/* =============================================================================
   FightPlan WASM — Design System Foundation
   Bridges coachlink-theme.css tokens into legacy --bg-*, --text-*, --primary vars.
   ============================================================================= */

/* ─── CSS Custom Properties (Design Tokens) ─────────────────────────────────── */

:root {
    /* Background surfaces — mapped from CoachLink dark theme */
    --bg-deepest:    var(--cl-bg-page,       #0E0E0E);
    --bg-default:    var(--cl-bg-subtle,      #1E1E1E);
    --bg-card:       var(--cl-bg-surface,     #161616);
    --bg-elevated:   var(--cl-bg-surface,     #161616);

    /* Primary brand — red accent from CoachLink */
    --primary:       #e40101;
    --primary-hover:  #cc0101;
    --primary-dark:   #b00101;
    --primary-deep:   #8a0101;

    /* Accent / Secondary */
    --accent:        var(--cl-blue-400, #378ADD);
    --accent-hover:  var(--cl-blue-600, #185FA5);
    --secondary:     var(--cl-amber-200, #EF9F27);

    /* Text — from CoachLink dark theme */
    --text-primary:   var(--cl-text-primary,   #F0EDE6);
    --text-secondary: var(--cl-text-secondary, #888780);
    --text-muted:     var(--cl-text-muted,     #5F5E5A);
    --text-soft:      var(--cl-gray-600,       #5F5E5A);
    --text-label:     var(--cl-text-muted,     #5F5E5A);

    /* Status colors */
    --success:     var(--cl-teal-400, #1D9E75);
    --success-bg:  var(--cl-bg-success, #0E1A14);
    --warning:     var(--cl-amber-200, #EF9F27);
    --warning-bg:  var(--cl-bg-warning, #1A1510);
    --danger:      var(--cl-red-400, #E24B4A);
    --danger-bg:   var(--cl-bg-danger, #1A0F0C);
    --info:        var(--cl-blue-400, #378ADD);
    --info-bg:     var(--cl-bg-info, #0A1520);

    /* Borders */
    --border-default:  var(--cl-border-default,  #2C2C2A);
    --border-light:    var(--cl-border-default,  #2C2C2A);
    --border-subtle:   var(--cl-surface-700,     #1E1E1E);
    --border-card:     var(--cl-border-default,  #2C2C2A);

    /* Readiness system */
    --readiness-peak:     var(--cl-blue-400,  #378ADD);
    --readiness-peak-bg:  var(--cl-bg-info,   #E6F1FB);
    --readiness-ready:    var(--cl-teal-400,  #1D9E75);
    --readiness-ready-bg: var(--cl-bg-success,#E1F5EE);
    --readiness-fair:     var(--cl-amber-200, #EF9F27);
    --readiness-fair-bg:  var(--cl-bg-warning,#FAEEDA);
    --readiness-low:      var(--cl-red-400,   #E24B4A);
    --readiness-low-bg:   var(--cl-bg-danger, #FCEBEB);

    /* Spacing — matches mobile DesignTokens.ts */
    --space-xs:   var(--cl-space-1, 4px);
    --space-sm:   var(--cl-space-2, 8px);
    --space-md:   var(--cl-space-3, 12px);
    --space-base: var(--cl-space-4, 16px);
    --space-lg:   var(--cl-space-5, 20px);
    --space-xl:   var(--cl-space-6, 24px);
    --space-2xl:  var(--cl-space-8, 32px);
    --space-3xl:  var(--cl-space-12, 48px);
    --space-4xl:  var(--cl-space-16, 64px);

    /* Border radius — mapped from CoachLink theme */
    --radius-sm:   var(--cl-radius-sm, 4px);
    --radius-md:   var(--cl-radius-md, 8px);
    --radius-base: var(--cl-radius-md, 8px);
    --radius-lg:   var(--cl-radius-lg, 12px);
    --radius-xl:   var(--cl-radius-xl, 16px);
    --radius-2xl:  var(--cl-radius-xl, 16px);
    --radius-3xl:  var(--cl-radius-xl, 16px);
    --radius-full: var(--cl-radius-pill, 9999px);

    /* Shadows — mapped from CoachLink theme */
    --shadow-soft:   var(--cl-shadow-sm);
    --shadow-card:   var(--cl-shadow-md);
    --shadow-medium: var(--cl-shadow-lg);
    --shadow-dialog: 0 20px 60px rgba(0, 0, 0, 0.18);

    /* Layout */
    --sidebar-width:   260px;
    --sidebar-collapsed-width: 0px;
    --topbar-height:   56px;

    /* Typography — mapped from CoachLink theme */
    --font-family: var(--cl-font-body, 'Barlow', system-ui, sans-serif);
    --font-display: var(--cl-font-display, 'Barlow Condensed', 'Impact', sans-serif);
    --font-mono:   var(--cl-font-mono, 'Fira Code', monospace);
}


/* ─── Base Reset & Defaults ──────────────────────────────────────────────────── */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-deepest);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}


/* ─── Typography ─────────────────────────────────────────────────────────────── */

h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.3;
}

h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.5rem;  font-weight: 700; }
h3 { font-size: 1.25rem; font-weight: 600; }
h4 { font-size: 1.0625rem; font-weight: 600; }

p {
    color: var(--text-secondary);
    line-height: 1.6;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--primary-hover);
}

small, .text-muted {
    color: var(--text-muted);
}


/* ─── Cards ──────────────────────────────────────────────────────────────────── */

.fp-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: var(--space-xl);
}


/* ─── Buttons ────────────────────────────────────────────────────────────────── */

.fp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-xl);
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    line-height: 1.4;
}

.fp-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.fp-btn-primary {
    background: var(--primary);
    color: #fff;
}

.fp-btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: 0 0 20px rgba(228, 1, 1, 0.25);
}

.fp-btn-accent {
    background: var(--accent);
    color: #fff;
}

.fp-btn-accent:hover:not(:disabled) {
    background: var(--accent-hover);
}

.fp-btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
}

.fp-btn-ghost:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.15);
}

.fp-btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}

.fp-btn-danger:hover:not(:disabled) {
    background: rgba(226, 75, 74, 0.1);
    color: #FCA5A5;
    border-color: #FCA5A5;
}

.fp-btn-lg {
    padding: var(--space-base) var(--space-2xl);
    font-size: 1rem;
    border-radius: var(--radius-base);
}

.fp-btn-sm {
    padding: var(--space-sm) var(--space-base);
    font-size: 0.8125rem;
}

.fp-btn-full {
    width: 100%;
}


/* ─── Form Inputs ────────────────────────────────────────────────────────────── */

.fp-input {
    width: 100%;
    padding: var(--space-md) var(--space-base);
    background: var(--bg-deepest);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.9375rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    outline: none;
}

.fp-input::placeholder {
    color: var(--text-muted);
}

.fp-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(112, 175, 251, 0.15);
}

.fp-input.invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.15);
}

.fp-label {
    display: block;
    margin-bottom: var(--space-sm);
    color: var(--text-label);
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}


/* ─── Status Badges ──────────────────────────────────────────────────────────── */

.fp-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px var(--space-sm);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

.fp-badge-success { background: var(--success-bg); color: var(--success); }
.fp-badge-warning { background: var(--warning-bg); color: var(--warning); }
.fp-badge-danger  { background: var(--danger-bg);  color: var(--danger);  }
.fp-badge-info    { background: var(--info-bg);     color: var(--info);    }


/* ─── Utility Classes ────────────────────────────────────────────────────────── */

.fp-divider {
    border: none;
    border-top: 1px solid var(--border-default);
    margin: var(--space-xl) 0;
}

.fp-text-primary   { color: var(--text-primary); }
.fp-text-secondary { color: var(--text-secondary); }
.fp-text-muted     { color: var(--text-muted); }

.fp-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}


/* ─── Spinner ────────────────────────────────────────────────────────────────── */

.fp-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: fp-spin 0.6s linear infinite;
}

@keyframes fp-spin {
    to { transform: rotate(360deg); }
}


/* ─── Scrollbar (WebKit) ─────────────────────────────────────────────────────── */

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-default);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.25);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* Firefox scrollbar */
* {
    scrollbar-width: auto;
    scrollbar-color: rgba(255, 255, 255, 0.25) var(--bg-default);
}


/* ─── Blazor Error UI (dark-mode override) ───────────────────────────────────── */


/* ─── Placeholder Pages ──────────────────────────────────────────────────────── */

.placeholder-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: var(--space-xl);
}

.placeholder-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
    padding: var(--space-3xl) var(--space-4xl);
    text-align: center;
    max-width: 420px;
}

.placeholder-icon {
    font-size: 56px;
    color: var(--text-soft);
    margin-bottom: var(--space-lg);
}

.placeholder-card h2 {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.placeholder-card p {
    font-size: 0.9375rem;
    color: var(--text-muted);
    margin-bottom: var(--space-xl);
    line-height: 1.5;
}


/* ─── Blazor Error UI (dark-mode override) ───────────────────────────────────── */

#blazor-error-ui {
    background: var(--danger-bg);
    color: var(--danger);
    border-top: 1px solid var(--danger);
    bottom: 0;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 10000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}


/* ─── Blazor Reconnection Modal — subtle dark toast ──────────────────────────── */

#components-reconnect-modal {
    position: fixed;
    bottom: 24px;
    right: 24px;
    top: auto !important;
    left: auto !important;
    width: auto;
    max-width: 320px;
    height: auto !important;
    background: #1a202c;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    padding: 12px 20px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    z-index: 10000;
    display: none;
    align-items: center;
    gap: 10px;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    color: #94A3B8;
    animation: reconnect-slide-in 0.25s ease-out;
}

#components-reconnect-modal[style*="display: flex"],
#components-reconnect-modal[style*="display:flex"],
#components-reconnect-modal.show {
    display: flex !important;
}

@keyframes reconnect-slide-in {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

#components-reconnect-modal::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #e40101;
    flex-shrink: 0;
    animation: reconnect-pulse 1.5s ease-in-out infinite;
}

@keyframes reconnect-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.3; }
}

#components-reconnect-modal h5,
#components-reconnect-modal h6,
#components-reconnect-modal p,
#components-reconnect-modal span,
#components-reconnect-modal div {
    color: #94A3B8;
    margin: 0;
    font-size: 0.85rem;
    font-weight: 400;
    line-height: 1.4;
}

/* Hide the default retry button chrome */
#components-reconnect-modal button {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.12);
    color: #E2E8F0;
    border-radius: 6px;
    padding: 4px 12px;
    font-size: 0.8rem;
    cursor: pointer;
    margin-left: auto;
    transition: border-color 0.15s;
}

#components-reconnect-modal button:hover {
    border-color: #e40101;
    color: #fff;
}
