/*
 * Golf Buddies — AdminUIUX Theme Bridge CSS
 * Maps all custom Golf Buddies classes to AdminUIUX's mobile-first layout
 */

/* ===== Golf Buddies Green Theme Override ===== */
:root, .theme-green {
    --adminuiux-theme-1: #1F6B3B;
    --adminuiux-theme-1-hover: #175A30;
    --adminuiux-theme-1-active: #0F4A25;
    --adminuiux-theme-1-rgb: 31, 107, 59;
    --adminuiux-theme-1-text: #fff;
    --adminuiux-theme-2: #C8A96A;
    --adminuiux-theme-2-rgb: 200, 169, 106;
    --adminuiux-theme-2-text: #fff;
    --adminuiux-theme-accent-1: #3E6B4F;
    --adminuiux-theme-accent-1-hover: #2D5A3E;
    --adminuiux-theme-accent-1-active: #1F4A2F;
    --adminuiux-theme-accent-1-rgb: 62, 107, 79;
    --adminuiux-theme-accent-1-text: #fff;
    --adminuiux-theme-accent-2: #F2B705;
    --adminuiux-theme-accent-2-rgb: 242, 183, 5;
    --adminuiux-theme-accent-2-text: #1A1A1A;
    --adminuiux-bg-1: #f0f5ee;
    --adminuiux-bg-2: #dce8d8;

    /* ── App bridge variables (used by JS-rendered templates) ── */
    --accent: #3E6B4F;
    --accent-hover: #1F3D2B;
    --accent-light: #e8f0eb;
    --gold: #C8A96A;
    --amber: #E0A106;
    --danger: #c62828;
    --danger-light: #ffebee;
    --warning: #E0A106;
    --warning-light: #fdf5e0;
    --info: #3E6B4F;
    --info-light: #e8f0eb;
    --bg-primary: var(--adminuiux-bg-1);
    --bg-secondary: #fff;
    --bg-card: #fff;
    --bg-input: #fff;
    --text-primary: #1A1A1A;
    --text-secondary: #5C5C5C;
    --text-muted: #8a8a8a;
    --border-color: rgba(0,0,0,0.1);
    --border-light: rgba(0,0,0,0.06);
    --shadow: 0 2px 8px rgba(31,61,43,0.06);
    --shadow-lg: 0 4px 16px rgba(31,61,43,0.10);
    --radius: var(--bs-border-radius);
    --radius-sm: var(--bs-border-radius-sm);
    --transition: 0.2s ease;
}

[data-bs-theme="dark"] .theme-green {
    --adminuiux-bg-1: #0a1f10;
    --adminuiux-bg-2: #132820;
    --accent-light: #1a3328;
    --danger-light: #3a1a1a;
    --warning-light: #3a2a10;
    --info-light: #1a3328;
    --bg-card: rgba(var(--adminuiux-theme-1-rgb), 0.15);
    --bg-input: rgba(255,255,255,0.08);
    --text-primary: #F5F5F5;
    --text-secondary: #A8B3AF;
    --text-muted: #7a8a83;
    --border-color: rgba(255,255,255,0.12);
    --border-light: rgba(255,255,255,0.06);
}

/* ===== Content Area Spacing ===== */
.gb-content-area {
    padding-top: calc(60px + env(safe-area-inset-top, 0px));       /* below fixed header + notch */
    padding-bottom: 100px;   /* above mobile footer */
    max-width: 800px;
}
@media (min-width: 992px) {
    .gb-content-area {
        max-width: 1100px;
        padding-bottom: 2rem;
    }
}

/* ===== iPhone Safe Area — Fixed Header ===== */
.adminuiux-header .navbar.fixed-top {
    padding-top: env(safe-area-inset-top, 0px) !important;
}

