:root {
    /* Energetic Premium Palette */
    --primary: #4F46E5; /* Vibrant Indigo */
    --primary-hover: #4338CA;
    --primary-light: #EEF2FF; 
    
    --secondary: #8B5CF6; /* Vibrant Purple */
    --success: #10B981; 
    --danger: #F43F5E; /* Vibrant Rose */
    --warning: #F59E0B; 
    --info: #0EA5E9; /* Vibrant Sky */
    
    --bg-body: #F4F6F8; 
    --bg-card: #FFFFFF;
    
    --text-heading: #1E293B; 
    --text-body: #475569; 
    --text-muted: #94A3B8;
    
    --border-color: #E2E8F0; /* Slate 200 */
    --border-radius-sm: 8px;
    --border-radius-md: 16px;
    
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 10px 25px -5px rgba(15, 23, 42, 0.05), 0 8px 10px -6px rgba(15, 23, 42, 0.01);
    
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Public Sans', 'Inter', sans-serif;
}

body {
    background-color: var(--bg-body);
    color: var(--text-body);
    font-size: 0.9375rem;
    line-height: 1.5;
    min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-heading);
    font-weight: 500;
}

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

/* Cards */
.card {
    background-color: var(--bg-card);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    border: 1px solid rgba(0,0,0,0); /* Invisible border for structure */
}

/* Forms & Inputs */
.form-group {
    margin-bottom: 1.25rem;
}
.form-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-heading);
    margin-bottom: 0.4rem;
    font-weight: 600;
}
.form-control {
    display: block;
    width: 100%;
    padding: 0.6rem 1rem;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-heading);
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    transition: all var(--transition);
    outline: none;
    box-shadow: var(--shadow-sm);
}
.form-control::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.05);
}
.form-error {
    color: var(--danger);
    font-size: 0.8125rem;
    margin-top: 0.25rem;
    display: none;
}
.form-error.visible {
    display: block;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    padding: 0.6rem 1.25rem;
    font-size: 0.95rem;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid transparent;
    gap: 0.5rem;
}
.btn-primary {
    color: #fff !important;
    background-color: var(--primary);
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.15);
}
.btn-primary:hover {
    color: #fff !important;
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(15, 23, 42, 0.2);
}
.btn-primary.loading {
    color: transparent !important;
}
.btn-outline-secondary {
    color: var(--text-body);
    border-color: var(--border-color);
    background: transparent;
}
.btn-outline-secondary:hover {
    background: var(--primary-light);
    color: var(--text-heading);
}
.btn-icon {
    padding: 0.25rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}
.btn-icon:hover { color: var(--text-heading); }
.text-primary { color: var(--primary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }

/* Loaders */
.btn.loading {
    color: transparent !important;
    pointer-events: none;
    position: relative;
    user-select: none;
}
.btn.loading::after {
    content: "";
    position: absolute;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Shimmer (Optimized & Subtle) */
.shimmer {
    background: #f6f7f8;
    background-image: linear-gradient(to right, #f6f7f8 0%, #edeef1 20%, #f6f7f8 40%, #f6f7f8 100%);
    background-repeat: no-repeat;
    background-size: 800px 100%; 
    animation: shimmer-animation 1s linear infinite forwards;
    border-radius: var(--border-radius-sm);
    color: transparent !important;
}
.shimmer * { visibility: hidden; }
@keyframes shimmer-animation {
    0% { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
    color: var(--text-heading);
}
.table th, .table td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    font-size: 0.95rem;
}
.table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 1.5px;
    font-weight: 700;
    background: #F8FAFC; /* Slate 50 */
    border-bottom: 2px solid var(--border-color);
}
.table tbody tr {
    transition: background-color var(--transition);
}
.table tbody tr:hover {
    background-color: var(--primary-light);
}

/* Pagination UI */
.pagination {
    display: flex;
    list-style: none;
    gap: 6px;
}
.page-item .page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--border-radius-sm);
    color: var(--text-body);
    background: transparent;
    font-size: 0.95rem;
    font-weight: 600;
    transition: var(--transition);
    cursor: pointer;
    border: 1px solid transparent;
}
.page-item.active .page-link {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.2);
}
.page-item.disabled .page-link {
    opacity: 0.4;
    pointer-events: none;
}
.page-item:not(.active):not(.disabled) .page-link:hover {
    background: var(--primary-light);
    color: var(--primary);
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 3.125rem;
    height: 1.5rem;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--border-color);
    transition: .4s;
    border-radius: 2.125rem;
}
.slider:before {
    position: absolute;
    content: "";
    height: 1.125rem;
    width: 1.125rem;
    left: 0.1875rem;
    bottom: 0.1875rem;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 0.125rem 0.25rem rgba(165,163,174,.3);
}
input:checked + .slider {
    background-color: var(--success);
}
input:checked + .slider:before {
    transform: translateX(1.625rem);
}

/* Custom Checkbox */
.custom-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-heading);
    user-select: none;
}
.custom-checkbox input {
    display: none;
}
.checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    background: var(--bg-card);
}
.checkmark i {
    color: #fff;
    font-size: 12px;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.2s;
}
.custom-checkbox input:checked ~ .checkmark {
    background: var(--primary);
    border-color: var(--primary);
}
.custom-checkbox input:checked ~ .checkmark i {
    opacity: 1;
    transform: scale(1);
}

