/**
 * Admin Panel – Dark & Light theme overrides
 * Load after styles.min.css. Cohesive palette and component styling.
 */

/* ========== MOBILE / RESPONSIVE BASE ========== */
html {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}
#main-wrapper.page-wrapper,
.page-wrapper {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}
.body-wrapper {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

/* When sidebar is visible, constrain body so content doesn't overflow the view */
@media (min-width: 1200px) {
    #main-wrapper[data-layout="vertical"][data-sidebartype="full"] .body-wrapper {
        width: calc(100% - 270px);
        max-width: calc(100vw - 270px);
    }
}

@media (max-width: 1199px) {
    .app-header,
    .body-wrapper {
        width: 100% !important;
        max-width: 100%;
    }
}

/* ========== DARK THEME ========== */
[data-bs-theme="dark"] {
    /* Base surfaces – slate palette */
    --bs-body-bg: #0f172a;
    --bs-body-bg-rgb: 15, 23, 42;
    --bs-body-color: #cbd5e1;
    --bs-body-color-rgb: 203, 213, 225;
    --bs-emphasis-color: #f1f5f9;
    --bs-emphasis-color-rgb: 241, 245, 249;

    /* Secondary / muted */
    --bs-secondary-color: rgba(203, 213, 225, 0.8);
    --bs-secondary-color-rgb: 203, 213, 225;
    --bs-secondary-bg: #1e293b;
    --bs-secondary-bg-rgb: 30, 41, 59;
    --bs-tertiary-color: rgba(203, 213, 225, 0.6);
    --bs-tertiary-bg: #1e293b;
    --bs-tertiary-bg-rgb: 30, 41, 59;

    /* Typography */
    --bs-heading-color: #f1f5f9;
    --bs-link-color: #93c5fd;
    --bs-link-hover-color: #bfdbfe;
    --bs-link-color-rgb: 147, 197, 253;
    --bs-link-hover-color-rgb: 191, 219, 254;

    /* Borders – subtle */
    --bs-border-color: #334155;
    --bs-border-color-translucent: rgba(255, 255, 255, 0.08);

    /* Subtle backgrounds for alerts/cards */
    --bs-light-text: #f1f5f9;
    --bs-dark-text: #e2e8f0;
    --bs-light-bg-subtle: #1e293b;
    --bs-dark-bg-subtle: #0f172a;
    --bs-light-border-subtle: #334155;
    --bs-dark-border-subtle: #334155;
    --bs-primary-bg-subtle: #1e3a5f;
    --bs-primary-border-subtle: #2563eb;
    --bs-secondary-bg-subtle: #1e293b;
    --bs-secondary-border-subtle: #475569;
    --bs-success-bg-subtle: #052e2a;
    --bs-success-border-subtle: #0d9488;
    --bs-info-bg-subtle: #0c1929;
    --bs-info-border-subtle: #2563eb;
    --bs-warning-bg-subtle: #422006;
    --bs-warning-border-subtle: #d97706;
    --bs-danger-bg-subtle: #450a0a;
    --bs-danger-border-subtle: #dc2626;

    /* Form controls */
    --bs-form-control-bg: #1e293b;
    --bs-form-control-disabled-bg: #334155;
}

/* Dark: Sidebar */
[data-bs-theme="dark"] .left-sidebar {
    background-color: #1e293b;
    border-right-color: #334155;
}

[data-bs-theme="dark"] .left-sidebar .scroll-sidebar {
    background: transparent;
}

[data-bs-theme="dark"] .nav-small-cap {
    color: #94a3b8;
}

[data-bs-theme="dark"] .sidebar-nav ul .sidebar-item .sidebar-link {
    color: #e2e8f0;
}

[data-bs-theme="dark"] .sidebar-nav ul .sidebar-item .sidebar-link:hover {
    background-color: #334155;
    color: #f1f5f9;
}

[data-bs-theme="dark"] .sidebar-nav ul .sidebar-item.selected > .sidebar-link,
[data-bs-theme="dark"] .sidebar-nav ul .sidebar-item.selected > .sidebar-link.active,
[data-bs-theme="dark"] .sidebar-nav ul .sidebar-item > .sidebar-link.active {
    background-color: rgba(93, 135, 255, 0.2);
    color: #93c5fd;
}

[data-bs-theme="dark"] .sidebar-nav ul .sidebar-item .sidebar-link:hover.has-arrow:after,
[data-bs-theme="dark"] .sidebar-nav ul .sidebar-item .sidebar-link.active.has-arrow:after {
    border-color: #93c5fd;
}

/* Dark: Header */
[data-bs-theme="dark"] .app-header {
    background: #1e293b;
    border-bottom-color: #334155;
}

[data-bs-theme="dark"] .app-header .navbar {
    --bs-navbar-color: #e2e8f0;
    --bs-navbar-hover-color: #93c5fd;
    --bs-navbar-active-color: #f1f5f9;
}

[data-bs-theme="dark"] .app-header .navbar .navbar-nav .nav-item .nav-link {
    color: #e2e8f0;
}

