﻿/* ==========================================================================
   Sabah Diabolo 沙巴扯铃协会 — Master CSS Design System
   ========================================================================== */

/* FontAwesome Icons Import */
@import url('../fonts/fontawesome/css/all.min.css');
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,400..800;1,400..800&family=Outfit:wght@400..800&family=Plus+Jakarta+Sans:ital,wght@0,400..800;1,400..800&display=swap');

:root {
    /* Color Palette (Dark Theme Obsidian + Electric Cyan) */
    --bg-dark: #07090e;
    --bg-surface-1: #0f172a;
    --bg-surface-2: #1e293b;
    --bg-surface-3: #334155;
    --bg-glass: rgba(15, 23, 42, 0.85);
    --bg-glass-card: rgba(30, 41, 59, 0.5);
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-medium: rgba(255, 255, 255, 0.16);
    --border-accent: rgba(6, 182, 212, 0.4);
    --border-glow: rgba(6, 182, 212, 0.6);
    /* Primary Brand Accent (Electric Cyan) */
    --primary: #06b6d4;
    --primary-hover: #0891b2;
    --primary-active: #0284c7;
    --primary-light: #22d3ee;
    --primary-gradient: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
    --primary-glow: 0 0 20px rgba(6, 182, 212, 0.35);
    --primary-glow-lg: 0 0 35px rgba(6, 182, 212, 0.5);
    /* Warning State (Warm Amber / Gold - Incomplete / Pending) */
    --warning: #f59e0b;
    --warning-hover: #d97706;
    --warning-bg: rgba(245, 158, 11, 0.12);
    --warning-border: rgba(245, 158, 11, 0.35);
    /* Danger State (Crimson - Destructive & Rule Drop ONLY) */
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --danger-bg: rgba(239, 68, 68, 0.12);
    --danger-border: rgba(239, 68, 68, 0.35);
    --danger-glow: 0 0 15px rgba(239, 68, 68, 0.3);
    /* Section accent (Violet). Carries no state meaning — it is a heading tint used to
     tell one accordion section apart from its neighbours on /admin-category, where the
     other section icons already use --primary, --warning and --text-muted. Tokenised
     from the one hardcoded #a855f7 that had been left inline on that page's icon. */
    --sd-accent-violet: #a855f7;
    /* Success State (Emerald - Confirmed / Active) */
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.12);
    --success-border: rgba(16, 185, 129, 0.35);
    /* Text Colors */
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --text-sub: #cbd5e1;
    /* Typography */
    --font-title: 'Outfit', -apple-system, sans-serif;
    --font-body: 'Plus Jakarta Sans', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    /* Layout Radius & Constraints */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --max-content-width: 800px;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

code, kbd, samp, pre, .mono {
    font-family: var(--font-mono);
}

code {
    font-family: var(--font-mono);
    background: var(--bg-surface-2);
    color: var(--primary-light);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    font-size: 1.2em;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-surface-3);
    border-radius: 4px;
}

    ::-webkit-scrollbar-thumb:hover {
        background: var(--primary);
    }

/* App Shell Structure */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Desktop Sidebar */
.app-sidebar {
    width: 240px;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background: var(--bg-surface-1);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
    z-index: 90;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.25) var(--bg-surface-1);
}

    .app-sidebar::-webkit-scrollbar {
        width: 6px;
    }

    .app-sidebar::-webkit-scrollbar-track {
        background: var(--bg-surface-1);
    }

    .app-sidebar::-webkit-scrollbar-thumb {
        background: rgba(148, 163, 184, 0.25);
        border-radius: 999px;
    }

        .app-sidebar::-webkit-scrollbar-thumb:hover {
            background: var(--primary);
        }

.sidebar-header {
    padding: 20px 16px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    display: block;
    flex-shrink: 0;
}

.login-logo {
    width: 64px;
    height: 64px;
    object-fit: contain;
    margin: 0 auto 14px;
    display: block;
}

.brand-title {
    font-family: var(--font-title);
    font-weight: 700;
    font-size: 16px;
    color: var(--text-main);
    line-height: 1.2;
}

.brand-sub {
    font-size: 11px;
    color: var(--text-muted);
}

.nav-list {
    list-style: none;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
}

    .nav-item a:hover {
        color: var(--text-main);
        background: rgba(255, 255, 255, 0.04);
    }

