/* ==========================================================================
   KobiJak — Admin Panel Styles
   ========================================================================== */

:root {
    --admin-bg: #121212;
    --admin-sidebar: #1c1c1c;
    --admin-card: #2a2a2a;
    --admin-border: #3a3a3a;
    --admin-red: #C62828;
    --admin-red-hover: #B71C1C;
    --admin-green: #39B54A;
    --admin-gold: #D4A017;
    --admin-white: #ffffff;
    --admin-grey: #adb5bd;
}

body {
    font-family: 'Montserrat', sans-serif;
    background-color: var(--admin-bg) !important;
}

/* ---------- Sidebar ---------- */
.admin-sidebar {
    width: 250px;
    height: 100vh;
    background-color: var(--admin-sidebar);
    position: sticky;
    top: 0;
    flex-shrink: 0;
    overflow-y: auto;
}

.admin-sidebar .nav-link {
    color: var(--admin-grey);
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.25rem;
}

.admin-sidebar .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--admin-white);
}

.admin-sidebar .nav-link.active {
    background-color: var(--admin-red);
    color: var(--admin-white);
}

.admin-sidebar .sidebar-subnav {
    margin-left: 1.25rem;
    padding-left: 0.75rem;
    border-left: 1px solid var(--admin-border);
}

.admin-sidebar .sidebar-subitem {
    color: #aaa;
    font-size: 0.85rem;
    padding: 0.2rem 0 0.2rem 0.5rem;
    border-radius: 0;
    position: relative;
}

.admin-sidebar .sidebar-subitem::before {
    content: '';
    position: absolute;
    left: -0.75rem;
    top: 50%;
    width: 0.5rem;
    height: 1px;
    background-color: var(--admin-border);
}

.admin-sidebar .sidebar-subitem:hover {
    color: var(--admin-white);
    background: none;
}

.admin-sidebar .sidebar-subitem.active {
    color: var(--admin-white);
    font-weight: 600;
    background: none;
}

.admin-sidebar .sidebar-subitem.active::before {
    background-color: var(--admin-red);
}

/* ---------- Main Content ---------- */
.admin-content {
    min-height: 100vh;
    overflow-x: auto;
}

/* ---------- Cards ---------- */
.stat-card {
    background-color: var(--admin-card);
    border: none;
    border-radius: 0.75rem;
}

.stat-card .stat-icon {
    font-size: 2rem;
    opacity: 0.7;
}

.dash-stat-card {
    transition: border-color 0.15s, transform 0.1s;
    border: 1px solid transparent;
}

.dash-stat-card:hover {
    border-color: var(--admin-border);
    transform: translateY(-2px);
}

.dash-stat-compact {
    padding: 1rem;
}

.dash-stat-compact .dash-stat-number {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
}

@media (min-width: 768px) {
    .dash-stat-compact {
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-wrap: wrap;
    }

    .dash-stat-compact .dash-stat-number {
        font-size: 2rem;
    }
}

@media (max-width: 767.98px) {
    .dash-stat-compact {
        padding: 0.5rem 0.6rem;
        text-align: center;
    }

    .dash-stat-compact .text-secondary {
        font-size: 0.65rem !important;
    }

    .dash-stat-compact .dash-stat-number {
        font-size: 1.5rem;
    }

    .dash-stat-compact .dash-stat-icon {
        font-size: 1rem;
        opacity: 0.6;
        margin-top: 0.15rem;
    }
}

/* ---------- Chart Range Toggles ---------- */
.chart-range-toggles {
    display: flex;
    gap: 4px;
    margin-bottom: 0.75rem;
}

.chart-range-btn {
    background: none;
    border: 1px solid var(--admin-border);
    color: var(--admin-grey);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}

.chart-range-btn:hover {
    border-color: var(--admin-red);
    color: var(--admin-white);
}

.chart-range-btn.active {
    background-color: var(--admin-red);
    border-color: var(--admin-red);
    color: var(--admin-white);
}

/* ---------- Tables ---------- */
.table-dark th {
    border-color: var(--admin-border);
}

/* ---------- Word List Textarea ---------- */
.word-list-input {
    min-height: 150px;
    font-family: 'Montserrat', monospace;
}

/* ---------- Mode Toggle Cards ---------- */
.mode-toggle {
    background-color: var(--admin-card);
    border: 2px solid transparent;
    border-radius: 0.75rem;
    padding: 1rem;
    cursor: pointer;
    transition: border-color 0.2s;
}

.mode-toggle.active {
    border-color: var(--admin-red);
}

.mode-toggle:hover {
    border-color: var(--admin-gold);
}

/* ---------- Copy-to-Clipboard Badge ---------- */
.copy-code {
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
    user-select: all;
    font-size: 0.85em;
}

.copy-code:hover {
    transform: scale(1.1);
    box-shadow: 0 0 8px rgba(198, 40, 40, 0.4);
}

