/* Bertina Mirror - Main Stylesheet */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --secondary: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #1f2937;
    --gray-900: #111827;
    --gray-800: #1f2937;
    --gray-700: #374151;
    --gray-600: #4b5563;
    --gray-500: #6b7280;
    --gray-400: #9ca3af;
    --gray-300: #d1d5db;
    --gray-200: #e5e7eb;
    --gray-100: #f3f4f6;
    --gray-50: #f9fafb;
    --white: #ffffff;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', monospace;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 8px;
    --radius-lg: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.6;
    min-height: 100vh;
    direction: rtl;
    text-align: right;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-dark);
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Header */
.header {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    flex-direction: row-reverse;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
}

.logo-img {
    width: 40px;
    height: 40px;
    max-width: 40px;
    max-height: 40px;
    flex-shrink: 0;
    overflow: hidden;
}

.nav {
    display: flex;
    align-items: center;
    gap: 2rem;
    flex-direction: row-reverse;
}

.nav a {
    color: var(--gray-600);
    font-weight: 500;
    padding: 0.5rem 0;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.nav a:hover, .nav a.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 3rem 0 4rem;
    text-align: center;
}

.hero h1 {
    font-size: 2.25rem;
    margin-bottom: 0.75rem;
}

.hero p {
    font-size: 1.05rem;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto 1.5rem;
}

/* Server Info Bar in Hero */
.server-info {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

.server-info-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.15);
    padding: 0.5rem 1rem;
    border-radius: 999px;
    font-size: 0.875rem;
    direction: ltr;
}

.server-info-item code {
    font-family: var(--font-mono);
    font-weight: 600;
}

/* Stats */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1.5rem;
    margin-top: -2.5rem;
    position: relative;
    z-index: 10;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    text-align: center;
    box-shadow: var(--shadow-md);
    direction: ltr;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.8125rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

/* Search */
.search-section {
    padding: 2rem 0 1rem;
}

.search-box {
    display: flex;
    gap: 0.75rem;
    max-width: 600px;
    margin: 0 auto;
    flex-direction: row-reverse;
}

.search-input {
    flex: 1;
    padding: 0.75rem 1.25rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color 0.2s;
    direction: rtl;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
}

.search-btn {
    padding: 0.75rem 1.5rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.search-btn:hover {
    background: var(--primary-dark);
}

/* Categories */
.categories {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    padding: 1rem 0;
}

.category-btn {
    padding: 0.5rem 1rem;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 999px;
    font-size: 0.875rem;
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.2s;
}

.category-btn:hover, .category-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Repository List */
.repos-section {
    padding: 1.5rem 0 4rem;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.section-title {
    font-size: 1.5rem;
    color: var(--gray-900);
}

.repos-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Repository Accordion Card */
.repo-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
    overflow: hidden;
    transition: box-shadow 0.2s;
}

.repo-card:hover {
    box-shadow: var(--shadow-md);
}

.repo-card-header {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    cursor: pointer;
    gap: 1rem;
    transition: background 0.15s;
}

.repo-card-header:hover {
    background: var(--gray-50);
}

.repo-icon {
    width: 44px;
    height: 44px;
    background: var(--gray-100);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.375rem;
    flex-shrink: 0;
}

.repo-info {
    flex: 1;
    min-width: 0;
}

.repo-name {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--gray-900);
}