[data-bs-theme="dark"] .app-header .navbar .navbar-nav .nav-item .nav-link:hover {
    color: #93c5fd;
}

[data-bs-theme="dark"] .app-header .navbar .navbar-nav.quick-links .nav-item:hover .nav-link:before {
    background: #334155;
}

[data-bs-theme="dark"] .nav-icon-hover:hover {
    color: #93c5fd;
}

/* Dark: Cards */
[data-bs-theme="dark"] .card {
    --bs-card-bg: #1e293b;
    --bs-card-border-color: #334155;
    --bs-card-title-color: #f1f5f9;
    --bs-card-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

[data-bs-theme="dark"] .card-title,
[data-bs-theme="dark"] .card .fw-bold.text-dark,
[data-bs-theme="dark"] .card .text-dark {
    color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .card .text-muted {
    color: #94a3b8 !important;
}

/* Dark: Form controls */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: var(--bs-form-control-bg);
    border-color: #334155;
    color: #e2e8f0;
}

[data-bs-theme="dark"] .form-control::placeholder {
    color: #64748b;
}

[data-bs-theme="dark"] .form-control:focus {
    background-color: var(--bs-form-control-bg);
    border-color: #5D87FF;
    color: #f1f5f9;
    box-shadow: 0 0 0 0.2rem rgba(93, 135, 255, 0.25);
}

[data-bs-theme="dark"] .form-select:focus {
    border-color: #5D87FF;
    color: #f1f5f9;
}

/* Dark: Stat / utility cards (bg-light-*) */
[data-bs-theme="dark"] .bg-light-primary {
    background-color: rgba(93, 135, 255, 0.15) !important;
}

[data-bs-theme="dark"] .bg-light-success {
    background-color: rgba(19, 222, 185, 0.15) !important;
}

[data-bs-theme="dark"] .bg-light-info {
    background-color: rgba(83, 155, 255, 0.15) !important;
}

[data-bs-theme="dark"] .bg-light-warning {
    background-color: rgba(255, 174, 31, 0.15) !important;
}

[data-bs-theme="dark"] .bg-light-danger {
    background-color: rgba(250, 137, 107, 0.15) !important;
}

[data-bs-theme="dark"] .bg-light {
    background-color: #1e293b !important;
}

[data-bs-theme="dark"] .border-light {
    border-color: #334155 !important;
}

/* Dark: Tables */
[data-bs-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-color: #e2e8f0;
    --bs-table-border-color: #334155;
    --bs-table-striped-bg: rgba(30, 41, 59, 0.5);
    --bs-table-hover-bg: rgba(51, 65, 85, 0.4);
}

[data-bs-theme="dark"] .table thead th {
    color: #94a3b8;
    border-bottom-color: #334155;
}

/* Dark: Dropdowns */
[data-bs-theme="dark"] .dropdown-menu {
    background-color: #1e293b;
    border-color: #334155;
}

[data-bs-theme="dark"] .dropdown-item {
    color: #e2e8f0;
}

[data-bs-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:focus {
    background-color: #334155;
    color: #f1f5f9;
}

[data-bs-theme="dark"] .dropdown-divider {
    border-top-color: #334155;
}

/* Dark: General text utilities used in content */
[data-bs-theme="dark"] .text-dark {
    color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .text-muted {
    color: #94a3b8 !important;
}

[data-bs-theme="dark"] .text-secondary {
    color: #94a3b8 !important;
}

/* Dark: Buttons that use dark text (btn-light, outline) – ensure readable text */
[data-bs-theme="dark"] .btn-light,
[data-bs-theme="dark"] .btn-outline-light,
[data-bs-theme="dark"] .btn-outline-light-primary,
[data-bs-theme="dark"] .btn-outline-light-secondary,
[data-bs-theme="dark"] .btn-outline-light-info,
[data-bs-theme="dark"] .btn-outline-light-success,
[data-bs-theme="dark"] .btn-outline-light-warning,
[data-bs-theme="dark"] .btn-outline-light-danger,
[data-bs-theme="dark"] .btn-outline-light-indigo,
[data-bs-theme="dark"] .btn-outline-light-gray {
    color: var(--bs-body-color) !important;
    border-color: var(--bs-border-color);
    background-color: var(--bs-secondary-bg);
}

[data-bs-theme="dark"] .btn-light:hover,
[data-bs-theme="dark"] .btn-outline-light:hover,
[data-bs-theme="dark"] .btn-outline-light-primary:hover,
[data-bs-theme="dark"] .btn-outline-light-secondary:hover,
[data-bs-theme="dark"] .btn-outline-light-info:hover,
[data-bs-theme="dark"] .btn-outline-light-success:hover,
[data-bs-theme="dark"] .btn-outline-light-warning:hover,
[data-bs-theme="dark"] .btn-outline-light-danger:hover,
[data-bs-theme="dark"] .btn-outline-light-indigo:hover,
[data-bs-theme="dark"] .btn-outline-light-gray:hover {
    color: var(--bs-emphasis-color) !important;
    background-color: var(--bs-tertiary-bg);
    border-color: var(--bs-border-color);
}

/* Dark: Badges with light bg / dark text */
[data-bs-theme="dark"] .badge.bg-light,
[data-bs-theme="dark"] .badge.bg-white {
    background-color: var(--bs-secondary-bg) !important;
    color: var(--bs-body-color) !important;
    border-color: var(--bs-border-color) !important;
}

[data-bs-theme="dark"] .badge.bg-light.text-dark,
[data-bs-theme="dark"] .badge.bg-white.text-dark {
    color: var(--bs-emphasis-color) !important;
}

/* Dark: Labels and small text that might inherit wrong */
[data-bs-theme="dark"] label,
[data-bs-theme="dark"] .form-label,
[data-bs-theme="dark"] .col-form-label {
    color: var(--bs-heading-color) !important;
}

[data-bs-theme="dark"] .small,
[data-bs-theme="dark"] .form-text {
    color: var(--bs-secondary-color) !important;
}

[data-bs-theme="dark"] hr,
[data-bs-theme="dark"] .border-light {
    border-color: #334155 !important;
    opacity: 0.8;
}

/* Dark: Page wrapper / body area */
[data-bs-theme="dark"] .body-wrapper {
    background-color: var(--bs-body-bg);
}

/* Dark: Theme toggle button in header */
[data-bs-theme="dark"] #theme-toggle {
    color: #e2e8f0;
}

[data-bs-theme="dark"] #theme-toggle:hover {
    color: #fbbf24;
}

/* ========== LIGHT THEME POLISH ========== */
[data-bs-theme="light"] {
    --bs-body-bg: #ffffff;
    --bs-border-color: #e2e8f0;
}

[data-bs-theme="light"] .left-sidebar {
    border-right-color: #e2e8f0;
}

[data-bs-theme="light"] .app-header {
    border-bottom-color: #e2e8f0;
}

[data-bs-theme="light"] #theme-toggle:hover {
    color: #5D87FF;
}

