/* ==========================================================================
   سالنیار نگار (SalonYar Negar) v3.1 - Modern RTL Mobile-First Design System
   بهینه‌سازی کامل پنل مدیریت برای موبایل (منوی کشویی + نوار پایین + کارت‌شدن خودکار جداول)
   ========================================================================== */

:root {
    --brand: #b76e79;
    --brand-dark: #944e59;
    --brand-soft: rgba(183, 110, 121, 0.12);
    --bg: #faf8f9;
    --bg-card: #ffffff;
    --bg-soft: #f4eff1;
    --text: #221c1e;
    --text-muted: #6c6165;
    --border: #e9dfe3;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #2563eb;
    --radius: 14px;
    --shadow: 0 8px 24px rgba(34, 28, 30, 0.06);
}

[data-theme="dark"] {
    --bg: #121013;
    --bg-card: #1c191e;
    --bg-soft: #262229;
    --text: #f3eff1;
    --text-muted: #a99ea3;
    --border: #332d37;
    --brand-soft: rgba(183, 110, 121, 0.22);
    --shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; overflow-x: hidden; }
body {
    margin: 0;
    font-family: 'Vazirmatn', Tahoma, system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    direction: rtl;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
code { background: var(--bg-soft); padding: .15rem .4rem; border-radius: 6px; font-size: .86em; word-break: break-all; }

.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 1rem; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    padding: .58rem 1.15rem;
    border-radius: 10px;
    border: 1px solid transparent;
    font-family: inherit;
    font-size: .92rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .18s ease;
    text-decoration: none !important;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); transform: translateY(-1px); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-sm { padding: .38rem .74rem; font-size: .82rem; border-radius: 8px; }
.btn-lg { padding: .82rem 1.5rem; font-size: 1rem; }

/* Cards & Grids */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem;
    box-shadow: var(--shadow);
    min-width: 0;
}
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.clients-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 1rem; align-items: start; }
.mobile-client-picker { display: none; }

/* Forms */
.form-stack { display: flex; flex-direction: column; gap: .9rem; min-width: 0; }
.form-group { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.form-group label { font-size: .86rem; font-weight: 600; color: var(--text); }
input[type="text"], input[type="password"], input[type="email"], input[type="number"],
input[type="url"], input[type="time"], input[type="date"], input[type="file"], select, textarea {
    width: 100%;
    padding: .62rem .85rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-card);
    color: var(--text);
    font-family: inherit;
    font-size: .92rem;
    transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}
.checkbox-row { display: flex; align-items: center; gap: .55rem; cursor: pointer; font-size: .9rem; }
.checkbox-row input { width: auto; }