.repo-desc-brief {
    font-size: 0.8125rem;
    color: var(--gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.repo-badges {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.repo-category-badge {
    font-size: 0.75rem;
    color: var(--primary);
    background: rgba(37, 99, 235, 0.1);
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    white-space: nowrap;
}

.repo-status {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    white-space: nowrap;
}

.status-completed { background: rgba(16, 185, 129, 0.1); color: #059669; }
.status-syncing { background: rgba(37, 99, 235, 0.1); color: var(--primary); }
.status-pending { background: rgba(245, 158, 11, 0.1); color: #d97706; }
.status-failed { background: rgba(239, 68, 68, 0.1); color: #dc2626; }

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.repo-toggle {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--gray-100);
    flex-shrink: 0;
    transition: transform 0.3s, background 0.15s;
    font-size: 0.75rem;
    color: var(--gray-500);
}

.repo-card.open .repo-toggle {
    transform: rotate(180deg);
    background: var(--primary);
    color: white;
}

/* Repo Detail Body */
.repo-card-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
}

.repo-card.open .repo-card-body {
    max-height: 2000px;
}

.repo-detail {
    padding: 0 1.5rem 1.5rem;
    border-top: 1px solid var(--gray-100);
}

.repo-detail-section {
    margin-top: 1.25rem;
}

.repo-detail-section h4 {
    font-size: 0.9rem;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.repo-detail-section h4 .step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.repo-detail-section p {
    font-size: 0.85rem;
    color: var(--gray-600);
    margin-bottom: 0.5rem;
}

/* Code Block */
.code-block {
    background: var(--gray-900);
    color: #e2e8f0;
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.7;
    overflow-x: auto;
    position: relative;
    direction: ltr;
    text-align: left;
    white-space: pre;
    margin-bottom: 0.5rem;
}

.code-block .comment {
    color: #64748b;
}

.code-block .copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: var(--gray-700);
    color: var(--gray-300);
    border: none;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--font-sans);
}

.code-block .copy-btn:hover {
    background: var(--primary);
    color: white;
}

.code-block .copy-btn.copied {
    background: var(--secondary);
    color: white;
}

/* Info box */
.info-box {
    background: rgba(37, 99, 235, 0.06);
    border: 1px solid rgba(37, 99, 235, 0.15);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    font-size: 0.8125rem;
    color: var(--gray-700);
    direction: rtl;
    text-align: right;
}

.info-box code {
    background: rgba(37, 99, 235, 0.1);
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.8em;
    direction: ltr;
    display: inline-block;
}

/* Repo meta grid */
.repo-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--gray-100);
}

.repo-meta-item {
    font-size: 0.8125rem;
}

.repo-meta-item .label {
    color: var(--gray-500);
    display: block;
    font-size: 0.75rem;
}

.repo-meta-item .value {
    color: var(--gray-800);
    font-weight: 500;
}

/* Access Protocols table */
.protocols-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    direction: ltr;
    text-align: left;
    margin-top: 0.5rem;
}

.protocols-table th {
    background: var(--gray-50);
    padding: 0.5rem 0.75rem;
    font-weight: 600;
    color: var(--gray-600);
    border-bottom: 2px solid var(--gray-200);
}

.protocols-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--gray-100);
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.protocols-table td:first-child {
    font-family: var(--font-sans);
    font-weight: 500;
    color: var(--gray-700);
}

/* How-to-use tabs inside repo detail */
.usage-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--gray-200);
    margin-bottom: 1rem;
    overflow-x: auto;
}

.usage-tab {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--gray-500);
    border: none;
    background: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: all 0.15s;
}

.usage-tab:hover {
    color: var(--gray-700);
}

.usage-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.usage-tab-content {
    display: none;
}

.usage-tab-content.active {
    display: block;
}

/* Footer */
.footer {
    background: var(--gray-900);
    color: var(--gray-400);
    padding: 3rem 0;
}

.footer-inner {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    direction: rtl;
}

.footer-section h4 {
    color: white;
    margin-bottom: 1rem;
}

.footer-section ul {
    list-style: none;
}

.footer-section li {
    margin-bottom: 0.5rem;
}

.footer-section a {
    color: var(--gray-400);
}

.footer-section a:hover {
    color: white;
}

.footer-bottom {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--gray-800);
    text-align: center;
    font-size: 0.875rem;
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--gray-500);
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    left: 1.5rem;
    z-index: 1100;
}

.toast {
    background: var(--gray-900);
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    margin-top: 0.5rem;
    animation: slideIn 0.3s ease;
    font-size: 0.875rem;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 768px) {
    .header-inner {
        flex-wrap: wrap;
        height: auto;
        padding: 0.75rem 0;
    }

    .nav {
        width: 100%;
        justify-content: center;
        margin-top: 0.75rem;
        gap: 1rem;
        font-size: 0.9rem;
    }

    .hero { padding: 2rem 0 3rem; }
    .hero h1 { font-size: 1.5rem; }
    .hero p { font-size: 0.95rem; }

    .server-info {
        gap: 0.5rem;
    }

    .server-info-item {
        font-size: 0.75rem;
        padding: 0.35rem 0.75rem;
    }

    .stats {
        grid-template-columns: repeat(2, 1fr);
        margin-top: -2rem;
        gap: 0.75rem;
    }

    .repo-card-header {
        padding: 0.875rem 1rem;
        flex-wrap: wrap;
    }

    .repo-badges {
        width: 100%;
        margin-top: 0.25rem;
        margin-right: 3.25rem;
    }

    .repo-detail {
        padding: 0 1rem 1rem;
    }

    .search-box {
        flex-direction: column-reverse;
    }

    .repo-meta-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.hidden { display: none !important; }