/* ===== Page Headers ===== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.page-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    font-family: var(--adminuiux-title-font);
}

/* ===== Cards (bridge old class to AdminUIUX) ===== */
.card {
    margin-bottom: 1rem;
    padding: 1.25rem !important;
}
.card .card-body {
    padding: 0; /* avoid double padding when card-body IS used */
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: none;
    margin: -1rem -1rem 0.75rem -1rem;
    padding: 0.75rem 1rem;
}
.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0;
}

/* ===== Custom Buttons (extend Bootstrap .btn) ===== */
.btn-primary {
    --bs-btn-bg: var(--accent);
    --bs-btn-border-color: var(--accent);
    --bs-btn-hover-bg: var(--accent-hover);
    --bs-btn-hover-border-color: var(--accent-hover);
    --bs-btn-active-bg: var(--accent-hover);
}
.btn-danger {
    --bs-btn-bg: var(--danger);
    --bs-btn-border-color: var(--danger);
}
.btn-warning {
    --bs-btn-bg: var(--amber);
    --bs-btn-border-color: var(--amber);
    --bs-btn-color: #1A1A1A;
}
.btn-secondary {
    --bs-btn-bg: rgba(0,0,0,0.06);
    --bs-btn-border-color: var(--border-color);
    --bs-btn-color: var(--text-primary);
    --bs-btn-hover-bg: rgba(0,0,0,0.1);
}
.btn-block { width: 100%; }

