/* ============================================================
   Tournament Management System - Master Stylesheet
   Child System of LevelLance Platform
   High-Contrast Dark UI with WCAG AA/AAA Compliance
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=Outfit:wght@400;600;700;800&display=swap');
@import url('https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css');
@import url('https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css');

:root, [data-bs-theme=dark], [data-bs-theme=light] {
    --app-primary: #00d2ff;
    --app-secondary: #3a7bd5;
    --app-bg: #0d1117;
    --app-surface: #161b22;
    --app-card: #21262d;
    --app-text: #f0f6fc;
    --app-text-muted: #cbd5e1;
    --app-border: #30363d;
    --app-radius: 10px;
    --app-font: 'Inter', system-ui, -apple-system, sans-serif;
    --app-gradient: linear-gradient(135deg, var(--app-primary) 0%, var(--app-secondary) 100%);
    --app-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
    --app-glow: 0 0 20px rgba(0, 210, 255, 0.25);

    /* Bootstrap 5.3 Theme Bridge Variables */
    --bs-body-color: var(--app-text);
    --bs-body-bg: var(--app-bg);
    --bs-emphasis-color: #ffffff;
    --bs-secondary-color: var(--app-text-muted);
    --bs-tertiary-color: var(--app-text-muted);
    --bs-border-color: var(--app-border);
    --bs-card-bg: var(--app-surface);
    --bs-card-color: var(--app-text);
    --bs-table-color: var(--app-text);
    --bs-table-bg: transparent;
    --bs-table-striped-color: var(--app-text);
    --bs-table-hover-color: #ffffff;
    --bs-table-hover-bg: rgba(255, 255, 255, 0.05);
    --bs-table-border-color: var(--app-border);
    --bs-heading-color: var(--app-text);
    --bs-link-color: var(--app-primary);
    --bs-link-hover-color: #60a5fa;
    --bs-list-group-color: var(--app-text);
    --bs-list-group-bg: transparent;
    --bs-list-group-border-color: var(--app-border);
}

