:root {
    --font-sans: 'Vazirmatn', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    --radius-lg: 1rem;
    --radius-md: 0.75rem;
    --radius-sm: 0.5rem;

    --transition-fast: 0.15s ease-out;
}

/* تم دارک (پیش‌فرض) */
body.theme-dark {
    --bg-body: #020617;
    --bg-elevated: #020617;
    --bg-card: #020617;
    --bg-card-soft: #020617;
    --border-subtle: rgba(148, 163, 184, 0.2);
    --text-main: #e5e7eb;
    --text-muted: #9ca3af;
    --accent: #6366f1;
    --accent-soft: rgba(99, 102, 241, 0.12);
    --danger: #ef4444;
    --danger-soft: rgba(248, 113, 113, 0.12);
    --sidebar-bg: rgba(15, 23, 42, 0.96);
    --sidebar-border: rgba(148, 163, 184, 0.2);
    --topbar-bg: rgba(15, 23, 42, 0.9);
    --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.75);
}

/* تم لایت */
body.theme-light {
    --bg-body: #f3f4f6;
    --bg-elevated: #f9fafb;
    --bg-card: #ffffff;
    --bg-card-soft: #f3f4f6;
    --border-subtle: rgba(148, 163, 184, 0.4);
    --text-main: #0f172a;
    --text-muted: #6b7280;
    --accent: #4f46e5;
    --accent-soft: rgba(79, 70, 229, 0.12);
    --danger: #dc2626;
    --danger-soft: rgba(248, 113, 113, 0.16);
    --sidebar-bg: #ffffff;
    --sidebar-border: rgba(148, 163, 184, 0.3);
    --topbar-bg: rgba(249, 250, 251, 0.9);
    --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.15);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    font-family: var(--font-sans);
    background: radial-gradient(circle at top, rgba(99, 102, 241, 0.28), transparent 55%),
                radial-gradient(circle at bottom, rgba(14, 165, 233, 0.2), transparent 55%),
                var(--bg-body);
    color: var(--text-main);
    transition: background 0.25s ease, color 0.25s ease;
}

/* Layout */

.app-shell {
    display: grid;
    grid-template-rows: auto 1fr;
    grid-template-columns: minmax(0, 1fr);
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--topbar-bg);
    backdrop-filter: blur(18px);
}

.topbar__brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.topbar__brand i {
    color: var(--accent);
}

.topbar__actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topbar__user {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--border-subtle);
    background: radial-gradient(circle at top left, rgba(99, 102, 241, 0.16), transparent 60%);
    font-size: 0.85rem;
}

.topbar__user i {
    color: var(--accent);
}

.topbar__menu-btn {
    display: none;
}

/* Sidebar */

.sidebar {
    position: fixed;
    top: 3.25rem;
    bottom: 0;
    right: 0;
    width: 230px;
    border-left: 1px solid var(--sidebar-border);
    background: var(--sidebar-bg);
    backdrop-filter: blur(18px);
    padding: 1rem 0.75rem;
    z-index: 30;
}

.sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sidebar li a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.85rem;
    border-radius: 999px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

.sidebar li a i {
    width: 1.1rem;
    text-align: center;
}

.sidebar li a:hover {
    background: var(--accent-soft);
    color: var(--accent);
    transform: translateX(-2px);
}

.sidebar li.active a {
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    color: #f9fafb;
    box-shadow: 0 12px 30px rgba(79, 70, 229, 0.4);
}

/* Main area */

.main {
    grid-row: 2;
    display: flex;
}

.main__inner {
    flex: 1;
    padding: 1.5rem;
    margin-right: 250px;
    max-width: 1200px;
    width: 100%;
}


body.no-sidebar .main__inner {
    margin-right: 0;
    max-width: 100%;
}

body.no-sidebar .main {
    justify-content: center;
}
/* Cards & common UI */

.card {
    border-radius: var(--radius-lg);
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.82), rgba(15, 23, 42, 0.96));
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(148, 163, 184, 0.22);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}