/* Custom Radio */
.custom-radio {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-heading);
    user-select: none;
}
.custom-radio input {
    display: none;
}
.radio-mark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    background: var(--bg-card);
}
.radio-mark::after {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.2s;
}
.custom-radio input:checked ~ .radio-mark {
    border-color: var(--primary);
}
.custom-radio input:checked ~ .radio-mark::after {
    opacity: 1;
    transform: scale(1);
}

/* Profile Picture Picker */
.avatar-picker {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}
.avatar-preview-box {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 2px dashed var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    background: var(--bg-body);
    transition: all 0.2s;
}
.avatar-preview-box:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}
.avatar-preview-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
    z-index: 2;
}
.avatar-preview-box .placeholder-icon {
    font-size: 2.5rem;
    color: var(--text-muted);
    position: absolute;
    z-index: 1;
}
.avatar-preview-box input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 3;
}
.avatar-remove-btn {
    font-size: 0.85rem;
    color: var(--danger);
    cursor: pointer;
    font-weight: 600;
    display: none;
}
.avatar-remove-btn:hover {
    text-decoration: underline;
}

/* Custom Searchable Dropdown */
.searchable-dropdown {
    position: relative;
    width: 100%;
}
.sd-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1rem;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-heading);
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
}
.sd-header:hover {
    border-color: var(--primary);
}
.sd-header.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}
.sd-list-container {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-top: none;
    border-bottom-left-radius: var(--border-radius-sm);
    border-bottom-right-radius: var(--border-radius-sm);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    z-index: 100;
    display: none;
    max-height: 250px;
    overflow-y: auto;
}
.searchable-dropdown.open .sd-list-container {
    display: block;
}
.sd-search-box {
    padding: 8px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: var(--bg-card);
}
.sd-search-box input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.85rem;
    outline: none;
}
.sd-search-box input:focus {
    border-color: var(--primary);
}
.sd-item {
    padding: 10px 16px;
    font-size: 0.95rem;
    color: var(--text-body);
    cursor: pointer;
    transition: background 0.1s;
}
.sd-item:hover {
    background: var(--primary-light);
    color: var(--primary);
}
.sd-item.selected {
    background: var(--primary);
    color: #fff;
}

/* Global Loading Spinner (Minimal) */
#global-loader {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--primary-light);
    z-index: 9999;
    overflow: hidden;
    opacity: 1;
    transition: opacity 0.3s;
}
#global-loader::after {
    content: '';
    position: absolute;
    top: 0; left: -50%;
    height: 100%;
    width: 50%;
    background: var(--primary);
    animation: loadingBar 1s ease-in-out infinite;
}
@keyframes loadingBar {
    0% { left: -50%; }
    100% { left: 100%; }
}
#global-loader.hidden { opacity: 0; pointer-events: none; }

/* ── Prize Image Picker ───────────────────────────────────────────────────── */
.prize-image-zone {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 2px dashed var(--border-color);
    border-radius: 14px;
    background: #F8FAFC;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.prize-image-zone:hover,
.prize-image-zone.drag-over {
    border-color: var(--primary);
    background: var(--primary-light);
}
.prize-image-zone.drag-over {
    border-style: solid;
}
.prize-image-zone.has-image {
    border-style: solid;
    border-color: #C7D2FE;
    background: #000;
}

/* Placeholder (no image) */
.prize-image-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    pointer-events: none;
    text-align: center;
    padding: 24px;
}
.prize-image-placeholder__icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: #EEF2FF;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 1.5rem;
    margin-bottom: 4px;
}
.prize-image-placeholder__title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-heading);
    margin: 0;
}
.prize-image-placeholder__hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: 0;
}

/* Preview image */
.prize-image-preview {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.2s;
}
.prize-image-zone.has-image:hover .prize-image-preview {
    opacity: 0.45;
}

/* Hover overlay */
.prize-image-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 700;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}
.prize-image-zone.has-image:hover .prize-image-overlay {
    opacity: 1;
}

/* Remove button */
.prize-image-remove-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding: 6px 14px;
    border: none;
    border-radius: 20px;
    background: #FFF1F2;
    color: var(--danger);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.prize-image-remove-btn:hover {
    background: var(--danger);
    color: #fff;
}

/* ── Mobile Responsiveness ────────────────────────────────────────────────── */
.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-heading);
    cursor: pointer;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 40;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.sidebar-overlay.open {
    display: block;
    opacity: 1;
}

/* Responsive Table Wrapper */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-sm);
    background: var(--bg-card);
}

.table-responsive .table {
    white-space: nowrap;
    margin-bottom: 0;
}

@media (max-width: 992px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        box-shadow: var(--shadow-md);
        z-index: 50;
    }

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

    .mobile-menu-btn {
        display: block;
    }

    .topbar {
        padding: 0 20px;
    }

    .content-area {
        padding: 20px 20px;
    }

    .topbar-search {
        display: none; /* Hide search bar on mobile for space */
    }

    /* Stack cards in grids */
    .grid, .flex {
        flex-direction: column;
        grid-template-columns: 1fr !important;
    }

    .user-info {
        display: none; /* Hide user name to save topbar space */
    }

    .card {
        padding: 1rem;
    }

    .table th, .table td {
        padding: 0.75rem 1rem;
    }
}
