/**
 * Base Design System
 * 
 * Provides CSS custom properties and utility classes for building
 * modern, professional UIs. The agent will extend this as needed.
 */
@tailwind base;
@tailwind components;
@tailwind utilities;

/* ===== DESIGN TOKENS ===== */
:root {
    /* Primary Palette - Deep indigo to violet */
    --color-primary-50: #eef2ff;
    --color-primary-100: #e0e7ff;
    --color-primary-200: #c7d2fe;
    --color-primary-500: #6366f1;
    --color-primary-600: #4f46e5;
    --color-primary-700: #4338ca;

    /* Accent - Vibrant cyan */
    --color-accent-400: #22d3ee;
    --color-accent-500: #06b6d4;

    /* Neutral */
    --color-neutral-50: #fafafa;
    --color-neutral-100: #f4f4f5;
    --color-neutral-200: #e4e4e7;
    --color-neutral-300: #d4d4d8;
    --color-neutral-600: #52525b;
    --color-neutral-700: #3f3f46;
    --color-neutral-800: #27272a;
    --color-neutral-900: #18181b;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, var(--color-primary-600), var(--color-primary-500), var(--color-accent-500));
    --gradient-card: linear-gradient(145deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.6) 100%);
    --gradient-sports: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);
    --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --gradient-warning: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --gradient-danger: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    --gradient-court: linear-gradient(to bottom, #4338ca, #3730a3);
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.3);

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-12: 3rem;
    --space-16: 4rem;

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;
}



/* ===== GLOBAL STYLES ===== */
body {
    @apply font-sans bg-gray-50 text-gray-900 antialiased;
    -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4, h5, h6 {
    @apply tracking-tight;
}

/* Form accessibility and touch friendliness */
input, select, textarea {
    @apply text-base md:text-sm transition-all duration-200;
}

button, a {
    @apply cursor-pointer select-none;
}

.glass {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.glass-dark {
    background: rgba(24, 24, 27, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}


/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    font-weight: 500;
    font-size: 1rem; /* Slightly larger for mobile tap targets */
    border-radius: var(--radius-lg);
    transition: all var(--transition-base);
    cursor: pointer;
    border: none;
    text-decoration: none;
    touch-action: manipulation;
}

@media (min-width: 768px) {
    .btn {
        font-size: 0.875rem;
    }
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-md), var(--shadow-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), 0 0 40px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: white;
    color: var(--color-primary-600);
    border: 2px solid var(--color-primary-200);
}

.btn-secondary:hover {
    background: var(--color-primary-50);
    border-color: var(--color-primary-500);
}

.btn-ghost {
    background: transparent;
    color: var(--color-neutral-700);
}

.btn-ghost:hover {
    background: var(--color-neutral-100);
}


/* ===== CARDS ===== */
.card {
    background: white;
    border-radius: var(--radius-xl);
    padding: var(--space-4); /* Reduced padding for mobile */
    box-shadow: var(--shadow-md);
    transition: all var(--transition-base);
}

@media (min-width: 768px) {
    .card {
        padding: var(--space-6);
    }
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.card-glass {
    background: var(--gradient-card);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-xl);
    padding: var(--space-4); /* Reduced padding for mobile */
    transition: all var(--transition-base);
}

@media (min-width: 768px) {
    .card-glass {
        padding: var(--space-6);
    }
}

.card-glass:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}


/* ===== NAVIGATION ===== */
.nav-link {
    position: relative;
    padding: var(--space-2) var(--space-3);
    color: var(--color-neutral-600);
    font-weight: 500;
    font-size: 0.875rem;
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
}

.nav-link:hover {
    color: var(--color-primary-600);
    background: var(--color-primary-50);
}

.nav-link.active {
    color: var(--color-primary-600);
}
/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-primary { background: var(--color-primary-100); color: var(--color-primary-700); }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }

/* ===== COURT BACKGROUNDS ===== */
.bg-court {
    background-color: #312e81;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 20px 20px;
}

/* ===== TYPOGRAPHY ===== */
.font-display {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    letter-spacing: -0.02em;
}
/* ===== ANIMATIONS ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes pulse-glow {

    0%,
    100% {
        box-shadow: var(--shadow-md), 0 0 20px rgba(99, 102, 241, 0.2);
    }

    50% {
        box-shadow: var(--shadow-lg), 0 0 40px rgba(99, 102, 241, 0.4);
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.5s ease-out forwards;
}

.animate-fade-in {
    animation: fadeIn 0.3s ease-out forwards;
}

.animate-pulse-glow {
    animation: pulse-glow 2s ease-in-out infinite;
}


/* ===== UTILITIES ===== */
.text-gradient {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 var(--space-6);
}

