/* ===== Admin Panel Styles ===== */
:root {
    --bg-primary: #0a0f0d;
    --bg-secondary: #111916;
    --bg-card: #151f1a;
    --bg-sidebar: #0d1410;
    --green-primary: #0d5c2e;
    --green-light: #1a7a42;
    --green-dark: #073d1f;
    --green-glow: rgba(10, 77, 38, 0.25);
    --white: #ffffff;
    --text-primary: #e8f5e9;
    --text-secondary: #a5d6a7;
    --text-muted: #6b8f71;
    --border: rgba(0, 200, 83, 0.12);
    --danger: #ef5350;
    --warning: #ffa726;
    --info: #42a5f5;
    --radius: 10px;
    --font: 'Vazirmatn', sans-serif;
}

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

body.admin-body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex; min-height: 100vh;
}

/* Sidebar */
.admin-sidebar {
    width: 260px; background: var(--bg-sidebar);
    border-left: 1px solid var(--border);
    display: flex; flex-direction: column;
    position: fixed; top: 0; right: 0; height: 100vh; z-index: 100;
    transition: transform 0.3s ease;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 0.65rem;
    padding: 1.25rem 1.5rem; font-size: 1.1rem; font-weight: 700;
    border-bottom: 1px solid var(--border);
}
.sidebar-brand .site-logo--admin { filter: brightness(1.1); }
.site-logo { display: block; object-fit: contain; width: auto; }
.site-logo--login { height: 72px; max-width: 160px; margin: 0 auto 1rem; }
.site-logo--admin { height: 30px; max-width: 90px; }
.sidebar-nav { flex: 1; padding: 1rem 0; overflow-y: auto; }
.sidebar-link {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.75rem 1.5rem; color: var(--text-muted);
    transition: all 0.2s; font-size: 0.9rem;
}
.sidebar-link:hover, .sidebar-link.active {
    background: rgba(0, 200, 83, 0.08);
    color: var(--green-light);
    border-right: 3px solid var(--green-primary);
}
.sidebar-logout { padding: 1rem 1.5rem; border-top: 1px solid var(--border); }

/* Main */
.admin-main { flex: 1; margin-right: 260px; min-height: 100vh; }
.admin-topbar {
    display: flex; align-items: center; gap: 1rem;
    padding: 1rem 2rem; background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
}
.sidebar-toggle {
    display: none; background: none; border: none;
    color: var(--green-primary); font-size: 1.5rem; cursor: pointer;
}
.topbar-title { font-size: 1.2rem; font-weight: 600; flex: 1; }
.topbar-user { color: var(--text-muted); font-size: 0.85rem; }
.admin-content { padding: 2rem; }

/* Cards */
.admin-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.5rem;
}
.card-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1.5rem;
}
.card-header h2 { font-size: 1.1rem; }

/* Stats */
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem; margin-bottom: 2rem;
}
.stat-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.5rem;
    display: flex; align-items: center; gap: 1rem;
    transition: all 0.3s;
}
.stat-card:hover { border-color: var(--green-primary); transform: translateY(-2px); }
.stat-icon { font-size: 2rem; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--green-light); display: block; }
.stat-label { font-size: 0.85rem; color: var(--text-muted); }