.nav-item.active a {
    color: var(--primary);
    background: var(--bg-surface-2);
    border: 1px solid var(--border-accent);
    box-shadow: var(--primary-glow);
}

.nav-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 8px 12px;
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px;
    border-top: 1px solid var(--border-subtle);
}

/* Mobile Header */
.mobile-header {
    display: none;
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-subtle);
    padding: 12px 16px;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: var(--transition-fast);
}

    .icon-btn:hover {
        background: var(--bg-surface-2);
    }

/* Mobile Drawer Overlay */
.mobile-drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 500;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-normal);
}

    .mobile-drawer-overlay.open {
        opacity: 1;
        pointer-events: auto;
    }

.mobile-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    background: var(--bg-surface-1);
    border-right: 1px solid var(--border-medium);
    z-index: 501;
    transform: translateX(-100%);
    transition: var(--transition-normal);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

    .mobile-drawer::-webkit-scrollbar {
        display: none;
    }

    .mobile-drawer.open {
        transform: translateX(0);
    }

/* Context Strip */
.context-strip {
    background: rgba(6, 182, 212, 0.08);
    border-bottom: 1px solid var(--border-accent);
    padding: 8px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
}

.context-name {
    color: var(--primary);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.context-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.context-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 12px;
}

    .context-link:hover {
        color: var(--danger);
    }

/* Main Area */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-left: 240px;
    min-width: 0;
}

.content-area {
    flex: 1;
    padding: 20px;
    width: 100%;
    margin: 0 auto;
}

    /* Default centered max-width 800px for reading/forms (Desktop PC & Tablet) */
    .content-area.standard-width {
        max-width: var(--max-content-width);
    }
    /* Wide workspace exception for matrices/tables */
    .content-area.wide-workspace {
        max-width: 100%;
    }

/* UI Cards */
.card {
    background: var(--bg-surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 16px;
    transition: var(--transition-normal);
}

.card-glass {
    background: var(--bg-glass-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
}

.card-interactive:hover {
    border-color: var(--border-accent);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    transform: translateY(-2px);
}

.card-title {
    font-family: var(--font-title);
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 8px;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}

.badge-primary {
    background: rgba(6, 182, 212, 0.15);
    color: var(--primary-light);
    border: 1px solid var(--border-accent);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid var(--warning-border);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid var(--danger-border);
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid var(--success-border);
}

.badge-neutral {
    background: var(--bg-surface-3);
    color: var(--text-sub);
    border: 1px solid var(--border-subtle);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition-fast);
    text-decoration: none;
}

.btn-primary {
    background: var(--primary-gradient);
    color: #0f172a;
    font-weight: 700;
    box-shadow: var(--primary-glow);
}

    .btn-primary:hover {
        filter: brightness(1.1);
        box-shadow: var(--primary-glow-lg);
    }

.btn .badge,
.btn .t2,
.btn .t2-cn,
.btn .t2-en {
    background: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
}

.btn-primary,
.btn-primary *,
.btn-primary .badge,
.btn-primary .t2,
.btn-primary .t2-cn,
.btn-primary .t2-en {
    color: #0f172a !important;
}

.btn:disabled,
.btn[disabled],
.btn.disabled {
    opacity: 0.88;
    cursor: not-allowed;
}

.btn-primary:disabled,
.btn-primary[disabled] {
    background: var(--primary-gradient);
    color: #0f172a !important;
}

.btn-secondary {
    background: var(--bg-surface-2);
    color: var(--text-main);
    border: 1px solid var(--border-medium);
}

    .btn-secondary:hover {
        background: var(--bg-surface-3);
        border-color: var(--text-muted);
    }

.btn-danger {
    background: var(--danger);
    color: #fff;
    box-shadow: var(--danger-glow);
}

    .btn-danger:hover {
        background: var(--danger-hover);
    }

.btn-danger-outline {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid var(--danger-border);
}

    .btn-danger-outline:hover {
        background: var(--danger);
        color: #fff;
    }

/* Terminal confirm action (judge "Submit Final Rank List"). #fff is deliberate here,
   same as .btn-danger: text on a solid colour button is not themed. There is no
   --success-hover token (unlike danger/warning), so the hover stays derived from
   --success via brightness rather than introducing a new hardcoded colour. */
.btn-success {
    background: var(--success);
    color: #fff;
}

    .btn-success:hover {
        background: var(--success);
        filter: brightness(1.1);
    }

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

/* Form Controls */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-sub);
    margin-bottom: 6px;
}

    .form-label .required-star {
        color: var(--danger);
        margin-left: 2px;
    }

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-surface-1);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 14px;
    outline: none;
    transition: var(--transition-fast);
}

    .form-input:focus, .form-select:focus, .form-textarea:focus {
        border-color: var(--primary);
        box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.2);
    }