/* Badges & Alerts */
.badge {
    display: inline-block;
    padding: .22rem .62rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-primary { background: var(--brand-soft); color: var(--brand); }
.badge-success { background: rgba(22, 163, 74, .14); color: #15803d; }
.badge-warning { background: rgba(217, 119, 6, .15); color: #b45309; }
.badge-danger  { background: rgba(220, 38, 38, .14); color: #b91c1c; }
.badge-info    { background: rgba(37, 99, 235, .14); color: #1d4ed8; }
.badge-dark    { background: rgba(100, 116, 139, .18); color: var(--text-muted); }
.badge-secondary { background: var(--bg-soft); color: var(--text-muted); }

.alert { padding: .85rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-size: .9rem; border: 1px solid transparent; }
.alert-success { background: rgba(22, 163, 74, .12); border-color: rgba(22, 163, 74, .3); color: #15803d; }
.alert-danger  { background: rgba(220, 38, 38, .12); border-color: rgba(220, 38, 38, .3); color: #b91c1c; }
.alert-warning { background: rgba(217, 119, 6, .12); border-color: rgba(217, 119, 6, .3); color: #b45309; }
.alert-info    { background: rgba(37, 99, 235, .12); border-color: rgba(37, 99, 235, .3); color: #1d4ed8; }
[data-theme="dark"] .alert-success { color: #86efac; }
[data-theme="dark"] .alert-danger  { color: #fca5a5; }
[data-theme="dark"] .alert-warning { color: #fcd34d; }
[data-theme="dark"] .alert-info    { color: #93c5fd; }

.chip { padding: .45rem .75rem; border-radius: 9px; font-weight: 600; text-align: center; }
.chip-ok  { background: rgba(22,163,74,.12); color: #15803d; }
.chip-err { background: rgba(220,38,38,.12); color: #b91c1c; }

/* Public Navbar & Sections */
.site-header {
    position: sticky; top: 0; z-index: 40;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}
[data-theme="dark"] .site-header { background: rgba(28, 25, 30, 0.92); }
.navbar { display: flex; align-items: center; justify-content: space-between; padding: .8rem 0; gap: .75rem; flex-wrap: wrap; }
.brand-logo { display: flex; align-items: center; gap: .55rem; font-weight: 800; font-size: 1.1rem; color: var(--text) !important; }
.brand-logo img { height: 36px; border-radius: 8px; }
.brand-badge { display: inline-block; background: var(--brand-soft); color: var(--brand); padding: .3rem .85rem; border-radius: 999px; font-size: .84rem; font-weight: 700; }
.nav-links { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

.section { padding: 2rem 0; }
.section-title { font-size: 1.4rem; margin: 0 0 .35rem; }
.section-mini-title { font-size: 1rem; margin: 0 0 .5rem; color: var(--brand); }
.cat-tabs { display: flex; gap: .5rem; flex-wrap: wrap; margin: 1rem 0 1.2rem; }
.cat-tab { padding: .48rem .95rem; border-radius: 999px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text); cursor: pointer; font-family: inherit; font-weight: 600; }
.cat-tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.service-item { display: flex; flex-direction: column; justify-content: space-between; border: 2px solid var(--border); border-radius: var(--radius); padding: 1rem; background: var(--bg-card); cursor: pointer; transition: all .16s ease; }
.service-item.selected { border-color: var(--brand); background: var(--brand-soft); }
.service-meta { display: flex; justify-content: space-between; align-items: center; margin-top: .75rem; font-size: .86rem; }

.day-strip { display: flex; gap: .55rem; overflow-x: auto; padding-bottom: .5rem; -webkit-overflow-scrolling: touch; }
.day-btn { min-width: 80px; padding: .6rem .5rem; border-radius: 12px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text); cursor: pointer; text-align: center; font-family: inherit; flex-shrink: 0; }
.day-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.day-btn.friday { border-style: dashed; opacity: .8; }

.slots-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: .55rem; margin-top: .85rem; }
.slot-btn { padding: .58rem .5rem; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text); cursor: pointer; font-family: inherit; font-weight: 600; text-align: center; transition: all .15s; }
.slot-btn:hover { border-color: var(--brand); }
.slot-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.faq-item { border: 1px solid var(--border); border-radius: 12px; background: var(--bg-card); margin-bottom: .65rem; overflow: hidden; }
.faq-q { width: 100%; text-align: right; background: transparent; border: 0; padding: .95rem 1.1rem; font-family: inherit; font-weight: 700; font-size: .95rem; color: var(--text); cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.faq-a { padding: 0 1.1rem .95rem; color: var(--text-muted); display: none; }
.faq-item.open .faq-a { display: block; }

.auth-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.25rem .85rem; }
.auth-card { width: 100%; max-width: 440px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 18px; padding: 1.5rem; box-shadow: var(--shadow); }

/* ==================== Admin Panel & Mobile App Shell ==================== */
.panel-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 260px; flex-shrink: 0; background: var(--bg-card); border-left: 1px solid var(--border);
    padding: 1.2rem .9rem; display: flex; flex-direction: column; gap: .35rem;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-head { display: flex; justify-content: space-between; align-items: center; padding: .3rem .5rem .9rem; border-bottom: 1px solid var(--border); margin-bottom: .5rem; }
.sidebar-brand { font-weight: 800; font-size: 1.02rem; }
.drawer-close-btn, .mobile-menu-btn { display: none; }
.mobile-drawer-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.48); z-index: 90; backdrop-filter: blur(2px); }
.mobile-drawer-backdrop.open { display: block; }

.side-link { display: flex; align-items: center; gap: .6rem; padding: .66rem .85rem; border-radius: 10px; color: var(--text); font-weight: 500; font-size: .92rem; }
.side-link:hover, .side-link.active { background: var(--brand-soft); color: var(--brand); text-decoration: none; font-weight: 700; }

.panel-main { flex: 1; min-width: 0; padding: 1.25rem 1.5rem; }
.panel-topbar {
    display: flex; justify-content: space-between; align-items: center; gap: .8rem;
    margin-bottom: 1.2rem; padding-bottom: .85rem; border-bottom: 1px solid var(--border); flex-wrap: wrap;
}

.mobile-bottom-nav { display: none; }

/* KPI Stat Cards */
.kpi-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; min-width: 0; }
.kpi-label { font-size: .8rem; color: var(--text-muted); }
.kpi-value { font-size: 1.35rem; font-weight: 800; margin-top: .2rem; color: var(--brand); word-break: break-word; }

/* Tables */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.data-table th, table.data-table td { padding: .72rem .75rem; border-bottom: 1px solid var(--border); text-align: right; vertical-align: middle; }
table.data-table th { background: var(--bg-soft); font-weight: 700; white-space: nowrap; }

/* Chat Box */
.chat-box { height: 380px; overflow-y: auto; display: flex; flex-direction: column; gap: .65rem; padding: 1rem; background: var(--bg-soft); border-radius: 12px; }
.chat-msg { max-width: 82%; padding: .65rem .9rem; border-radius: 12px; background: var(--bg-card); border: 1px solid var(--border); }
.chat-msg.mine { align-self: flex-start; background: var(--brand); color: #fff; border-color: var(--brand); }
.chat-msg .meta { font-size: .75rem; opacity: .8; margin-bottom: .2rem; }

/* ==================== Mobile & Tablet Responsive Polish ==================== */
@media (max-width: 960px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .clients-layout { grid-template-columns: 1fr; }
    .clients-sidebar-desktop { display: none; }
    .mobile-client-picker { display: block; margin-bottom: 1rem; }

    /* Slide-out RTL Drawer on Mobile/Tablet */
    .mobile-menu-btn, .drawer-close-btn { display: inline-flex; }
    .sidebar {
        position: fixed;
        top: 0;
        right: -290px;
        bottom: 0;
        width: 275px;
        height: 100dvh;
        z-index: 100;
        transition: right .24s ease;
        box-shadow: -8px 0 28px rgba(0,0,0,.22);
    }
    .sidebar.open { right: 0; }
    .panel-main { padding: .95rem .85rem 5.4rem; }
    .panel-topbar {
        position: sticky; top: 0; z-index: 30;
        background: var(--bg);
        padding: .65rem 0;
        margin-top: -.4rem;
    }

    /* Native-App-Like Bottom Tab Bar */
    .mobile-bottom-nav {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        position: fixed;
        bottom: 0; left: 0; right: 0;
        z-index: 50;
        background: var(--bg-card);
        border-top: 1px solid var(--border);
        padding: .35rem .25rem calc(.35rem + env(safe-area-inset-bottom, 0px));
        box-shadow: 0 -6px 20px rgba(0,0,0,.08);
    }
    .mobile-bottom-nav a {
        display: flex; flex-direction: column; align-items: center; justify-content: center;
        gap: .15rem; font-size: .7rem; font-weight: 600; color: var(--text-muted);
        padding: .25rem .15rem; border-radius: 10px; text-decoration: none;
    }
    .mobile-bottom-nav a .ico { font-size: 1.15rem; line-height: 1; }
    .mobile-bottom-nav a.active { color: var(--brand); background: var(--brand-soft); font-weight: 800; }
}

@media (max-width: 720px) {
    .grid-3, .grid-2 { grid-template-columns: 1fr; }
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
    .kpi-card { padding: .8rem; }
    .kpi-value { font-size: 1.1rem; }
    .card { padding: .95rem; }

    /* Prevent iOS Safari zoom on input focus */
    input[type="text"], input[type="password"], input[type="email"], input[type="number"],
    input[type="url"], input[type="time"], input[type="date"], select, textarea {
        font-size: 16px;
        min-height: 44px;
    }
    .btn { min-height: 40px; }
    .btn-sm { min-height: 36px; }

    /* Auto Stacked Card-Tables on Mobile (Zero cramped columns!) */
    table.data-table:not(.table-keep-scroll) thead { display: none; }
    table.data-table:not(.table-keep-scroll),
    table.data-table:not(.table-keep-scroll) tbody,
    table.data-table:not(.table-keep-scroll) tr,
    table.data-table:not(.table-keep-scroll) td {
        display: block;
        width: 100%;
    }
    table.data-table:not(.table-keep-scroll) tr {
        background: var(--bg-soft);
        border: 1px solid var(--border);
        border-radius: 12px;
        padding: .65rem .8rem;
        margin-bottom: .75rem;
    }
    table.data-table:not(.table-keep-scroll) td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: .75rem;
        padding: .42rem 0;
        border-bottom: 1px dashed var(--border);
        text-align: left;
    }
    table.data-table:not(.table-keep-scroll) td:last-child {
        border-bottom: 0;
        padding-bottom: .1rem;
    }
    table.data-table:not(.table-keep-scroll) td::before {
        content: attr(data-label);
        font-weight: 700;
        font-size: .8rem;
        color: var(--text-muted);
        text-align: right;
        flex-shrink: 0;
        max-width: 42%;
    }
    table.data-table:not(.table-keep-scroll) td[colspan] {
        display: block;
        text-align: center;
    }
    table.data-table:not(.table-keep-scroll) td[colspan]::before { display: none; }
}

@media print {
    .sidebar, .no-print, .mobile-bottom-nav, .mobile-menu-btn, .panel-topbar .btn { display: none !important; }
    .panel-main { padding: 0; }
    .card { box-shadow: none; border: 1px solid #ccc; }
}

/* ==================== ۵ قالب اختصاصی پنل مدیریت (Admin Themes) ==================== */
.ui-icon { display: inline-block; vertical-align: middle; flex-shrink: 0; }

[data-admin-theme="admin-rose"] {
    --brand: #b76e79; --brand-dark: #944e59; --brand-soft: rgba(183,110,121,.13);
    --bg: #faf7f8; --bg-card: #ffffff; --bg-soft: #f4edf0; --border: #e9dde1;
}
[data-admin-theme="admin-slate"] {
    --brand: #1e40af; --brand-dark: #1e3a8a; --brand-soft: rgba(30,64,175,.11);
    --bg: #f4f6fa; --bg-card: #ffffff; --bg-soft: #e9eef7; --border: #d7dfec;
}
[data-admin-theme="admin-emerald"] {
    --brand: #0f766e; --brand-dark: #115e59; --brand-soft: rgba(15,118,110,.12);
    --bg: #f3faf8; --bg-card: #ffffff; --bg-soft: #e6f4f1; --border: #cfe4df;
}
[data-admin-theme="admin-midnight"] {
    --brand: #d4af37; --brand-dark: #b59024; --brand-soft: rgba(212,175,55,.18);
    --bg: #0f1015; --bg-card: #181a22; --bg-soft: #222530; --text: #f3f4f8; --text-muted: #9ea4b8; --border: #2d3140;
}
[data-admin-theme="admin-midnight"] .btn-primary { color: #121216; }
[data-admin-theme="admin-royal"] {
    --brand: #6d28d9; --brand-dark: #5b21b6; --brand-soft: rgba(109,40,217,.12);
    --bg: #f8f6ff; --bg-card: #ffffff; --bg-soft: #f0ebff; --border: #e1d7fa;
}