/* Table */
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td {
    padding: 0.75rem 1rem; text-align: right;
    border-bottom: 1px solid var(--border); font-size: 0.9rem;
}
.admin-table th { color: var(--text-muted); font-weight: 600; font-size: 0.8rem; }
.admin-table tr:hover td { background: rgba(0, 200, 83, 0.03); }
.admin-table a { color: var(--green-light); }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 320px; gap: 1.5rem; }
.form-main { display: flex; flex-direction: column; gap: 1.5rem; }
.form-sidebar { display: flex; flex-direction: column; gap: 1rem; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.4rem; font-size: 0.85rem; color: var(--text-secondary); font-weight: 500; }
.form-input, .form-select, textarea.form-input {
    width: 100%; padding: 0.65rem 0.9rem; border-radius: 8px;
    border: 1px solid var(--border); background: var(--bg-secondary);
    color: var(--text-primary); font-family: var(--font); font-size: 0.9rem;
    transition: all 0.2s;
}
.form-input:focus, .form-select:focus, textarea.form-input:focus {
    outline: none; border-color: var(--green-primary);
    box-shadow: 0 0 0 3px var(--green-glow);
}
.form-select option { background: var(--bg-card); }
.form-check { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; }
.form-check input { accent-color: var(--green-primary); }
.form-check label { font-size: 0.9rem; }
.form-actions { display: flex; gap: 0.75rem; margin-top: 1rem; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.6rem 1.25rem; border-radius: 8px;
    font-family: var(--font); font-size: 0.85rem; font-weight: 600;
    border: 1px solid transparent; cursor: pointer;
    transition: all 0.2s; text-decoration: none;
}
.btn-primary { background: var(--green-primary); color: var(--white); }
.btn-primary:hover { background: var(--green-dark); color: var(--white); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text-secondary); }
.btn-outline:hover { border-color: var(--green-primary); color: var(--green-light); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #c62828; }
.btn-sm { padding: 0.5rem 1rem; }
.btn-xs { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn-block { width: 100%; }

/* Badges */
.badge {
    display: inline-block; padding: 0.2rem 0.6rem;
    border-radius: 20px; font-size: 0.75rem; font-weight: 600;
}
.badge-success { background: rgba(0, 200, 83, 0.15); color: var(--green-light); }
.badge-warning { background: rgba(255, 167, 38, 0.15); color: var(--warning); }
.badge-info { background: rgba(66, 165, 245, 0.15); color: var(--info); }

/* Toolbar */
.admin-toolbar {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem;
}
.toolbar-form { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Upload */
.upload-zone {
    border: 2px dashed var(--border); border-radius: var(--radius);
    padding: 2rem; text-align: center; cursor: pointer;
    transition: all 0.3s; margin-bottom: 1rem;
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--green-primary);
    background: rgba(0, 200, 83, 0.05);
}
.upload-zone p { color: var(--text-secondary); margin-bottom: 0.5rem; }
.upload-zone small { color: var(--text-muted); font-size: 0.8rem; }
.upload-zone-sm { padding: 1.5rem; }
.upload-preview { margin-top: 1rem; }
.thumb-preview { width: 100%; border-radius: 8px; margin-top: 0.5rem; }

/* Progress Bar */
.progress-bar-wrap {
    display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem;
}
.progress-bar {
    flex: 1; height: 8px; background: var(--bg-secondary);
    border-radius: 4px; overflow: hidden;
}
.progress-fill {
    height: 100%; width: 0%; background: linear-gradient(90deg, var(--green-dark), var(--green-primary));
    border-radius: 4px; transition: width 0.3s ease;
    position: relative;
}
.progress-fill::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 1.5s infinite;
}
@keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
.progress-text { font-size: 0.85rem; color: var(--green-light); min-width: 40px; font-weight: 600; }

/* Messages */
.message-item {
    padding: 1.25rem; border-bottom: 1px solid var(--border);
    transition: background 0.2s;
}
.message-item.unread { background: rgba(0, 200, 83, 0.04); border-right: 3px solid var(--green-primary); }
.admin-table tr.row-unread { background: rgba(0, 200, 83, 0.05); }
.ticket-admin-thread .message-item { margin-bottom: 0.75rem; }
.message-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.5rem; }
.message-contact { display: flex; gap: 1.5rem; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.75rem; }
.message-body { color: var(--text-secondary); line-height: 1.8; }
.message-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; }

/* Login */
.login-body {
    font-family: var(--font);
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; background: var(--bg-primary);
    background-image: radial-gradient(ellipse at center, rgba(0,200,83,0.08) 0%, transparent 70%);
}
.login-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 16px; padding: 2.5rem; width: 100%; max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.login-header { text-align: center; margin-bottom: 2rem; }
.login-icon { font-size: 3rem; }
.login-header h1 { font-size: 1.3rem; margin: 0.5rem 0; }
.login-header p { color: var(--text-muted); font-size: 0.9rem; }
.back-link { display: block; text-align: center; margin-top: 1.5rem; color: var(--text-muted); font-size: 0.85rem; }

/* Alerts */
.alert { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.9rem; }
.alert-success { background: rgba(0,200,83,0.12); color: var(--green-light); border: 1px solid var(--green-primary); }
.alert-danger { background: rgba(239,83,80,0.12); color: var(--danger); border: 1px solid var(--danger); }
.text-danger { color: var(--danger); font-size: 0.8rem; }
.empty-text { color: var(--text-muted); text-align: center; padding: 2rem; }

/* Pagination */
.pagination { display: flex; gap: 0.4rem; margin-top: 1rem; justify-content: center; }
.page-link {
    width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
    border-radius: 6px; background: var(--bg-secondary); border: 1px solid var(--border);
    color: var(--text-secondary); font-size: 0.85rem; transition: all 0.2s;
}
.page-link:hover, .page-link.active { background: var(--green-primary); color: var(--white); border-color: var(--green-primary); }