/* ---------- Word Cards / Chips ---------- */
.word-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    min-height: 44px;
}

.word-card {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--admin-card);
    border: 1.5px solid var(--admin-border);
    border-radius: 10px;
    padding: 10px 16px;
    font-size: 1.05rem;
    font-weight: 500;
    color: #eee;
    transition: border-color 0.15s;
}

.word-card.bonus {
    border-color: var(--admin-gold);
}

.word-card .word-star {
    cursor: pointer;
    color: var(--admin-border);
    font-size: 1rem;
    transition: color 0.15s;
}

.word-card .word-star:hover {
    color: var(--admin-gold);
}

.word-card.bonus .word-star {
    color: var(--admin-gold);
}

.word-card .word-remove {
    cursor: pointer;
    color: #666;
    font-size: 0.9rem;
    margin-left: 0.1rem;
    transition: color 0.15s;
}

.word-card .word-remove:hover {
    color: var(--admin-red);
}

.word-input-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.word-input-row input {
    flex: 1;
    font-size: 1.05rem;
    padding: 10px 14px;
}

/* ---------- Word History ---------- */
.word-history-card .word-list {
    color: #ccc;
    font-size: 0.85rem;
    line-height: 1.6;
}

.word-history-card .word-list .bonus-word {
    color: var(--admin-gold);
}

.word-history-card .bonus-star {
    color: var(--admin-gold);
    font-size: 0.7rem;
    margin-right: 2px;
}

/* ---------- Class Detail Sections ---------- */
.class-section {
    background-color: var(--admin-sidebar);
    border-radius: 0.75rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.class-section-title {
    color: var(--admin-grey);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 1rem;
}

/* ---------- Share Card ---------- */
.share-card {
    background-color: var(--admin-sidebar);
    border: 1px solid var(--admin-border);
    border-radius: 1rem;
    padding: 2rem 1.5rem;
    text-align: center;
    margin-bottom: 1.5rem;
}

.share-card .share-class-name {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--admin-white);
    margin-bottom: 1rem;
}

.share-card #qrcode {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.share-card #qrcode canvas,
.share-card #qrcode img {
    border-radius: 10px;
}

.share-card .share-code {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--admin-red);
    letter-spacing: 0.15em;
    margin-bottom: 0.75rem;
}

.share-card .share-url {
    max-width: 400px;
    margin: 0 auto 1rem;
}

.share-card .share-actions {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
}

/* ---------- Class List Cards ---------- */
.class-list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.class-list-card {
    background-color: var(--admin-sidebar);
    border: 1px solid var(--admin-border);
    border-radius: 0.75rem;
    padding: 1.25rem;
    transition: border-color 0.15s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.class-list-card:hover {
    border-color: var(--admin-red);
}

.class-list-card .class-card-info {
    min-width: 0;
}

.class-list-card .class-card-name {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--admin-white);
    margin-bottom: 0.25rem;
}

.class-list-card .class-card-meta {
    font-size: 0.8rem;
    color: var(--admin-grey);
}

.class-list-card .class-card-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* ---------- Week Card ---------- */
.week-card {
    background-color: var(--admin-card);
    border: 1px solid var(--admin-border);
    border-radius: 0.75rem;
    margin-bottom: 1rem;
    overflow: hidden;
}

.week-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--admin-border);
    background-color: rgba(255, 255, 255, 0.02);
}

.week-card-header .week-label {
    font-weight: 600;
    color: #e0e0e0;
    font-size: 0.9rem;
}

.week-card-header .week-meta {
    color: var(--admin-grey);
    font-size: 0.8rem;
    margin-left: 0.5rem;
}

.week-card-body {
    padding: 1rem;
}

@media print {
    body * { visibility: hidden !important; }
    .print-qr, .print-qr * { visibility: visible !important; }
    .print-qr {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        text-align: center;
        padding: 2rem;
    }
    .print-qr h3, .print-qr p, .print-qr .share-class-name, .print-qr .share-code { color: #000 !important; }
}

/* ---------- Button Overrides ---------- */
.btn-danger {
    background-color: var(--admin-red);
    border-color: var(--admin-red);
}

.btn-danger:hover {
    background-color: var(--admin-red-hover);
    border-color: var(--admin-red-hover);
}

.bg-danger {
    background-color: var(--admin-red) !important;
}

/* ---------- Gallery Admin Grid ---------- */
.gallery-admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.gallery-admin-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 1;
    background-color: var(--admin-card);
}

.gallery-admin-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gallery-admin-delete {
    position: absolute;
    top: 6px;
    right: 6px;
    opacity: 0;
    transition: opacity 0.15s;
}

.gallery-admin-item:hover .gallery-admin-delete {
    opacity: 1;
}

.gallery-admin-handle {
    position: absolute;
    bottom: 6px;
    left: 6px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1rem;
    cursor: grab;
    opacity: 0;
    transition: opacity 0.15s;
}