body.theme-light .card {
    background: var(--bg-card);
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 1rem;
}

.page-header h2 {
    margin: 0;
    font-size: 1.2rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.page-header .actions {
    display: flex;
    gap: 0.5rem;
}

/* Buttons */

.btn-primary,
.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    border-radius: 999px;
    border: 1px solid transparent;
    padding: 0.45rem 0.9rem;
    text-decoration: none;
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    color: #f9fafb;
    box-shadow: 0 10px 30px rgba(79, 70, 229, 0.55);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 40px rgba(79, 70, 229, 0.65);
}

.btn-secondary {
    background: transparent;
    border-color: var(--border-subtle);
    color: var(--text-muted);
}

.btn-secondary:hover {
    background: var(--bg-card-soft);
    color: var(--text-main);
}

/* Icon button */

.icon-button {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: 1px solid var(--border-subtle);
    background: rgba(15, 23, 42, 0.4);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--transition-fast), transform var(--transition-fast), color var(--transition-fast);
}

body.theme-light .icon-button {
    background: rgba(249, 250, 251, 0.9);
}

.icon-button:hover {
    background: var(--accent-soft);
    color: var(--accent);
    transform: translateY(-1px);
}

.icon-button--danger:hover {
    background: var(--danger-soft);
    color: var(--danger);
}

/* Tables */

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.table thead {
    background: rgba(15, 23, 42, 0.55);
}

body.theme-light .table thead {
    background: #e5e7eb;
}

.table th,
.table td {
    padding: 0.6rem 0.5rem;
    text-align: right;
}

/* خط جداکننده هر ردیف جدول */
.table tr {
    border-bottom: 1px solid rgba(148, 163, 184, 0.22);
}

.table thead tr {
    border-bottom: 1px solid rgba(148, 163, 184, 0.3);
}

.table tbody tr:last-child {
    border-bottom: none;
}

.table th {
    font-weight: 500;
    color: var(--text-muted);
}

.table tbody tr:hover {
    background: rgba(15, 23, 42, 0.45);
}

body.theme-light .table tbody tr:hover {
    background: #eef2ff;
}

.table-actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.btn-link {
    border: none;
    background: none;
    color: #fff;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
    padding: 0;
    text-decoration: none;
    border-radius: 7px;
    padding: 3px 7px;
    background-color: var(--accent);
}

.btn-link--danger {
    color: #fff;
    background: var(--danger);
    padding: 5px 12px !important;
}

/* Badges */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    border-radius: 999px;
    border: 1px solid var(--border-subtle);
    font-size: 0.75rem;
    padding: 0.08rem 0.5rem;
    color: var(--text-muted);
}

.badge--vip {
    border-color: rgba(250, 204, 21, 0.7);
    background: radial-gradient(circle at top left, rgba(250, 204, 21, 0.28), transparent 55%);
    color: #fde68a;
}

/* Forms */

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.9rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

input[type="text"],
input[type="password"],
textarea,
select {
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    padding: 0.4rem 0.6rem;
    font-size: 0.9rem;
    background: rgba(15, 23, 42, 0.6);
    color: var(--text-main);
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

body.theme-light input[type="text"],
body.theme-light input[type="password"],
body.theme-light textarea,
body.theme-light select {
    background: #ffffff;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.6);
}

textarea {
    resize: vertical;
}

.form-inline {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 0.75rem 0;
    flex-wrap: wrap;
}

.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
}

.permissions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.4rem;
    margin-top: 0.4rem;
}

.form-actions {
    display: flex;
    justify-content: flex-start;
    gap: 0.5rem;
    margin-top: 1rem;
}

.muted {
    color: var(--text-muted);
    font-size: 0.8rem;
}


.btn-phone-add {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    padding-inline: 0.8rem;
    padding-block: 0.25rem;
}
/* Alerts */

.alert {
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.alert-error {
    border: 1px solid var(--danger);
    background: var(--danger-soft);
    color: #fecaca;
}

/* Login layout */

.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 60px);
    padding: 2rem 1rem;
}