/* ===== Forms ===== */
.form-group { margin-bottom: 1rem; }
.form-label {
    display: block; font-size: 0.85rem; font-weight: 600;
    color: var(--text-secondary); margin-bottom: 4px;
}
.form-input, .form-textarea {
    display: block; width: 100%; padding: 0.5rem 0.75rem;
    font-size: 0.95rem; font-weight: 400; line-height: 1.5;
    color: var(--bs-body-color);
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--bs-border-radius);
    transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
    min-height: 44px; /* Touch target */
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
    border-color: var(--adminuiux-theme-1);
    box-shadow: 0 0 0 0.2rem rgba(var(--adminuiux-theme-1-rgb), .15);
    outline: none;
}
.form-select {
    display: block; width: 100%; padding: 0.5rem 2.25rem 0.5rem 0.75rem;
    font-size: 0.95rem; line-height: 1.5;
    color: var(--bs-body-color);
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--bs-border-radius);
    min-height: 44px;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
    -webkit-appearance: none; appearance: none;
}
.form-textarea { min-height: 80px; resize: vertical; }
.form-error { color: var(--danger); font-size: 0.8rem; margin-top: 2px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
@media (max-width: 500px) { .form-row { grid-template-columns: 1fr; } }

/* ===== Tabs ===== */
.tabs {
    display: flex; gap: 4px;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 1rem; overflow-x: auto;
}
.tab {
    padding: 0.625rem 1rem; font-size: 0.875rem; font-weight: 600;
    color: var(--text-secondary); background: none; border: none;
    cursor: pointer; white-space: nowrap;
    border-bottom: 2px solid transparent; margin-bottom: -2px;
    transition: all var(--transition);
}
.tab.active { color: var(--adminuiux-theme-1); border-bottom-color: var(--adminuiux-theme-accent-2); }
.tab:hover { color: var(--bs-body-color); }

/* ===== Toast Notifications ===== */
.golf-toast {
    position: fixed; top: 80px; right: 16px; z-index: 1200;
    padding: 12px 20px; border-radius: var(--bs-border-radius);
    font-weight: 600; font-size: 0.9rem;
    box-shadow: var(--shadow-lg); transition: all 0.3s ease;
    max-width: 360px;
}
.golf-toast.hidden { opacity: 0; pointer-events: none; transform: translateY(-10px); }
.golf-toast.success { background: var(--accent); color: #fff; }
.golf-toast.error { background: var(--danger); color: #fff; }
.golf-toast.info { background: var(--info); color: #fff; }

/* ===== Data Tables ===== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th, .data-table td {
    padding: 0.625rem 0.75rem; text-align: left;
    border-bottom: 1px solid var(--border-color);
}
.data-table th {
    font-weight: 700; color: var(--text-secondary);
    font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px;
}

/* ===== Status Badges ===== */
.badge-live { background: var(--danger); color: #fff; animation: gb-pulse 2s infinite; }
.badge-scheduled { background: var(--adminuiux-theme-accent-2); color: #1A1A1A; }
.badge-completed { background: var(--accent); color: #fff; }
.badge-cancelled { background: var(--text-muted); color: #fff; }
@keyframes gb-pulse { 0%,100% { opacity:1; } 50% { opacity:0.7; } }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.7; } }

/* ===== Scorecard ===== */
.scorecard-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
}
.hole-card {
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--bs-border-radius); padding: 12px; text-align: center;
    cursor: pointer; transition: all var(--transition);
}
.hole-card:hover, .hole-card.active {
    border-color: var(--accent); box-shadow: 0 0 0 2px rgba(62,107,79,0.2);
}
.hole-card.scored { border-left: 4px solid var(--accent); }
.hole-number { font-size: 0.75rem; color: var(--text-muted); font-weight: 700; }
.hole-par { font-size: 0.75rem; color: var(--text-secondary); }
.hole-score { font-size: 1.5rem; font-weight: 800; margin: 4px 0; }
.score-under { color: #c62828; }
.score-over { color: #1565c0; }
.score-par { color: var(--accent); }

/* ===== Score Entry Modal ===== */
.modal-overlay {
    display: none; position: fixed; inset: 0; z-index: 1100;
    background: rgba(0,0,0,0.85); align-items: flex-end; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-overlay .modal {
    display: block !important;
    background: var(--bs-body-bg);
    border-radius: 16px 16px 0 0;
    padding: 1.5rem; width: 100%; max-width: 500px;
    max-height: 85vh; overflow-y: auto; position: relative; opacity: 1;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.3);
}
@media (min-width: 700px) {
    .modal-overlay.open { align-items: center; }
    .modal-overlay .modal { border-radius: var(--bs-border-radius); }
}
.modal-title {
    font-size: 1.1rem; font-weight: 700; margin-bottom: 1rem;
    display: flex; justify-content: space-between; align-items: center;
}
.modal-close {
    background: none; border: none; font-size: 1.5rem;
    cursor: pointer; color: var(--text-muted); padding: 4px;
}

/* ===== Number Stepper (touch-optimized) ===== */
.stepper { display: flex; align-items: center; gap: 12px; justify-content: center; }
.stepper-btn {
    width: 52px; height: 52px; border-radius: 50%;
    border: 2px solid var(--border-color); background: var(--bg-input);
    font-size: 1.5rem; font-weight: 700; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--bs-body-color); transition: all var(--transition);
    -webkit-tap-highlight-color: transparent;
}
.stepper-btn:hover { border-color: var(--accent); color: var(--accent); }
.stepper-btn:active { background: var(--accent-light); transform: scale(0.95); }
.stepper-value {
    font-size: 2.2rem; font-weight: 800; min-width: 52px;
    text-align: center; color: var(--bs-body-color);
    font-family: var(--adminuiux-title-font);
}

/* ===== Toggle Switch ===== */
.toggle-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; }
.toggle-label { font-size: 0.95rem; color: var(--bs-body-color); }
.toggle {
    width: 52px; height: 28px; border-radius: 14px;
    background: var(--border-color); cursor: pointer;
    position: relative; transition: background var(--transition); border: none;
    -webkit-tap-highlight-color: transparent;
}
.toggle.on { background: var(--accent); }
.toggle::after {
    content: ''; position: absolute; top: 3px; left: 3px;
    width: 22px; height: 22px; border-radius: 50%;
    background: #fff; transition: transform var(--transition);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle.on::after { transform: translateX(24px); }

/* ===== Empty State ===== */
.empty-state { text-align: center; padding: 3rem 1.25rem; color: var(--text-muted); }
.empty-state-icon { font-size: 3rem; margin-bottom: 0.75rem; }
.empty-state-text { font-size: 1rem; margin-bottom: 1rem; }

/* ===== Leaderboard / Player Rows ===== */
.rank-1 { color: #E0A106; }
.rank-2 { color: #C8A96A; }
.rank-3 { color: #a07840; }
.player-row {
    display: flex; align-items: center; gap: 12px; padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}
.player-rank { font-size: 1.2rem; font-weight: 800; min-width: 32px; text-align: center; }
.player-avatar {
    width: 44px; height: 44px; border-radius: 50%;
    background: var(--accent-light); display: flex;
    align-items: center; justify-content: center;
    font-weight: 700; font-size: 1rem; color: var(--accent);
    overflow: hidden;
}
.player-avatar img { width: 100%; height: 100%; object-fit: cover; }
.player-info { flex: 1; }
.player-name { font-weight: 700; font-size: 0.95rem; }
.player-stat { font-size: 0.8rem; color: var(--text-muted); }
.player-score { font-size: 1.3rem; font-weight: 800; min-width: 48px; text-align: right; }

/* ===== Auth Pages ===== */
.auth-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 80vh; padding: 20px; width: 100%;
}
.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--bs-border-radius);
    padding: 2rem; width: 100%; max-width: 420px;
    box-shadow: 0 4px 24px rgba(31,61,43,0.10);
}
.auth-logo { text-align: center; margin-bottom: 1.5rem; }
.auth-logo-icon { font-size: 3rem; }
.auth-logo-text { font-size: 1.3rem; font-weight: 800; color: var(--adminuiux-theme-1); }
.auth-footer { text-align: center; margin-top: 1.25rem; font-size: 0.9rem; color: var(--text-secondary); }

/* ===== Day Selector / Chips ===== */
.day-selector { display: flex; flex-wrap: wrap; gap: 8px; }
.day-chip {
    padding: 10px 16px; border: 2px solid var(--border-color);
    border-radius: 24px; cursor: pointer; font-size: 0.85rem;
    font-weight: 600; transition: all var(--transition);
    user-select: none; color: var(--text-secondary);
    -webkit-tap-highlight-color: transparent;
}
.day-chip.selected { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ===== Loading Spinner ===== */
.spinner {
    display: inline-block; width: 24px; height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%; animation: gb-spin 0.8s linear infinite;
}
@keyframes gb-spin { to { transform: rotate(360deg); } }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center { display: flex; justify-content: center; padding: 3rem; }

/* ===== Utility Classes ===== */
.text-sm { font-size: 0.85rem; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-between { justify-content: space-between; }
.flex-center { align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 500px) { .grid-2 { grid-template-columns: 1fr; } }

/* ===== Link Colors ===== */
a { color: var(--adminuiux-theme-1); text-decoration: none; }
a:hover { color: var(--adminuiux-theme-1-hover); }

/* ===== Mobile-First Touch Targets ===== */
@media (max-width: 991.98px) {
    /* Ensure all interactive elements meet 44px touch target */
    .btn { min-height: 44px; }
    .btn-sm { min-height: 36px; }
    .form-input, .form-select, .form-textarea { min-height: 44px; }

    /* Content area: full-bleed on mobile */
    .gb-content-area {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
        padding-top: 56px;
    }

    .page-title { font-size: 1.15rem; }

    /* Stat cards stack better */
    div[style*="grid-template-columns: 1fr 1fr 1fr"] {
        gap: 8px !important;
    }
}

/* ===== Hide desktop sidebar on mobile (handled by d-none d-lg-block) ===== */
/* Mobile footer is already d-lg-none */

/* ===== Scorecard in-game: immersive mode ===== */
@media (max-width: 767px) {
    /* When on scorecard, minimize chrome for immersive feel */
    .scorecard-immersive .adminuiux-header .navbar {
        padding-top: 4px;
        padding-bottom: 4px;
    }
    .scorecard-immersive .adminuiux-mobile-footer {
        /* Always show footer on scorecard for quick nav */
        bottom: 0 !important;
    }
}

/* ===== Smooth scrolling & overscroll ===== */
html {
    scroll-behavior: smooth;
    overscroll-behavior-y: none;
}

/* ===== PWA standalone mode adjustments ===== */
@media (display-mode: standalone) {
    .gb-content-area {
        padding-top: 64px;
    }
    .adminuiux-mobile-footer {
        padding-bottom: calc(8px + env(safe-area-inset-bottom)) !important;
    }
}

/* ===== Details/Accordion styling (used in scorecard, game detail) ===== */
details.card { cursor: default; }
details.card summary {
    cursor: pointer; font-weight: 700; font-size: 0.95rem;
    list-style: none; display: flex; align-items: center; gap: 8px;
    -webkit-tap-highlight-color: transparent;
}
details.card summary::-webkit-details-marker { display: none; }
details.card summary::after {
    content: ''; width: 8px; height: 8px; margin-left: auto;
    border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted);
    transform: rotate(-45deg); transition: transform 0.2s ease; flex-shrink: 0;
}
details[open].card summary::after { transform: rotate(45deg); }

/* ===== AdminUIUX card overrides for Golf Buddies ===== */
.card.adminuiux-card {
    backdrop-filter: blur(15px);
}

/* ===== Consistent btn-theme = green accent ===== */
.btn-theme {
    --bs-btn-bg: var(--adminuiux-theme-1) !important;
    --bs-btn-border-color: var(--adminuiux-theme-1) !important;
    --bs-btn-hover-bg: var(--adminuiux-theme-1-hover) !important;
    --bs-btn-hover-border-color: var(--adminuiux-theme-1-hover) !important;
}

/* ===== Mobile: hide scrollbar on horizontal scroll containers ===== */
[style*="overflow-x:auto"]::-webkit-scrollbar,
[style*="overflow-x: auto"]::-webkit-scrollbar {
    display: none;
}

/* ===== Haptic-style feedback on tappable cards ===== */
@media (max-width: 991.98px) {
    a.card:active, .card[onclick]:active, .player-score-entry:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
}

/* ===== Fix for form-control inside cards (AdminUIUX override) ===== */
.card .form-control, .card .form-select {
    min-height: 44px;
}

/* ===== Ensure modals sit above mobile footer ===== */
.modal-overlay { z-index: 1100; }
.beer-alert-overlay { z-index: 1100; }

/* ===== Golf Ball Center Button (Emoji Style) ===== */
.golf-ball-btn {
    display: flex; align-items: center; justify-content: center;
    width: 60px; height: 60px; border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #fff 50%, #e4e4e4 85%, #ccc);
    box-shadow: 0 4px 16px rgba(0,0,0,0.3), inset 0 2px 4px rgba(255,255,255,0.9);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    font-size: 30px; line-height: 1;
    margin-top: -22px;
}
.golf-ball-btn:active {
    transform: scale(0.9);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* ===== Emoji Tab Bar ===== */
.gb-tab-bar { align-items: flex-end !important; }

.gb-tab {
    display: flex !important; flex-direction: column !important;
    align-items: center !important; gap: 1px !important;
    padding: 6px 8px 4px !important; position: relative;
    -webkit-tap-highlight-color: transparent;
}
.gb-tab-emoji {
    font-size: 22px; line-height: 1;
    transition: transform 0.15s ease;
}
.gb-tab.active .gb-tab-emoji {
    transform: scale(1.15);
}
.gb-tab-label {
    font-size: 10px; font-weight: 500;
    color: rgba(255,255,255,0.5); line-height: 1;
}
.gb-tab.active .gb-tab-label {
    font-weight: 700; color: #fff;
}
/* Active dot indicator */
.gb-tab.active::after {
    content: ''; position: absolute; bottom: 0;
    width: 5px; height: 5px; border-radius: 50%;
    background: #F2B705;
}
/* Tap feedback */
.gb-tab:active .gb-tab-emoji { transform: scale(0.9); }
