@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Playfair+Display:wght@700&display=swap');

:root {
  /* Status Colors - Defined by TDD */
  --status-green: #10b981;  /* Active / OK */
  --status-yellow: #f59e0b; /* Waiting / Pause */
  --status-red: #ef4444;    /* Problem / Time Expired */
  --status-grey: #6b7280;   /* Inactive / Empty */

  /* Theme Transitions */
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: 'Outfit', system-ui, sans-serif;
}

/* DARK THEME (Default) */
.dark-theme {
  --bg-deep: #0a0c10;
  --bg-card: #151921;
  --bg-hover: #1e242f;
  --primary: #c5a059;
  --primary-light: #e2c284;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --border: rgba(197, 160, 89, 0.2);
  --glass: rgba(21, 25, 33, 0.7);
  --shadow-premium: 0 10px 30px -5px rgba(0, 0, 0, 0.5);
  --logo-filter: brightness(0) saturate(100%) invert(71%) sepia(19%) saturate(848%) hue-rotate(1deg) brightness(92%) contrast(89%); /* Golden */
}

/* LIGHT THEME */
.light-theme {
  --bg-deep: #f3f4f6;
  --bg-card: #ffffff;
  --bg-hover: #e5e7eb;
  --primary: #8a6a33;
  --primary-light: #c5a059;
  --text-main: #111827;
  --text-muted: #4b5563;
  --border: rgba(0, 0, 0, 0.1);
  --glass: rgba(255, 255, 255, 0.8);
  --shadow-premium: 0 4px 20px -2px rgba(0, 0, 0, 0.1);
  --logo-filter: brightness(0) saturate(100%) invert(0%) sepia(0%) saturate(0%) hue-rotate(0deg) brightness(0%) contrast(100%); /* Black/Original */
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg-deep);
  color: var(--text-main);
  background: radial-gradient(circle at top right, #161b22, var(--bg-deep));
  overflow-x: hidden;
}

h1, h2, h3 {
  font-family: 'Playfair Display', serif;
  letter-spacing: -0.02em;
}

/* Initial Loader with Premium Logo Animation */
.initial-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    animation: fadeOut 1s ease 1.5s forwards;
    background: radial-gradient(circle at center, #151921, #0a0c10);
}

.logo-container {
    position: relative;
    display: inline-block;
}

.loading-text {
    margin: 0;
    color: var(--primary);
    font-size: 3.5rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    font-family: 'Playfair Display', serif;
    position: relative;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 50%, #8a6a33 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0px 4px 10px rgba(197, 160, 89, 0.3));
    animation: pulseLogo 2s infinite ease-in-out;
}

.loading-text::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background: var(--primary);
    animation: lineReveal 1.5s ease forwards;
}

@keyframes pulseLogo {
    0%, 100% { filter: drop-shadow(0px 4px 10px rgba(197, 160, 89, 0.3)); transform: scale(1); }
    50% { filter: drop-shadow(0px 4px 25px rgba(197, 160, 89, 0.6)); transform: scale(1.02); }
}

@keyframes lineReveal {
    0% { width: 0; opacity: 0; }
    100% { width: 80%; opacity: 1; }
}

@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; visibility: hidden; } }

/* Attention Animations */
@keyframes shake-attention {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}

@keyframes pulse-attention {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 15px rgba(239, 68, 68, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.attention-needed {
    animation: shake-attention 0.5s cubic-bezier(.36,.07,.19,.97) both;
    border-color: var(--status-red) !important;
}

.pulse-red {
    animation: pulse-attention 2s infinite;
}

/* Global UI Components */
.glass-card {
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-premium);
  transition: var(--transition);
}

.glass-card:hover {
    border-color: var(--primary);
    box-shadow: 0 15px 35px -5px rgba(0, 0, 0, 0.6);
}

.btn-premium {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #000;
  border: none;
  padding: 10px 24px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-premium:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(197, 160, 89, 0.4);
}

/* Navigation Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 280px;
    border-right: 1px solid var(--border);
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: sticky;
    top: 0;
    height: 100vh;
    background: var(--bg-card);
}

.sidebar-logo {
    padding: 0 16px 20px 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
}

.sidebar-logo img {
    max-width: 100%;
    filter: var(--logo-filter);
    transition: var(--transition);
}

.main-content {
    flex: 1;
    padding: 40px;
}

.nav-item {
    padding: 12px 16px;
    border-radius: 10px;
    color: var(--text-muted);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
}

.nav-item:hover, .nav-item.active {
    background: var(--bg-hover);
    color: var(--primary);
}

/* Custom Premium Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-deep);
}
::-webkit-scrollbar-thumb {
  background: rgba(197, 160, 89, 0.3);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
}
.toast {
    background: var(--bg-card);
    border-left: 4px solid var(--primary);
    color: var(--text-main);
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-premium);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.toast.success { border-color: var(--accent-green); }
.toast.error { border-color: var(--accent-red); }
.toast.info { border-color: var(--secondary); }

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOutToast {
    to { opacity: 0; visibility: hidden; transform: translateX(20px); }
}

.logo-img {
    max-width: 200px;
    height: auto;
    filter: drop-shadow(0 0 10px rgba(197,160,89,0.3));
}

/* Mobile Admin Fallbacks */
.mobile-only { display: none !important; }
.desktop-only { display: block !important; }

/* Footer */
.app-footer {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.theme-toggle:hover {
    transform: rotate(15deg) scale(1.1);
    background: var(--bg-hover);
}

@media (max-width: 768px) {
    .app-container { flex-direction: column; }
    .sidebar { 
        width: 100%; 
        height: auto; 
        position: relative; 
        border-right: none; 
        border-bottom: 1px solid var(--border); 
        padding: 15px; 
    }
    .theme-toggle {
        top: 15px;
        right: 15px;
    }
    .main-content { padding: 15px; }
    .admin-grid { grid-template-columns: 1fr !important; }
    .courts-grid { grid-template-columns: 1fr !important; }
    .stats-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
    .desktop-only { display: none !important; }
    .mobile-only { display: block !important; }
    
    .glass-card[draggable="true"] { pointer-events: none; }
    
    /* Mobile Bottom Nav Specifics */
    .mobile-nav { 
        display: flex !important; 
        position: fixed; 
        bottom: 0; 
        left: 0; 
        right: 0; 
        background: var(--bg-card); 
        border-top: 1px solid var(--border); 
        padding: 10px 0; 
        z-index: 1000; 
        justify-content: space-around;
        backdrop-filter: blur(10px);
    }
    .mobile-nav .nav-item {
        background: none;
        border: none;
        color: var(--text-muted);
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        font-size: 0.65rem;
        cursor: pointer;
        padding: 5px;
    }
    .mobile-nav .nav-item.active { color: var(--primary); }
    .mobile-nav .nav-item i { width: 20px; height: 20px; }
    
    .mobile-view-section { display: none; }
    #section-courts { display: block; }
    .main-content { padding-bottom: 80px !important; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.notif-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--status-red);
    color: white;
    font-size: 0.6rem;
    padding: 2px 5px;
    border-radius: 10px;
    min-width: 15px;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}