/* Dark: Game-add upload zones and pills */
[data-bs-theme="dark"] .upload-zone {
    background: #1e293b !important;
    border-color: #475569 !important;
}

[data-bs-theme="dark"] .upload-zone:hover,
[data-bs-theme="dark"] .upload-zone.drag-over {
    background: #334155 !important;
    border-color: #5D87FF !important;
}

[data-bs-theme="dark"] .category-pill.bg-white,
[data-bs-theme="dark"] .prize-pill.bg-white,
[data-bs-theme="dark"] .category-pill:not(.active) {
    background-color: var(--bs-secondary-bg) !important;
    border-color: var(--bs-border-color) !important;
    color: var(--bs-body-color) !important;
}

[data-bs-theme="dark"] .category-pill.bg-white:hover,
[data-bs-theme="dark"] .category-pill.bg-white.selected,
[data-bs-theme="dark"] .category-pill:not(.active):hover {
    background-color: var(--bs-primary-bg-subtle) !important;
    border-color: var(--bs-primary) !important;
    color: var(--bs-link-color) !important;
}

[data-bs-theme="dark"] .game-section {
    border-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .game-section-header {
    background: var(--bs-secondary-bg);
    border-bottom-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .prize-slot .slot-remove {
    background: rgba(0,0,0,0.7);
}

[data-bs-theme="dark"] .prize-slot .slot-remove:hover {
    background: var(--bs-danger);
}

/* ========== HEADER ICON HOVER (fix misplaced :before) ========== */
.app-header .nav-icon-hover {
    position: relative;
}

/* ========== RESPONSIVE HEADER (mobile) ========== */
.app-header .header-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    flex-wrap: nowrap;
    gap: 0.5rem;
    padding: 0 0.5rem;
    min-height: 70px;
}

.app-header .header-left {
    display: flex;
    align-items: center;
    min-width: 0;
    flex: 1;
    gap: 0.5rem;
}

.app-header .header-hamburger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    padding: 0;
    color: inherit;
    text-decoration: none;
}

.app-header .header-welcome {
    font-size: 1rem;
    font-weight: 600;
    color: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.app-header .header-right {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

@media (min-width: 768px) {
    .app-header .header-welcome {
        font-size: 1.25rem;
    }
}

/* ========== GLOBAL TOAST NOTIFICATION ========== */
#global-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.global-toast {
    min-width: 250px;
    max-width: 350px;
    padding: 15px 20px;
    border-radius: 8px;
    color: #fff;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateX(120%);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    word-break: break-word;
}
.global-toast.show {
    transform: translateX(0);
    opacity: 1;
}
.global-toast.toast-success {
    background-color: var(--bs-success, #13deb9);
}
.global-toast.toast-error {
    background-color: var(--bs-danger, #fa896b);
}
.global-toast.toast-info {
    background-color: var(--bs-info, #539bff);
}
.toast-close-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    margin-left: 10px;
    padding: 0;
    opacity: 0.8;
}
.toast-close-btn:hover {
    opacity: 1;
}
