@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/vazirmatn/Vazirmatn-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/vazirmatn/Vazirmatn-Medium.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/vazirmatn/Vazirmatn-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-muted: #64748b;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #0891b2;
    --sidebar-w: 260px;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 10px 25px rgba(15, 23, 42, 0.08);
}

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

html { font-size: 16px; }

body {
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    direction: rtl;
    min-height: 100vh;
}

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

img { max-width: 100%; }

/* Layout */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-left: 1px solid var(--border);
    position: fixed;
    top: 0; right: 0; bottom: 0;
    overflow-y: auto;
    z-index: 100;
    transition: transform .25s ease;
}
.main-content {
    flex: 1;
    min-width: 0;
}
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: .75rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}
.page-body { padding: 1.25rem; }

.sidebar-brand {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border);
}
.sidebar-brand h2 { font-size: 1.1rem; font-weight: 700; }
.sidebar-brand p { font-size: .8rem; color: var(--text-muted); margin-top: .15rem; }

.nav-menu { padding: .75rem; }
.nav-item {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .65rem .85rem;
    border-radius: var(--radius);
    color: var(--text);
    margin-bottom: .2rem;
    font-size: .9rem;
    transition: background .15s;
}
.nav-item:hover { background: #f1f5f9; color: var(--text); }
.nav-item.active { background: #eff6ff; color: var(--primary); font-weight: 500; }
.nav-item i { width: 18px; text-align: center; color: var(--text-muted); }
.nav-item.active i { color: var(--primary); }
.nav-badge {
    margin-right: auto;
    background: var(--danger);
    color: #fff;
    font-size: .7rem;
    padding: .1rem .45rem;
    border-radius: 999px;
    min-width: 20px;
    text-align: center;
}

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h3 { font-size: 1rem; font-weight: 600; }
.card-body { padding: 1.25rem; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    cursor: pointer;
    transition: box-shadow .15s, transform .15s;
}
.stat-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.stat-card .label { font-size: .8rem; color: var(--text-muted); }
.stat-card .value { font-size: 1.6rem; font-weight: 700; margin-top: .25rem; }
.stat-card .icon { float: left; font-size: 1.5rem; opacity: .5; }

.announcement-card {
    border-right: 4px solid var(--info);
    background: linear-gradient(135deg, #f0f9ff 0%, #ffffff 100%);
}

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: .35rem; }
.form-control {
    width: 100%;
    padding: .6rem .85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: .9rem;
    background: var(--surface);
    transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { cursor: pointer; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .55rem 1.1rem;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: .9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, opacity .15s;
    text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { background: #f1f5f9; color: var(--text); }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: .7rem 1rem; text-align: right; border-bottom: 1px solid var(--border); }
th { background: #f8fafc; font-weight: 600; color: var(--text-muted); font-size: .8rem; }
tr:hover td { background: #fafbfc; }
.clickable-row { cursor: pointer; }

/* Pagination */
.pagination-wrap { padding: 1rem; border-top: 1px solid var(--border); }
.pagination { display: flex; flex-wrap: wrap; gap: .35rem; justify-content: center; align-items: center; }
.pagination-link {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 2rem; padding: .35rem .65rem; border-radius: var(--radius);
    border: 1px solid var(--border); color: var(--text); font-size: .85rem;
    text-decoration: none; background: #fff;
}
.pagination-link:hover { background: #f1f5f9; color: var(--text); }
.pagination-link.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination-ellipsis { padding: 0 .25rem; color: var(--text-muted); }

/* Combo select */
.combo-select { position: relative; }
.combo-select-trigger {
    display: flex; align-items: center; justify-content: space-between; gap: .5rem;
    width: 100%; text-align: right; cursor: pointer; background: #fff;
}
.combo-select-trigger .combo-select-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-select-trigger .combo-select-label.is-placeholder { color: var(--text-muted); }
.combo-select-trigger i { color: var(--text-muted); font-size: .75rem; transition: transform .15s; }
.combo-select.open .combo-select-trigger i { transform: rotate(180deg); }
.combo-select-dropdown {
    display: none; position: absolute; z-index: 120; top: calc(100% + 4px); right: 0; left: 0;
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); overflow: hidden;
}
.combo-select.open .combo-select-dropdown { display: block; }
.combo-select-search-wrap { padding: .5rem; border-bottom: 1px solid var(--border); background: #f8fafc; }
.combo-select-search {
    width: 100%; border: 1px solid var(--border); border-radius: var(--radius);
    padding: .45rem .65rem; font-size: .88rem; outline: none;
}
.combo-select-search:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37,99,235,.12); }
.combo-select-list { list-style: none; margin: 0; padding: .25rem 0; max-height: 220px; overflow-y: auto; }
.combo-select-option {
    padding: .55rem .75rem; cursor: pointer; font-size: .88rem;
    border-bottom: 1px solid #f1f5f9;
}
.combo-select-option:last-child { border-bottom: none; }
.combo-select-option:hover, .combo-select-option.focused { background: #eff6ff; color: var(--primary); }
.combo-select-option.selected { background: #dbeafe; font-weight: 500; }
.combo-select-empty { padding: .75rem; text-align: center; color: var(--text-muted); font-size: .85rem; }

/* Badges */
.badge {
    display: inline-block;
    padding: .15rem .55rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 500;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #cffafe; color: #155e75; }
.badge-muted { background: #f1f5f9; color: #475569; }

/* Alerts */
.alert {
    padding: .75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: .9rem;
}
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: #e0f2fe; color: #075985; border: 1px solid #bae6fd; }

/* Login */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: linear-gradient(135deg, #f0f9ff 0%, #f8fafc 50%, #eff6ff 100%);
}
.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 4px);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
}
.login-card h1 { font-size: 1.35rem; text-align: center; margin-bottom: .25rem; }
.login-card .subtitle { text-align: center; color: var(--text-muted); font-size: .85rem; margin-bottom: 1.5rem; }

/* License blocked */
.license-block-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background:
        radial-gradient(ellipse 80% 60% at 50% -10%, rgba(239, 68, 68, .18), transparent),
        radial-gradient(ellipse 60% 50% at 100% 100%, rgba(59, 130, 246, .12), transparent),
        linear-gradient(160deg, #0f172a 0%, #1e293b 45%, #0f172a 100%);
    font-family: 'Vazirmatn', Tahoma, sans-serif;
}
.license-block-card {
    width: 100%;
    max-width: 440px;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 20px;
    padding: 2.25rem 2rem;
    text-align: center;
    color: #f8fafc;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, .45);
    backdrop-filter: blur(12px);
}
.license-block-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 1.25rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    background: linear-gradient(135deg, rgba(251, 191, 36, .25), rgba(239, 68, 68, .2));
    border: 1px solid rgba(251, 191, 36, .35);
    color: #fbbf24;
}
.license-block-card h1 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: .75rem;
    color: #fff;
}
.license-block-message {
    font-size: .95rem;
    line-height: 1.75;
    color: #cbd5e1;
    margin-bottom: 1.5rem;
}
.license-block-domain {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-size: .78rem;
    color: #94a3b8;
    background: rgba(15, 23, 42, .5);
    border: 1px solid rgba(148, 163, 184, .2);
    border-radius: 999px;
    padding: .35rem .85rem;
    margin-bottom: 1.5rem;
    direction: ltr;
    font-family: ui-monospace, monospace;
}
.license-block-hint {
    font-size: .82rem;
    color: #64748b;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, .08);
}
.license-block-hint i { color: #60a5fa; margin-left: .25rem; }
.license-block-brand {
    margin-top: 1.75rem;
    font-size: .75rem;
    color: #475569;
    letter-spacing: .02em;
}

/* Booth map */
.booth-map-container {
    position: relative;
    background: #f1f5f9;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: auto;
    max-height: 70vh;
}
.booth-map-svg { display: block; }
.booth-rect {
    cursor: pointer;
    stroke: #fff;
    stroke-width: 2;
    transition: opacity .15s, filter .15s;
}
.booth-rect:hover { filter: brightness(1.1); }
.booth-available { fill: #22c55e; }
.booth-reserved { fill: #f59e0b; }
.booth-sold { fill: #ef4444; }
.booth-blocked { fill: #94a3b8; }
.booth-selected { stroke: var(--primary); stroke-width: 4; filter: drop-shadow(0 0 6px rgba(37,99,235,.5)); }
.editor-booth.selected .booth-rect { stroke: var(--primary); stroke-width: 4; filter: drop-shadow(0 0 6px rgba(37,99,235,.5)); }

.map-legend { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: .75rem; font-size: .8rem; }
.legend-item { display: flex; align-items: center; gap: .35rem; }
.legend-dot { width: 14px; height: 14px; border-radius: 3px; }

/* Chart placeholder */
.chart-bar { display: flex; align-items: flex-end; gap: .5rem; height: 180px; padding-top: 1rem; }
.chart-bar .bar {
    flex: 1;
    background: var(--primary);
    border-radius: 4px 4px 0 0;
    min-height: 4px;
    position: relative;
    cursor: pointer;
    opacity: .85;
    transition: opacity .15s;
}
.chart-bar .bar:hover { opacity: 1; }
.chart-bar .bar span {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    font-size: .7rem;
    white-space: nowrap;
    color: var(--text-muted);
    margin-bottom: 2px;
}

/* Ticket chat */
.ticket-messages { max-height: 400px; overflow-y: auto; padding: 1rem; }
.ticket-msg {
    max-width: 75%;
    padding: .65rem 1rem;
    border-radius: var(--radius);
    margin-bottom: .75rem;
    font-size: .88rem;
}
.ticket-msg.staff { background: #eff6ff; margin-left: auto; margin-right: 0; }
.ticket-msg.user { background: #f1f5f9; }
.ticket-msg .meta { font-size: .7rem; color: var(--text-muted); margin-top: .25rem; }

/* Sidebar toggle */
.menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1.05rem;
    cursor: pointer;
    padding: 0;
    color: var(--text);
    transition: background .15s, border-color .15s;
}
.menu-toggle:hover { background: #f1f5f9; }

html.sidebar-open .menu-toggle {
    display: none;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 99;
    opacity: 0;
    transition: opacity .25s ease;
    pointer-events: none;
}

.sidebar {
    transform: translateX(100%);
}
.main-content {
    margin-right: 0;
    transition: margin-right .25s ease;
}

html.sidebar-open .sidebar {
    transform: translateX(0);
}
html.sidebar-open .main-content {
    margin-right: var(--sidebar-w);
}
html.sidebar-open .sidebar-overlay {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

.sidebar-brand-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .5rem;
}

.sidebar-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text-muted);
    cursor: pointer;
    flex-shrink: 0;
    transition: background .15s, color .15s;
}
.sidebar-close:hover {
    background: #f1f5f9;
    color: var(--text);
}

@media (min-width: 901px) {
    html.sidebar-open .sidebar-overlay {
        display: none;
        opacity: 0;
        pointer-events: none;
    }
}

@media (max-width: 900px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    html.sidebar-open .main-content { margin-right: 0; }

    .page-body { padding: .75rem; }
    .topbar {
        padding: .6rem .75rem;
        flex-wrap: wrap;
        gap: .5rem;
    }
    .topbar h1 {
        font-size: .92rem !important;
        line-height: 1.4;
    }
    .card-header {
        flex-wrap: wrap;
        gap: .5rem;
        padding: .85rem 1rem;
    }
    .card-body { padding: .85rem; }
    .card-header .flex { flex-wrap: wrap; }
    .btn { max-width: 100%; }
    .flex.gap-1 { flex-wrap: wrap; }
    .flex.justify-between { flex-wrap: wrap; gap: .5rem; }

    table { font-size: .78rem; }
    th, td {
        padding: .5rem .55rem;
        vertical-align: top;
    }
    .table-wrap {
        margin: 0 -.25rem;
        -webkit-overflow-scrolling: touch;
    }

    .ticket-messages { max-height: 55vh; padding: .75rem; }
    .ticket-msg { max-width: 92%; font-size: .84rem; }

    .stat-card { padding: .9rem 1rem; }
    .stat-card .value { font-size: 1.35rem; }

    .login-card { padding: 1.35rem; margin: .5rem; }
    .announcement-card .card-body { padding: .9rem; }

    .nav-item { font-size: .85rem; padding: .55rem .75rem; }
    .form-control { font-size: .88rem; }
    .empty-state { padding: 2rem .75rem; }

    .chart-bar {
        height: 140px;
        overflow-x: auto;
        padding-bottom: .5rem;
    }
    .chart-bar .bar { min-width: 28px; }
}

@media (max-width: 600px) {
    html { font-size: 15px; }

    .page-body { padding: .6rem; }
    .btn-sm { padding: .3rem .55rem; font-size: .75rem; }
    .badge { font-size: .7rem; }
    .card-header h3 { font-size: .92rem; }

    th, td { white-space: normal; word-break: break-word; }
    .topbar .text-muted { width: 100%; font-size: .78rem !important; }

    .map-studio-toolbar {
        padding: .55rem .65rem;
    }
    .map-studio-toolbar .text-muted {
        width: 100%;
        margin-right: 0 !important;
        font-size: .72rem !important;
    }
}

@media (max-width: 900px) {
    .map-studio-layout {
        grid-template-columns: 1fr !important;
    }
    .map-studio-panel { order: -1; }
    .map-studio-viewport { max-height: 55vh; }
    .jalali-datepicker {
        width: min(280px, calc(100vw - 24px));
    }
}

/* Utilities */
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.gap-1 { gap: .5rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state i { font-size: 2.5rem; margin-bottom: .75rem; opacity: .4; }