/* ===== MARKDOWN FORMATTING ===== */
.markdown-content {
    line-height: 1.7;
    color: #374151;
}

.markdown-content h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: #1e1b4b;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.35rem;
    border-bottom: 2px solid #e0e7ff;
}

.markdown-content h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: #1e1b4b;
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
}

.markdown-content h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #312e81;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.markdown-content h4 {
    font-size: 1rem;
    font-weight: 700;
    color: #374151;
    margin-top: 0.75rem;
    margin-bottom: 0.25rem;
}

.markdown-content p {
    margin-bottom: 0.85rem;
}

.markdown-content ul {
    list-style-type: disc;
    padding-left: 1.5rem;
    margin-bottom: 0.85rem;
}

.markdown-content ol {
    list-style-type: decimal;
    padding-left: 1.5rem;
    margin-bottom: 0.85rem;
}

.markdown-content li {
    margin-bottom: 0.25rem;
}

.markdown-content blockquote {
    border-left: 4px solid #6366f1;
    background-color: #f5f3ff;
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    border-radius: 0.5rem;
    font-style: italic;
    color: #4338ca;
}

.markdown-content code {
    background-color: #f3f4f6;
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    font-size: 0.875em;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    color: #4f46e5;
}

.markdown-content pre {
    background-color: #1e1b4b;
    color: #e0e7ff;
    padding: 1rem;
    border-radius: 0.75rem;
    overflow-x: auto;
    margin-bottom: 1rem;
}

.markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.markdown-content th, .markdown-content td {
    border: 1px solid #e5e7eb;
    padding: 0.5rem 0.75rem;
    text-align: left;
}

.markdown-content th {
    background-color: #f9fafb;
    font-weight: 600;
}

.markdown-content a {
    color: #4f46e5;
    text-decoration: underline;
}

.markdown-content hr {
    border: 0;
    height: 1px;
    background: #e5e7eb;
    margin: 1.25rem 0;
}


/* Global mobile overflow prevention */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* ===== CUSTOM SLEEK SCROLLBAR SYSTEM ===== */
/* Modern sleek scrollbars for Chromium / Firefox / WebKit on Windows & all platforms */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.3) transparent;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.28);
    border-radius: 9999px;
    transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.55);
}

/* Specific sleek dark sidebar scrollbar */
.sidebar-scroll {
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.22) transparent;
    -ms-overflow-style: -ms-autohiding-scrollbar;
}

.sidebar-scroll::-webkit-scrollbar {
    width: 4px;
}

.sidebar-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.22);
    border-radius: 9999px;
}

.sidebar-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.48);
}

/* Complete scrollbar elimination for pure, seamless panels while keeping scroll behavior */
.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}

/* ===== BUTTON HELPERS & GRADIENT FALLBACKS ===== */
.btn-auto-schedule {
    background-color: #4f46e5 !important;
    background-image: linear-gradient(135deg, #6366f1 0%, #4338ca 100%) !important;
    color: #ffffff !important;
}
.btn-auto-schedule:hover {
    background-image: linear-gradient(135deg, #4f46e5 0%, #3730a3 100%) !important;
}

.btn-amber-gradient {
    background-color: #f59e0b !important;
    background-image: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
    color: #ffffff !important;
}
.btn-amber-gradient:hover {
    background-image: linear-gradient(135deg, #d97706 0%, #b45309 100%) !important;
}

/* Fallbacks for Tailwind gradient utility classes if not in output.css */
.to-orange-600 {
    --tw-gradient-to: #ea580c var(--tw-gradient-to-position, ) !important;
}
.to-orange-700 {
    --tw-gradient-to: #c2410c var(--tw-gradient-to-position, ) !important;
}
.from-violet-600 {
    --tw-gradient-from: #7c3aed var(--tw-gradient-from-position, ) !important;
    --tw-gradient-to: rgb(124 58 237 / 0) var(--tw-gradient-to-position, ) !important;
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to) !important;
}
.to-indigo-600 {
    --tw-gradient-to: #4f46e5 var(--tw-gradient-to-position, ) !important;
}

/* Safe area padding for mobile bottom bar */
.safe-area-pb {
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom, 0.5rem));
}

/* ==========================================================================
   Desktop / Mobile Responsive Layout Rules
   ========================================================================== */