/* Keypad Grid for Scoring */
.keypad-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    margin-top: 6px;
}

.keypad-btn {
    background: var(--bg-surface-2);
    border: 1px solid var(--border-medium);
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 15px;
    font-weight: 700;
    padding: 10px 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
}

    .keypad-btn:hover {
        border-color: var(--primary);
        color: var(--primary);
    }

    .keypad-btn.selected {
        background: var(--primary-gradient);
        color: #000;
        border-color: transparent;
        box-shadow: var(--primary-glow);
    }

/* Tables */
.table-container {
    width: 100%;
    overflow: auto;
    max-height: calc(100vh - 220px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}

.data-table {
    width: auto;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
}

    .data-table th {
        background: var(--bg-surface-2);
        color: var(--text-sub);
        font-weight: 600;
        padding: 10px 12px;
        border-bottom: 1px solid var(--border-medium);
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .data-table td {
        padding: 12px;
        border-bottom: 1px solid var(--border-subtle);
        color: var(--text-main);
    }

    .data-table tr:hover td {
        background: rgba(255, 255, 255, 0.02);
    }

.rank-cell {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--primary);
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 13px;
    margin-bottom: 16px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.alert-info {
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid var(--border-accent);
    color: var(--text-sub);
}

.alert-warning {
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    color: var(--warning);
}

.alert-danger {
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    color: #fca5a5;
}

/* Arithmetic Security Guard Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-normal);
}

    .modal-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }

.modal-card {
    background: var(--bg-surface-1);
    border: 1px solid var(--danger-border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 440px;
    padding: 24px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.8), var(--danger-glow);
}

.modal-title {
    font-family: var(--font-title);
    font-size: 18px;
    font-weight: 700;
    color: var(--danger);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.puzzle-box {
    background: var(--bg-dark);
    border: 1px dashed var(--danger-border);
    padding: 12px;
    border-radius: var(--radius-md);
    margin: 16px 0;
    text-align: center;
}

.puzzle-question {
    font-family: var(--font-mono);
    font-size: 18px;
    font-weight: 700;
    color: var(--warning);
    margin-bottom: 8px;
}

/* Responsive Media Queries */
@media (max-width: 800px) {
    .app-sidebar {
        display: none;
    }

    .mobile-header {
        display: flex;
    }

    .app-main {
        margin-left: 0;
    }

    .content-area.standard-width {
        max-width: 100%;
    }

    .data-table {
        width: 100%;
    }
}

/* Category Popup Selector Modal */
.cat-popup-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: min(760px, calc(100vw - 32px));
    max-height: 85vh;
    background: var(--bg-surface-1);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8), var(--primary-glow);
    z-index: 600;
    flex-direction: column;
    opacity: 0;
    transition: opacity var(--transition-normal), transform var(--transition-normal);
}

    .cat-popup-modal.open {
        display: flex;
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

.cat-popup-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-surface-2);
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
}

.cat-popup-body {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.25) var(--bg-surface-1);
}

.cat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 10px;
}

.cat-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 12px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-main);
    transition: var(--transition-normal);
    cursor: pointer;
    position: relative;
}

    .cat-card:hover {
        background: var(--bg-surface-3);
        border-color: var(--primary);
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(6, 182, 212, 0.15);
    }

    .cat-card.is-active {
        border-color: var(--primary);
        background: rgba(6, 182, 212, 0.08);
        box-shadow: inset 0 0 0 1px var(--primary);
    }

.cat-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.cat-code-badge {
    font-weight: 800;
    color: var(--primary);
    font-size: 13px;
}

.cat-card-title {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text-main);
}

.cat-card-active-tag {
    margin-top: 8px;
    font-size: 11px;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 4px;
}