/* Animations */
.animate-fade-up { animation: fadeUp 0.5s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.4s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.hero-upload-preview {
    margin-top: 0.75rem;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    max-width: 320px;
}
.hero-upload-preview img {
    display: block;
    width: 100%;
    height: auto;
}
.upload-progress {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.35rem;
}
.upload-progress-bar {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
}
.upload-progress-fill {
    height: 100%;
    width: 0;
    background: var(--green-primary);
    transition: width 0.2s;
}

/* Responsive */
@media (max-width: 1024px) {
    .form-grid { grid-template-columns: 1fr; }
    .admin-topbar { padding: 0.85rem 1.25rem; }
    .topbar-title { font-size: 1.05rem; }
}

@media (max-width: 768px) {
    body.admin-body { font-size: 0.88rem; }

    .admin-sidebar { transform: translateX(100%); width: 240px; }
    .admin-sidebar.open { transform: translateX(0); }
    .admin-main { margin-right: 0; }
    .sidebar-toggle { display: block; }
    .sidebar-brand { padding: 1rem 1.15rem; font-size: 0.95rem; }
    .sidebar-link { padding: 0.6rem 1.15rem; font-size: 0.82rem; gap: 0.55rem; }
    .sidebar-logout { padding: 0.75rem 1.15rem; }
    .sidebar-logout .btn { font-size: 0.8rem; padding: 0.45rem 0.85rem; }

    .admin-topbar { padding: 0.65rem 0.85rem; gap: 0.65rem; }
    .topbar-title { font-size: 0.92rem; }
    .topbar-user { font-size: 0.72rem; max-width: 38vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    .admin-content { padding: 0.75rem; }
    .admin-card { padding: 0.85rem; margin-bottom: 0.85rem; border-radius: 8px; }
    .card-header { margin-bottom: 0.85rem; }
    .card-header h2 { font-size: 0.92rem; }

    .stats-grid { grid-template-columns: 1fr 1fr; gap: 0.55rem; margin-bottom: 1rem; }
    .stat-card { padding: 0.75rem; gap: 0.55rem; }
    .stat-icon { font-size: 1.35rem; }
    .stat-value { font-size: 1.25rem; }
    .stat-label { font-size: 0.72rem; }

    .admin-toolbar { margin-bottom: 0.85rem; gap: 0.55rem; }
    .admin-toolbar h2 { font-size: 0.9rem !important; }
    .toolbar-form { width: 100%; }
    .toolbar-form .form-input,
    .toolbar-form .form-select { font-size: 0.8rem; padding: 0.5rem 0.7rem; }
    .toolbar-actions { width: 100%; display: flex; flex-wrap: wrap; gap: 0.4rem; }

    .btn { font-size: 0.78rem; padding: 0.48rem 0.85rem; }
    .btn-sm { padding: 0.4rem 0.7rem; font-size: 0.74rem; }
    .btn-xs { padding: 0.28rem 0.55rem; font-size: 0.7rem; }

    .form-input, .form-select, textarea.form-input { font-size: 0.82rem; padding: 0.55rem 0.75rem; }
    .form-group label { font-size: 0.76rem; margin-bottom: 0.3rem; }
    .form-group { margin-bottom: 0.75rem; }

    .badge { font-size: 0.68rem; padding: 0.15rem 0.45rem; }
    .alert { font-size: 0.8rem; padding: 0.6rem 0.75rem; }
    .pagination { gap: 0.3rem; }
    .page-link { width: 30px; height: 30px; font-size: 0.75rem; }

    /* Mobile card tables */
    .admin-table--cards thead { display: none; }
    .admin-table--cards,
    .admin-table--cards tbody,
    .admin-table--cards tr,
    .admin-table--cards td { display: block; width: 100%; }

    .admin-table--cards tr {
        background: var(--bg-secondary);
        border: 1px solid var(--border);
        border-radius: 8px;
        margin-bottom: 0.65rem;
        padding: 0.25rem 0;
    }

    .admin-table--cards tr:hover td { background: transparent; }

    .admin-table--cards td {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 0.65rem;
        padding: 0.45rem 0.7rem;
        border-bottom: 1px solid rgba(0, 200, 83, 0.06);
        font-size: 0.78rem;
        text-align: left;
    }

    .admin-table--cards td:last-child { border-bottom: none; }

    .admin-table--cards td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        font-size: 0.72rem;
        flex-shrink: 0;
        min-width: 5.5rem;
        text-align: right;
    }

    .admin-table--cards td.actions,
    .admin-table--cards td[colspan] {
        display: block;
        text-align: center;
    }

    .admin-table--cards td.actions::before,
    .admin-table--cards td[colspan]::before { display: none; }

    .admin-table--cards .toolbar-form {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    .admin-table--cards .toolbar-form .form-select,
    .admin-table--cards .toolbar-form .form-input { min-width: 0 !important; width: 100%; }

    .message-item { padding: 0.85rem; }
    .message-header { flex-wrap: wrap; gap: 0.4rem; font-size: 0.82rem; }
    .message-contact { flex-direction: column; gap: 0.25rem; font-size: 0.76rem; }
    .message-body { font-size: 0.82rem; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
}

/* Sidebar backdrop */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 90;
}
.sidebar-backdrop.open { display: block; }
body.sidebar-open { overflow: hidden; }

/* Lottery lookup */
.lookup-hero { text-align: center; max-width: 480px; margin: 0 auto 1rem; }
.lookup-hero-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.lookup-hero h2 { font-size: 1.15rem; margin-bottom: 0.35rem; }
.lookup-hero p { font-size: 0.85rem; margin-bottom: 1.25rem; }
.lookup-form { display: flex; flex-direction: column; gap: 0.75rem; }
.lookup-input-wrap { text-align: right; }
.lookup-input {
    font-size: 1.35rem !important;
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.05em;
    padding: 0.85rem !important;
}
.lookup-submit { padding: 0.75rem !important; font-size: 0.95rem !important; }

/* Lookup result modal */
.lookup-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.lookup-modal.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}
body.lookup-modal-open { overflow: hidden; }

.lookup-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 8, 4, 0.88);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.lookup-modal-dialog {
    position: relative;
    z-index: 1;
    width: min(94vw, 560px);
    max-height: calc(100dvh - 1.5rem);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: linear-gradient(165deg, #0f1f16 0%, #0a1510 100%);
    border: 1px solid rgba(0, 200, 83, 0.25);
    border-radius: 16px;
    padding: 0.85rem 1.25rem 1rem;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
    animation: lookupModalIn 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes lookupModalIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

.lookup-modal-close {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.35);
    color: var(--text-primary);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
}
.lookup-modal-close:hover { background: rgba(239, 83, 80, 0.2); border-color: var(--danger); }

.lookup-modal-logo-wrap {
    text-align: center;
    margin: 0 0 0.5rem;
    padding: 0;
    line-height: 0;
}
.lookup-modal-logo {
    display: inline-block;
    height: clamp(52px, 11vh, 76px);
    width: auto;
    max-width: 200px;
    object-fit: contain;
}

.lookup-modal-body {
    text-align: center;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.lookup-result-badge {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    background: rgba(0, 200, 83, 0.15);
    color: var(--green-light);
    font-size: 0.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.lookup-result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    text-align: right;
}
.lookup-result-grid--modal {
    margin-bottom: 0.65rem;
    flex: 1;
}

.lookup-result-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.55rem 0.7rem;
}
.lookup-result-item--highlight {
    grid-column: 1 / -1;
    text-align: center;
    padding: 0.5rem 0.7rem;
    background: rgba(0, 200, 83, 0.08);
    border-color: rgba(0, 200, 83, 0.25);
}
.lookup-result-item--full { grid-column: 1 / -1; }

.lookup-label {
    display: block;
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-bottom: 0.15rem;
}
.lookup-value { font-size: 0.92rem; color: var(--text-primary); font-weight: 700; }
.lookup-value--lg { font-size: 1rem; }
.lookup-code { font-size: 1.65rem !important; color: var(--green-light); line-height: 1.15; }
.lookup-phone { font-size: 1.05rem !important; letter-spacing: 0.03em; }

.lookup-modal-done {
    padding: 0.55rem !important;
    font-size: 0.85rem !important;
    flex-shrink: 0;
}

@media (min-width: 769px) {
    .lookup-modal-dialog {
        width: min(90vw, 520px);
        padding: 1rem 1.5rem 1.1rem;
    }
    .lookup-modal-logo { height: clamp(64px, 10vh, 88px); }
    .lookup-code { font-size: 1.85rem !important; }
    .lookup-value--lg { font-size: 1.08rem; }
    .lookup-phone { font-size: 1.12rem !important; }
}

@media (max-width: 768px) {
    .lookup-hero h2 { font-size: 0.95rem; }
    .lookup-hero p { font-size: 0.76rem; }
    .lookup-input { font-size: 1.1rem !important; padding: 0.7rem !important; }
    .lookup-modal {
        padding: 0;
        align-items: flex-end;
    }
    .lookup-modal-dialog {
        width: 100%;
        max-height: 100dvh;
        border-radius: 16px 16px 0 0;
        padding: 0.75rem 1rem 0.85rem;
    }
    .lookup-modal-logo { height: clamp(48px, 10vh, 64px); }
    .lookup-result-grid { grid-template-columns: 1fr 1fr; gap: 0.4rem; }
    .lookup-result-item { padding: 0.45rem 0.55rem; }
    .lookup-code { font-size: 1.45rem !important; }
    .lookup-phone { font-size: 0.95rem !important; }
}

.text-muted { color: var(--text-muted); font-size: 0.85rem; }