.gallery-admin-item:hover .gallery-admin-handle {
    opacity: 1;
}

/* ---------- Mobile Top Bar ---------- */
.mobile-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    background-color: var(--admin-sidebar);
    border-bottom: 1px solid var(--admin-border);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    z-index: 1040;
}

.mobile-hamburger {
    background: none;
    border: none;
    color: var(--admin-white);
    font-size: 1.25rem;
    padding: 0.25rem;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-topbar-brand {
    color: var(--admin-red);
    font-weight: 700;
    font-size: 1rem;
    text-decoration: none;
    margin-left: 0.5rem;
}

.mobile-topbar-brand:hover {
    color: var(--admin-red);
}

/* ---------- Drawer Overlay ---------- */
.drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1049;
}

.drawer-overlay.open {
    display: block;
}

/* ---------- FAB (Floating Action Button) ---------- */
.fab-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 2000;
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-end;
    gap: 0.75rem;
}

.fab-trigger {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    background-color: #C62828;
    color: var(--admin-white);
    font-size: 1.75rem;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(198, 40, 40, 0.5);
    transition: transform 0.2s, background-color 0.15s, box-shadow 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fabPulseGlow 1.2s ease-in-out 3;
}

.fab-trigger:active {
    transform: scale(0.93);
}

.fab-trigger.open {
    transform: rotate(45deg);
    background-color: #555;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    animation: none;
}

@keyframes fabPulseGlow {
    0%, 100% { box-shadow: 0 4px 16px rgba(198, 40, 40, 0.5); }
    50% { box-shadow: 0 4px 24px rgba(198, 40, 40, 0.8), 0 0 0 8px rgba(198, 40, 40, 0.15); }
}

.fab-actions {
    display: none;
    flex-direction: column-reverse;
    gap: 0.6rem;
    align-items: flex-end;
}

.fab-actions.open {
    display: flex;
}

.fab-action {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    white-space: nowrap;
    animation: fabSlideUp 0.2s ease-out;
}

.fab-action-label {
    background-color: var(--admin-card);
    color: var(--admin-white);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.5rem 0.85rem;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
}

.fab-action-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: var(--admin-card);
    border: 1.5px solid var(--admin-border);
    color: var(--admin-white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
}

@keyframes fabSlideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---------- Responsive ---------- */
@media (min-width: 768px) {
    .mobile-topbar { display: none !important; }
    .drawer-overlay { display: none !important; }
    .fab-container { display: none !important; }
}

@media (max-width: 767.98px) {
    /* Drawer */
    .admin-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        height: 100vh;
        z-index: 1050;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
    }

    .admin-sidebar.drawer-open {
        transform: translateX(0);
    }

    /* Content area */
    .admin-content {
        margin-left: 0 !important;
        padding: 56px 0.75rem 1rem !important;
    }

    .admin-content h2 {
        font-size: 1.3rem;
        margin-bottom: 0.75rem;
    }

    /* Stat cards */
    .stat-card {
        padding: 0.75rem 1rem;
    }

    .stat-card .fs-2 {
        font-size: 1.5rem !important;
    }

    .stat-card .stat-icon {
        font-size: 1.5rem;
    }

    .row.g-3, .row.g-4 {
        --bs-gutter-y: 0.5rem;
        --bs-gutter-x: 0.5rem;
    }

    /* Class sections */
    .class-section {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .class-section-title {
        margin-bottom: 0.6rem;
    }

    /* Tables */
    .table {
        font-size: 0.85rem;
    }

    .table th, .table td {
        padding: 0.35rem 0.5rem;
    }

    /* Quick actions */
    .quick-actions-desktop {
        display: none !important;
    }

    .quick-actions-desktop .btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
    }

    /* Chart */
    .chart-range-toggles {
        gap: 2px;
    }

    .chart-range-btn {
        padding: 3px 8px;
        font-size: 0.7rem;
    }

    /* Word cards */
    .word-cards {
        gap: 6px;
    }

    .word-card {
        padding: 6px 10px;
        font-size: 0.9rem;
    }

    .word-input-row input {
        font-size: 0.95rem;
        padding: 8px 10px;
    }

    /* Share card */
    .share-card {
        padding: 1.25rem 1rem;
    }

    .share-card .share-class-name {
        font-size: 1.15rem;
    }

    .share-card .share-code {
        font-size: 1.4rem;
    }

    /* Week cards */
    .week-card-header {
        padding: 0.5rem 0.75rem;
    }

    .week-card-body {
        padding: 0.75rem;
    }

    /* Class list cards */
    .class-list-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .class-list-card {
        padding: 1rem;
    }

    /* Chart */
    .chart-container {
        height: 250px !important;
    }

    /* General tightening */
    .mb-4 { margin-bottom: 1rem !important; }
    .mb-3 { margin-bottom: 0.75rem !important; }
}
