@font-face {
    font-family: "IRANSans";
    src: local("IRANSans"), local("IRAN Sans"), local("IRANSansWeb"), local("IRANSansWebFa"), local("Tahoma");
}

:root {
    --bg: #f5f7fb;
    --card: #ffffff;
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --success: #16a34a;
    --danger: #dc2626;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

body[data-theme="dark"] {
    --bg: #0f172a;
    --card: #111827;
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --border: #1f2937;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "IRANSans", Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    direction: rtl;
}

.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: linear-gradient(180deg, #111827, #1e293b);
    color: #fff;
    padding: 24px 18px;
}

body[data-theme="dark"] .sidebar {
    background: linear-gradient(180deg, #0b1220, #111827);
}

.sidebar h1 {
    font-size: 18px;
    margin: 0 0 16px;
}

.user-card {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
}

.sidebar nav a {
    display: block;
    padding: 8px 12px;
    color: #cbd5f5;
    text-decoration: none;
    border-radius: 10px;
    margin-bottom: 6px;
    font-size: 15px;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 12px 0;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    border: none;
    color: #e2e8f0;
    cursor: pointer;
    font-size: 12px;
}

.nav-section {
    background: none;
    border: none;
    width: 100%;
    color: #94a3b8;
    font-size: 15px;
    font-weight: 600;
    margin: 12px 0 6px;
    text-align: right;
    padding: 6px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.nav-section .nav-toggle {
    color: inherit;
}

.nav-section.open {
    color: #e2e8f0;
}

.nav-toggle {
    font-size: 12px;
    transition: transform 0.2s ease;
}

.nav-section.open .nav-toggle {
    transform: rotate(180deg);
}

.nav .nav-group {
    display: none;
    margin-bottom: 8px;
}

.nav .nav-group.open {
    display: block;
}

.cards.modern .card {
    border: 1px solid var(--border);
    background: linear-gradient(145deg, var(--card), rgba(255, 255, 255, 0.9));
}

body[data-theme="dark"] .cards.modern .card {
    background: linear-gradient(145deg, #111827, #0f172a);
}

@media (max-width: 1024px) {
    .layout {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
    }
    main {
        padding: 20px;
    }
}

@media (max-width: 640px) {
    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }
    .search input {
        min-width: 180px;
    }
}

.sidebar nav a.active,
.sidebar nav a:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.sidebar nav .logout {
    margin-top: 16px;
    background: rgba(239, 68, 68, 0.2);
    color: #fecaca;
}

main {
    flex: 1;
    padding: 28px 32px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 16px;
}

.search {
    display: flex;
    gap: 8px;
    align-items: center;
}

.search input {
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    min-width: 240px;
    background: var(--card);
    color: var(--text);
}

.sidebar-toggle {
    display: none;
    border: none;
    background: var(--card);
    color: var(--text);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 18px;
    box-shadow: var(--shadow);
}

.search button {
    padding: 8px 16px;
    border: none;
    background: var(--primary);
    color: #fff;
    border-radius: 10px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    text-decoration: none;
    margin-bottom: 16px;
}

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

.table-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.table-actions .button {
    margin-bottom: 0;
    padding: 6px 12px;
    font-size: 13px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}

.page-settings .form {
    margin-bottom: 0;
}

h2 {
    margin-top: 0;
}

.form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    background: var(--card);
    padding: 18px;
    border-radius: 16px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.form label {
    display: flex;
    flex-direction: column;
    font-size: 14px;
    gap: 6px;
    color: var(--text);
}

.form input,
.form select,
.form textarea {
    padding: 9px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    font-family: inherit;
    background: var(--card);
    color: var(--text);
    width: 100%;
    box-sizing: border-box;
}

.form select {
    min-height: 42px;
}

.form .span-2 {
    grid-column: span 2;
}

.form .form-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
}

.form textarea {
    min-height: 80px;
    resize: vertical;
}

.form button {
    align-self: end;
    padding: 10px 16px;
    border: none;
    background: var(--primary);
    color: #fff;
    border-radius: 10px;
    cursor: pointer;
}

.form button:hover {
    background: var(--primary-dark);
}

.secondary {
    background: #64748b;
}

.secondary:hover {
    background: #475569;
}

.checkbox {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.sidebar-backdrop {
    display: none;
}

@media (max-width: 900px) {
    .sidebar-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .layout {
        flex-direction: row;
    }
    .sidebar {
        position: fixed;
        top: 0;
        right: 0;
        height: 100vh;
        width: 280px;
        z-index: 30;
        transform: translateX(100%);
        transition: transform 0.2s ease;
    }
    body.nav-open .sidebar {
        transform: translateX(0);
    }
    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.5);
        z-index: 20;
    }
    body.nav-open .sidebar-backdrop {
        display: block;
    }
    main {
        padding: 16px;
    }
    .topbar {
        flex-wrap: wrap;
        justify-content: flex-start;
    }
    .search {
        width: 100%;
    }
    .search input {
        min-width: 0;
        flex: 1;
    }
    table {
        display: block;
        overflow-x: auto;
    }
}

th, td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    text-align: right;
    font-size: 14px;
}

th {
    background: #f8fafc;
    color: var(--muted);
}

body[data-theme="dark"] .form input,
body[data-theme="dark"] .form select,
body[data-theme="dark"] .form textarea {
    background: #0b1220;
}

body[data-theme="dark"] table {
    background: #0b1220;
}

body[data-theme="dark"] th {
    background: #0f172a;
    color: #cbd5f5;
}

body[data-theme="dark"] td {
    border-bottom-color: #1f2937;
}

.alert {
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 16px;
}

.alert.success {
    background: #dcfce7;
    color: #166534;
}

.alert.error {
    background: #fee2e2;
    color: #991b1b;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.cards .span-2 {
    grid-column: span 2;
}

.card {
    background: var(--card);
    padding: 18px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.card-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-icon {
    font-size: 18px;
    width: 28px;
    height: 28px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(99, 102, 241, 0.12);
}

.card strong {
    font-size: 18px;
}

.progress {
    background: rgba(148, 163, 184, 0.2);
    border-radius: 999px;
    overflow: hidden;
    height: 10px;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 999px;
    transition: width 0.3s ease;
}

.inline-form {
    display: inline-flex;
    gap: 6px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.inline-form input,
.inline-form select {
    padding: 6px 8px;
    font-size: 12px;
}

.inline-form button {
    padding: 6px 10px;
    font-size: 12px;
    background: var(--primary);
}

.inline-form .secondary {
    background: #64748b;
}

.danger {
    color: var(--danger);
    text-decoration: none;
    font-size: 13px;
}

.note,
.muted {
    color: var(--muted);
    font-size: 13px;
}

.section-title {
    grid-column: 1 / -1;
    font-weight: 600;
    color: var(--text);
    padding-top: 8px;
}

.code-block {
    background: #0f172a;
    color: #e2e8f0;
    padding: 12px;
    border-radius: 12px;
    font-size: 13px;
    overflow-x: auto;
}

.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e2e8f0, #f8fafc);
}

.auth-card {
    background: var(--card);
    padding: 32px;
    border-radius: 18px;
    width: min(520px, 92vw);
    box-shadow: var(--shadow);
}

.auth-card h1 {
    margin-top: 0;
}