.login-card {
    max-width: 360px;
    width: 100%;
    border-radius: 1.25rem;
    background: radial-gradient(circle at top left, rgba(99, 102, 241, 0.2), transparent 60%),
                radial-gradient(circle at bottom right, rgba(56, 189, 248, 0.25), transparent 60%),
                rgba(15, 23, 42, 0.85);
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.25);
    padding: 1.5rem 1.75rem;
}

.login-card h1 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.login-card input {
    display: block;
    width: 100%;
}

.login-card button[type="submit"] {
    margin-top: 10px;
}

/* Dashboard cards */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.stat-card__icon {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-soft);
    color: var(--accent);
}

.stat-card__label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.stat-card__value {
    font-size: 1.2rem;
    font-weight: 600;
}

/* Search box */

.search-box {
    margin-bottom: 0.75rem;
}

.search-box input {
    width: 100%;
}

/* Customer detail */

.customer-detail__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem 1.25rem;
    margin-top: 0.75rem;
}

.customer-detail__item {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.customer-detail__item--full {
    grid-column: 1 / -1;
}

.customer-detail__item .label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.customer-detail__item .value {
    font-size: 0.9rem;
}

/* Phones */

.phone-row + .phone-row {
    margin-top: 0.35rem;
}

/* Responsive */

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(100%);
        transition: transform 0.2s ease-out;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .topbar__menu-btn {
        display: inline-flex;
    }

    .main__inner {
        margin-right: 0;
        padding: 1rem;
    }
}





@media (max-width:500px) {
    /* هدر جدول رو مخفی کن */
    .table thead {
        display: none;
    }

    .table {
        width: 100%;
        border-collapse: collapse;
    }

    .table tbody,
    .table tr,
    .table td {
        display: block;
        width: 100%;
    }

    .table tbody tr {
        border: 1px solid var(--border-subtle);
        border-radius: 10px;
        margin-bottom: 10px;
        overflow: hidden;
        background: var(--bg-card);
        box-shadow: var(--shadow-soft);
    }

    .table tbody td {
        padding: 6px 10px;
        text-align: right;
        position: relative;
        padding-right: 90px; /* جا برای لیبل‌ها */
        box-sizing: border-box;
        border-bottom: 1px solid var(--border-subtle);
        font-size: 13px;
        color: var(--text-main);
        background: transparent;
    }

    .table tbody td:last-child:not(.table-actions) {
        border-bottom: 1px solid var(--border-subtle);
    }

    /* لیبل هر ستون با :before */
    .table tbody td::before {
        content: "";
        position: absolute;
        right: 10px;
        top: 6px;
        font-weight: 600;
        font-size: 12px;
        color: var(--text-muted);
    }

    .table tbody td:nth-child(1)::before {
        content: "نام";
    }

    .table tbody td:nth-child(2)::before {
        content: "VIP";
    }

    .table tbody td:nth-child(3)::before {
        content: "کارشناس";
    }

    .table tbody td:nth-child(4)::before {
        content: "شماره تماس";
    }

    /* بخش عملیات در انتهای کارت */
    .table tbody td.table-actions {
        padding-right: 10px;
        text-align: center;
        border-top: 1px solid var(--border-subtle);
        border-bottom: none;
    }

    .table tbody td.table-actions::before {
        content: "عملیات";
        position: static;
        display: block;
        text-align: right;
        margin-bottom: 4px;
        font-weight: 600;
        font-size: 12px;
        color: var(--text-muted);
    }

    .table tbody td.table-actions .btn-link,
    .table tbody td.table-actions form {
        display: inline-block;
        margin: 2px 4px;
    }

    .page-header h2 {
        font-size: 1rem;
    }

    .page-header {
        flex-direction: column;
    }

    .page-header .actions {
        width: 100%;
        justify-content: space-between;
        flex-direction: row-reverse;
        
    }

    .page-header .actions a {
        font-size: .7rem;
        padding: 7px;
    }
    
}