/* Desktop screens (>= 768px) */
@media (min-width: 768px) {
    .app-sidebar-desktop {
        display: flex !important;
        flex-direction: column !important;
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 16rem !important; /* 256px */
        z-index: 30 !important;
        background-color: #ffffff !important;
        border-right: 1px solid rgba(226, 232, 240, 0.9) !important;
    }

    .app-main-layout {
        padding-left: 16rem !important; /* 256px */
        width: 100% !important;
        min-height: 100vh !important;
    }

    .app-desktop-only {
        display: flex !important;
        position: fixed !important;
        top: 1rem !important;
        right: 1.5rem !important;
        z-index: 40 !important;
    }

    .app-desktop-block {
        display: block !important;
    }

    .app-mobile-only,
    .app-mobile-block,
    .app-bottom-nav,
    .md\:hidden {
        display: none !important;
    }

    .md\:flex {
        display: flex !important;
    }

    .md\:block {
        display: block !important;
    }
}

/* Mobile screens (< 768px) */
@media (max-width: 767px) {
    .app-sidebar-desktop,
    .app-desktop-only,
    .app-desktop-block {
        display: none !important;
    }

    .app-main-layout {
        padding-left: 0 !important;
        width: 100% !important;
        min-height: 100vh !important;
    }

    .app-mobile-only {
        display: flex !important;
    }

    .app-mobile-block {
        display: block !important;
    }

    .app-bottom-nav {
        display: flex !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 40 !important;
    }
}

.hidden {
    display: none;
}

@media (min-width: 640px) {
    .sm\:hidden {
        display: none !important;
    }
    .sm\:inline {
        display: inline !important;
    }
    .sm\:block {
        display: block !important;
    }
    .sm\:flex {
        display: flex !important;
    }
}

/* Suppress default platform pwa banner to favor customized in-app PWA install and push experience */
#sm-client-pwa-banner,
#sm-client-ios-modal {
    display: none !important;
}

/* Responsive Shoelace dialogs for mobile vertical scrolling */
sl-dialog {
    z-index: 9999 !important;
    --sl-z-index-dialog: 9999 !important;
}

sl-dialog::part(base) {
    z-index: 9999 !important;
}

sl-dialog::part(overlay) {
    z-index: 9999 !important;
}

sl-dialog::part(panel) {
    max-height: calc(100dvh - 6rem) !important;
    max-height: calc(100vh - 6rem) !important;
    max-width: 95vw !important;
    display: flex !important;
    flex-direction: column !important;
    margin: auto auto 4.5rem auto !important;
    z-index: 10000 !important;
}

sl-dialog::part(body) {
    overflow-y: auto !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
}

sl-dialog::part(footer) {
    flex-shrink: 0 !important;
    padding: 0.75rem 1rem !important;
    background: #f8fafc !important;
    border-top: 1px solid #e2e8f0 !important;
}

@media (min-width: 768px) {
    sl-dialog::part(panel) {
        max-height: 85vh !important;
        margin: auto !important;
    }
}

/* Full-viewport Chat Container Lock (both mobile and desktop) */
body:has(#chat-messages-container),
html:has(#chat-messages-container) {
    height: 100% !important;
    max-height: 100% !important;
    overflow: hidden !important;
    width: 100% !important;
    overscroll-behavior: none !important;
}

/* Only lock position: fixed when the virtual keyboard is actively open on mobile */
html.keyboard-open,
body.keyboard-open {
    height: 100% !important;
    max-height: 100% !important;
    overflow: hidden !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    overscroll-behavior: none !important;
}

.chat-screen-layout {
    height: 100% !important;
    height: 100dvh !important;
    max-height: 100% !important;
    max-height: 100dvh !important;
    overflow: hidden !important;
}

html.keyboard-open .chat-screen-layout,
body.keyboard-open .chat-screen-layout {
    height: var(--app-viewport-height, 100dvh) !important;
    max-height: var(--app-viewport-height, 100dvh) !important;
}

/* Mobile chat bottom compensation to keep composer cleanly above bottom navigation bar when keyboard is closed */
.chat-screen-container {
    height: 100% !important;
    max-height: 100% !important;
    overflow: hidden !important;
    padding-bottom: calc(66px + env(safe-area-inset-bottom, 0px)) !important;
    box-sizing: border-box !important;
    transition: padding-bottom 0.15s ease;
}

/* When the virtual keyboard is active on mobile: hide bottom nav and remove padding */
html.keyboard-open .app-bottom-nav,
body.keyboard-open .app-bottom-nav {
    display: none !important;
    pointer-events: none !important;
    opacity: 0 !important;
}

html.keyboard-open .chat-screen-container,
body.keyboard-open .chat-screen-container {
    padding-bottom: 0 !important;
}

@media (min-width: 768px) {
    .chat-screen-container {
        padding-bottom: 0 !important;
    }
}