body {
    font-family: var(--app-font);
    background-color: var(--app-bg);
    color: var(--app-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Typography & Headings */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Outfit', var(--app-font);
    font-weight: 700;
    color: var(--app-text);
}

.text-gradient {
    background: var(--app-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* High-Contrast Primary, Secondary, and Text Utilities */
.text-primary,
[data-bs-theme] .text-primary {
    color: var(--app-primary, #00d2ff) !important;
}

/* Ensure pill badges with transparent backgrounds are crisp, luminous, and 100% readable */
.badge.bg-primary.bg-opacity-10,
.badge.bg-primary.bg-opacity-20,
.badge.bg-primary.bg-opacity-25,
.badge.bg-opacity-20.text-primary,
.badge.bg-opacity-25.text-primary {
    background-color: rgba(0, 210, 255, 0.16) !important;
    color: #38bdf8 !important;
    border: 1px solid rgba(56, 189, 248, 0.45) !important;
    font-weight: 600;
}

.badge.bg-info.bg-opacity-10,
.badge.bg-info.bg-opacity-20,
.badge.bg-info.bg-opacity-25,
.badge.bg-opacity-20.text-info,
.badge.bg-opacity-25.text-info {
    background-color: rgba(14, 165, 233, 0.16) !important;
    color: #38bdf8 !important;
    border: 1px solid rgba(14, 165, 233, 0.45) !important;
    font-weight: 600;
}

.badge.bg-success.bg-opacity-10,
.badge.bg-success.bg-opacity-20,
.badge.bg-success.bg-opacity-25,
.badge.bg-opacity-20.text-success,
.badge.bg-opacity-25.text-success {
    background-color: rgba(34, 197, 94, 0.16) !important;
    color: #4ade80 !important;
    border: 1px solid rgba(34, 197, 94, 0.45) !important;
    font-weight: 600;
}

.badge.bg-warning.bg-opacity-10,
.badge.bg-warning.bg-opacity-20,
.badge.bg-warning.bg-opacity-25,
.badge.bg-opacity-20.text-warning,
.badge.bg-opacity-25.text-warning {
    background-color: rgba(234, 179, 8, 0.16) !important;
    color: #fbbf24 !important;
    border: 1px solid rgba(234, 179, 8, 0.45) !important;
    font-weight: 600;
}

.badge.bg-danger.bg-opacity-10,
.badge.bg-danger.bg-opacity-20,
.badge.bg-danger.bg-opacity-25,
.badge.bg-opacity-20.text-danger,
.badge.bg-opacity-25.text-danger {
    background-color: rgba(239, 68, 68, 0.16) !important;
    color: #f87171 !important;
    border: 1px solid rgba(239, 68, 68, 0.45) !important;
    font-weight: 600;
}

.badge.bg-secondary.bg-opacity-10,
.badge.bg-secondary.bg-opacity-20,
.badge.bg-secondary.bg-opacity-25 {
    background-color: rgba(148, 163, 184, 0.16) !important;
    color: #e2e8f0 !important;
    border: 1px solid rgba(148, 163, 184, 0.35) !important;
    font-weight: 600;
}

/* High-Contrast Muted & Secondary Text System-wide */
.text-muted,
.text-secondary,
[data-bs-theme] .text-muted,
[data-bs-theme] .text-secondary {
    color: var(--app-text-muted, #cbd5e1) !important;
}

small.text-muted,
span.text-muted,
p.text-muted,
div.text-muted,
.smaller.text-muted,
.small.text-muted,
.font-monospace.text-muted {
    color: var(--app-text-muted, #cbd5e1) !important;
}

/* Glassmorphism Cards */
.card, .widget-card {
    background-color: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow);
    color: var(--app-text);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

.card-header {
    background-color: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--app-border);
    color: var(--app-text);
    font-weight: 600;
}

.card-body {
    color: var(--app-text);
}

.card-footer {
    background-color: rgba(255, 255, 255, 0.02);
    border-top: 1px solid var(--app-border);
    color: var(--app-text-muted, #cbd5e1);
}

/* Navigation & Navbar */
.navbar-custom {
    background-color: rgba(22, 27, 34, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--app-border);
    position: relative;
    z-index: 1040;
}

.navbar-custom .dropdown-menu {
    z-index: 1045 !important;
}

.navbar-brand {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--app-text) !important;
}

.nav-link {
    color: var(--app-text-muted, #cbd5e1) !important;
    font-weight: 500;
    transition: color 0.15s ease;
}

.nav-link:hover, .nav-link.active {
    color: var(--app-primary) !important;
}

/* Buttons */
.btn-primary {
    background: var(--app-gradient);
    border: none;
    color: #fff !important;
    font-weight: 600;
    border-radius: var(--app-radius);
    box-shadow: var(--app-glow);
    transition: all 0.2s ease;
}

.btn-primary:hover {
    filter: brightness(1.15);
    transform: translateY(-1px);
    color: #fff !important;
}

.btn-outline-secondary {
    border-color: var(--app-border);
    color: var(--app-text);
    border-radius: var(--app-radius);
}

.btn-outline-secondary:hover {
    background-color: var(--app-border);
    color: #fff;
}

/* Forms & Inputs */
.form-label, label {
    color: var(--app-text) !important;
    font-weight: 500;
}

.form-text, .form-check-label {
    color: var(--app-text-muted, #cbd5e1) !important;
}

.form-control, .form-select {
    background-color: var(--app-card) !important;
    border: 1px solid var(--app-border) !important;
    color: var(--app-text) !important;
    border-radius: var(--app-radius);
    padding: 0.6rem 0.9rem;
}

.form-control:focus, .form-select:focus {
    background-color: var(--app-card) !important;
    border-color: var(--app-primary) !important;
    color: #ffffff !important;
    box-shadow: 0 0 0 0.25rem rgba(0, 210, 255, 0.15) !important;
}

.form-control::placeholder {
    color: #94a3b8 !important;
    opacity: 0.8;
}

.input-group-text {
    background-color: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid var(--app-border) !important;
    color: var(--app-text-muted, #cbd5e1) !important;
}

/* Badges & Tags */
.badge {
    padding: 0.45em 0.75em;
    font-weight: 600;
    border-radius: 6px;
    letter-spacing: 0.2px;
}

.badge-success, .badge.bg-success { background-color: #238636 !important; color: #fff !important; }
.badge-warning, .badge.bg-warning { background-color: #f59e0b !important; color: #0f172a !important; }
.badge-danger, .badge.bg-danger { background-color: #da3633 !important; color: #fff !important; }
.badge-info, .badge.bg-info { background-color: #0284c7 !important; color: #fff !important; }
.badge-purple { background-color: #8957e5 !important; color: #fff !important; }
.badge-orange { background-color: #bd561d !important; color: #fff !important; }
.badge-secondary, .badge.bg-secondary { background-color: #334155 !important; color: #f8fafc !important; border: 1px solid rgba(255, 255, 255, 0.1) !important; }
.badge-dark, .badge.bg-dark { background-color: rgba(255, 255, 255, 0.1) !important; color: #f0f6fc !important; border: 1px solid var(--app-border) !important; }

/* Code & Syntax Elements */
code {
    color: #38bdf8 !important;
    background-color: rgba(56, 189, 248, 0.12) !important;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.875em;
}

/* List Groups */
.list-group-item {
    background-color: transparent !important;
    color: var(--app-text) !important;
    border-color: var(--app-border) !important;
}

.list-group-item .text-muted {
    color: var(--app-text-muted, #cbd5e1) !important;
}

/* Universal High-Contrast Table Styles */
.table,
.table-custom,
table {
    --bs-table-color: var(--app-text, #f0f6fc) !important;
    --bs-table-bg: transparent !important;
    --bs-table-border-color: var(--app-border, #30363d) !important;
    --bs-table-striped-color: var(--app-text, #f0f6fc) !important;
    --bs-table-hover-color: #ffffff !important;
    --bs-table-hover-bg: rgba(255, 255, 255, 0.04) !important;
    color: var(--app-text, #f0f6fc) !important;
    border-color: var(--app-border, #30363d) !important;
}

.table > :not(caption) > * > *,
.table-custom > :not(caption) > * > *,
table > :not(caption) > * > * {
    color: var(--app-text, #e2e8f0) !important;
    background-color: transparent !important;
    border-color: var(--app-border, #30363d) !important;
}

.table th,
.table-custom th,
table th {
    background-color: rgba(255, 255, 255, 0.04) !important;
    color: #ffffff !important;
    font-weight: 600 !important;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--app-border, #30363d) !important;
}

.table td,
.table-custom td,
table td {
    color: var(--app-text, #e2e8f0) !important;
    border-color: var(--app-border, #30363d) !important;
    vertical-align: middle;
}

.table td .text-muted,
.table-custom td .text-muted,
table td .text-muted {
    color: #cbd5e1 !important;
}

.table-hover tbody tr:hover td,
.table-hover tbody tr:hover > *,
.table tbody tr:hover td,
.table-custom tbody tr:hover td,
table tbody tr:hover td {
    background-color: rgba(255, 255, 255, 0.05) !important;
    color: #ffffff !important;
}

.table-dark {
    --bs-table-bg: rgba(255, 255, 255, 0.06) !important;
    --bs-table-color: #ffffff !important;
    background-color: rgba(255, 255, 255, 0.06) !important;
    color: #ffffff !important;
}

.table-dark th,
.table-dark td {
    background-color: rgba(255, 255, 255, 0.06) !important;
    color: #ffffff !important;
}

/* Modals & Dropdowns */
.dropdown-menu {
    background-color: var(--app-surface) !important;
    border: 1px solid var(--app-border) !important;
    box-shadow: var(--app-shadow) !important;
    color: var(--app-text) !important;
}

.dropdown-item {
    color: var(--app-text, #e2e8f0) !important;
}

.dropdown-item:hover, .dropdown-item:focus {
    background-color: rgba(255, 255, 255, 0.08) !important;
    color: #ffffff !important;
}

.modal-content {
    background-color: var(--app-surface) !important;
    border: 1px solid var(--app-border) !important;
    color: var(--app-text) !important;
}

.modal-header, .modal-footer {
    border-color: var(--app-border) !important;
}

/* Pagination & Breadcrumbs */
.page-link {
    background-color: var(--app-card) !important;
    border-color: var(--app-border) !important;
    color: var(--app-text) !important;
}

.page-link:hover {
    background-color: rgba(255, 255, 255, 0.08) !important;
    color: #ffffff !important;
}

.page-item.active .page-link {
    background: var(--app-gradient) !important;
    border-color: transparent !important;
    color: #ffffff !important;
}

.page-item.disabled .page-link {
    background-color: transparent !important;
    border-color: var(--app-border) !important;
    color: var(--app-text-muted, #94a3b8) !important;
}

/* Hero Section */
.hero-section {
    background: radial-gradient(circle at top right, rgba(0, 210, 255, 0.15), transparent 60%),
                radial-gradient(circle at bottom left, rgba(58, 123, 213, 0.15), transparent 60%),
                var(--app-surface);
    border: 1px solid var(--app-border);
    padding: 5rem 2rem;
}

.hero-badge {
    display: inline-block;
    padding: 0.35rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Bracket Tree Styles */
.bracket-container {
    display: flex;
    overflow-x: auto;
    padding: 2rem 1rem;
    gap: 2.5rem;
}

.bracket-round {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    min-width: 260px;
}

.bracket-round-title {
    text-align: center;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--app-text-muted, #cbd5e1);
    text-transform: uppercase;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--app-border);
}

.bracket-match {
    background-color: var(--app-card);
    border: 1px solid var(--app-border);
    border-radius: 8px;
    margin: 1rem 0;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}

.bracket-participant {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.55rem 0.85rem;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--app-border);
}

.bracket-participant:last-child {
    border-bottom: none;
}

.bracket-participant.winner {
    background-color: rgba(35, 134, 54, 0.15);
    font-weight: 700;
    color: #3fb950;
}

.bracket-score {
    font-weight: 800;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
}

/* Admin Sidebar */
.admin-wrapper {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 270px;
    background-color: var(--app-surface);
    border-right: 1px solid var(--app-border);
    display: flex;
    flex-direction: column;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 1000;
}

.admin-sidebar.collapsed {
    width: 78px;
}

.admin-sidebar.collapsed .sidebar-text,
.admin-sidebar.collapsed .sidebar-heading {
    display: none;
}

.admin-sidebar.collapsed .sidebar-link {
    justify-content: center;
    padding: 0.75rem 0;
}

.admin-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar-nav {
    overflow-y: auto;
    flex: 1;
    padding: 1rem 0.75rem;
}

.sidebar-heading {
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    color: #cbd5e1 !important;
    padding: 0.75rem 0.75rem 0.25rem 0.75rem;
    letter-spacing: 0.75px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 0.6rem 0.85rem;
    color: #cbd5e1 !important;
    text-decoration: none;
    border-radius: var(--app-radius);
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
    transition: all 0.15s ease;
}

.sidebar-link i {
    font-size: 1.15rem;
    margin-right: 0.75rem;
    min-width: 1.5rem;
    text-align: center;
}

.admin-sidebar.collapsed .sidebar-link i {
    margin-right: 0;
}

.sidebar-link:hover {
    color: #ffffff !important;
    background-color: rgba(255, 255, 255, 0.08) !important;
}

.sidebar-link.active {
    color: #ffffff !important;
    background: var(--app-gradient) !important;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 210, 255, 0.25);
}

/* Floating Live Chat Widget */
.floating-chat-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--app-gradient);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    box-shadow: 0 8px 25px rgba(0, 210, 255, 0.4);
    cursor: pointer;
    z-index: 1050;
    transition: transform 0.2s ease;
}

.floating-chat-btn:hover {
    transform: scale(1.08);
}

.chat-box-popup {
    position: fixed;
    bottom: 6.5rem;
    right: 2rem;
    width: 360px;
    height: 480px;
    background-color: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 16px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
    display: none;
    flex-direction: column;
    z-index: 1050;
    overflow: hidden;
}

.chat-box-popup.open {
    display: flex;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.chat-bubble {
    max-width: 80%;
    padding: 0.55rem 0.85rem;
    border-radius: 12px;
    font-size: 0.85rem;
}

.chat-bubble.visitor, .chat-bubble.user {
    background-color: var(--app-primary);
    color: #000;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.chat-bubble.staff {
    background-color: var(--app-card);
    color: var(--app-text);
    border: 1px solid var(--app-border);
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

.floating-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #fff;
    font-size: 0.75rem;
    font-weight: bold;
    border-radius: 9999px;
    padding: 2px 7px;
    border: 2px solid #111827;
    animation: chat-badge-pulse 1.8s infinite;
}

@keyframes chat-badge-pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

@keyframes bell-ring {
    0% { transform: rotate(0); }
    10% { transform: rotate(15deg); }
    20% { transform: rotate(-15deg); }
    30% { transform: rotate(10deg); }
    40% { transform: rotate(-10deg); }
    50% { transform: rotate(5deg); }
    60% { transform: rotate(-5deg); }
    100% { transform: rotate(0); }
}

.bell-ringing {
    animation: bell-ring 0.8s ease-in-out;
}

/* Print Styles */
@media print {
    body { background-color: #fff !important; color: #000 !important; }
    .navbar-custom, .admin-sidebar, .floating-chat-btn, .btn, .no-print { display: none !important; }
    .card { border: 1px solid #ddd !important; box-shadow: none !important; color: #000 !important; }
    .table, .table-custom, table { color: #000 !important; }
    .table td, .table th { color: #000 !important; }
}
