/*
 * MyAthlete Auth System Stylesheet
 *
 * This stylesheet adapts the Auth UI to align with the visual
 * identity of the main MyAthlete app, using consistent
 * colors, fonts, spacing, and component styles from app_theme.dart.
 */

/* --- Import Font (Using the same as Landing Page) --- */
/* @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap'); */


/* --- Base Styles & Variables (Matching MyAthlete Theme) --- */
:root {
    --bg-dark: #121212; /* MyAthlete dark background (_darkBackgroundColor) */
    --bg-darker: #111111; /* MyAthlete footer background (slightly darker) */
    
    /* Colors from app_theme.dart */
    --primary-color: #1976D2; /* MyAthlete blue (_primaryColor) */
    --accent-color: #18FFFF; /* MyAthlete cyan (_accentColor) */
    --warning-color: #FFA000; /* MyAthlete amber/pb (_pbColor) */
    
    /* Text Colors */
    --text-light: #f4f4f4; /* Softer white (near _darkOnBackgroundColor) */
    --text-on-primary: #FFFFFF; /* Text on blue buttons (_darkOnPrimaryColor) */
    --text-muted: #aaaaaa; /* Light grey for muted text (near _darkSecondaryColor) */
    
    /* UI Element Colors */
    --border-color: #444444; /* Close to dividerColor (grey.shade800) */
    --element-bg-dark: #1E1E1E; /* MyAthlete surface color (_darkSurfaceColor) */
    --input-bg-dark: #2c2c2c; /* A bit lighter than surface for inputs */

    /* Fonts & Transitions (from old CSS) */
    --font-primary: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
    --font-headings: 'Segoe UI Bold', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --transition-speed: 0.3s;
    --animation-delay: 0.15s;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px; /* Base font size */
}

body {
    font-family: var(--font-primary);
    line-height: 1.6;
    background-color: var(--bg-dark); /* Use dark background variable */
    color: var(--text-light); /* Use light text variable */
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Header (Matching MyAthlete Style) --- */
header {
    background-color: rgba(17, 17, 17, 0.8); /* Dark, slightly transparent */
    backdrop-filter: blur(5px);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: background-color var(--transition-speed) ease;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

.navbar-brand {
    color: var(--primary-color); /* Use primary color variable */
    font-size: 1.5rem;
    text-decoration: none;
    font-weight: bold;
}
.duck-accent { /* Kept class name if used elsewhere, but styling removed */
    color: var(--text-light);
    font-weight: 300;
}

.nav-links {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
}
.nav-links li {
    margin-left: 1.5rem;
}
.nav-links a, .nav-logout-btn {
    color: var(--text-light);
    text-decoration: none;
    font-size: 1em;
    font-weight: 500;
    background: none;
    border: none;
    cursor: pointer;
    transition: color var(--transition-speed) ease;
    padding: 0.5rem 0.1rem;
    position: relative;
    display: inline-block;
    vertical-align: middle;
    overflow: hidden;
}

/* Nav Link Hover Effect (Matching MyAthlete Style) */
.nav-links a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: -100%;
    width: 100%;
    height: 2px;
    background-color: var(--primary-color); /* Use primary color */
    transition: left var(--transition-speed) ease-out;
}

.nav-links a:hover::after,
.nav-links a:focus::after {
    left: 0;
}

.nav-logout-btn {
    margin-left: 1.5rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    background-color: var(--element-bg-dark);
    color: var(--text-muted);
    transition: background-color var(--transition-speed) ease, border-color var(--transition-speed) ease, color var(--transition-speed) ease;
}

.nav-logout-btn:hover {
    background-color: var(--border-color);
    border-color: var(--text-muted);
    color: var(--text-light);
}

.nav-user-email {
    color: var(--text-muted);
    font-size: 0.9em;
    margin-right: 0.75rem;
    font-weight: 400;
}


/* --- Main Content Container --- */
.container {
    flex-grow: 1;
    padding: 2rem 20px;
    max-width: 1100px;
    margin: 2rem auto;
    width: 100%;
}

/* === Card Styling (for Profile Pages) === */
.card {
    background-color: var(--element-bg-dark); /* Use element background variable */
    padding: 2rem;
    border-radius: 8px; /* Match app border-radius */
    box-shadow: 0 5px 15px rgba(25, 118, 210, 0.1); /* Blue glow */
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
    overflow: hidden;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

.card-header {
    background-color: transparent;
    padding: 0 0 1rem 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.card-header h2 {
    color: var(--primary-color); /* Use primary color variable */
    margin: 0;
    font-size: 2.2rem;
    font-weight: 600;
    font-family: var(--font-headings);
}

/* === Auth Container (Login/Register/Password Reset) === */
.auth-container {
    background-color: var(--element-bg-dark); /* Use element background variable */
    padding: 2rem;
    border-radius: 8px; /* Match app border-radius */
    box-shadow: 0 5px 15px rgba(25, 118, 210, 0.1); /* Blue glow */
    max-width: 400px;
    margin: 2rem auto;
    border: 1px solid var(--border-color);
}
.auth-container h2 {
    color: var(--primary-color); /* Use primary color variable */
    text-align: center;
    margin-bottom: 1.5rem;
    font-weight: 600;
    font-size: 2.2rem;
    font-family: var(--font-headings);
}

.auth-container p a, .auth-container > a {
    color: var(--primary-color); /* Use primary color variable */
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-speed) ease;
}
.auth-container p a:hover, .auth-container > a:hover {
    color: #1565C0; /* Darker blue on hover */
    text-decoration: underline;
}


/* === General Form Styling (Matching App Theme) === */
form p {
    margin-bottom: 1rem;
}
form label, .form-label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.95em;
}

form input[type="text"],
form input[type="email"],
form input[type="password"],
form input[type="date"],
form input[type="number"],
form select,
form textarea {
    width: 100%;
    padding: 0.8rem 1rem;
    margin-bottom: 0.5rem;
    background-color: var(--input-bg-dark); /* Use input background variable */
    border: 1px solid var(--border-color);
    color: var(--text-light);
    border-radius: 8px; /* Match app border-radius */
    box-sizing: border-box;
    font-family: inherit;
    font-size: 1em;
    transition: border-color var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
}

form input[type="text"]:focus,
form input[type="email"]:focus,
form input[type="password"]:focus,
form input[type="date"]:focus,
form input[type="number"]:focus,
form select:focus,
form textarea:focus {
    border-color: var(--primary-color); /* Use primary color */
    outline: none;
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.25); /* Use primary color in shadow */
}

form select {
    appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%231976D2%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E'); /* Updated SVG fill to blue */
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 0.8em;
    padding-right: 2.5rem;
}

form input[type="date"]::-webkit-calendar-picker-indicator {
    /* Removed filter, rely on browser default which is usually dark-aware */
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s ease-in-out;
}
form input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

/* Checkbox styling */
form input[type="checkbox"] {
    width: auto;
    margin-right: 0.5rem;
    vertical-align: middle;
    accent-color: var(--primary-color); /* Use primary color */
}
.form-check-input {
    accent-color: var(--primary-color); /* Use primary color */
}
.form-check-label {
    color: var(--text-muted);
    font-weight: normal;
}


/* For form field error messages */
.invalid-feedback.d-block, ul.errorlist {
    color: #ff6b6b; /* Keep a clear red for errors */
    font-size: 0.875em;
    margin-top: 0.25rem;
    font-weight: 500;
    list-style: none;
    padding: 0;
    margin-bottom: 0.5rem;
}
ul.errorlist li {
    padding: 0.1rem 0;
}


/* === Button Styling (Matching App Theme) === */
.btn {
    display: inline-block;
    padding: 0.8rem 1.8rem;
    border-radius: 8px; /* Match app border-radius */
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: background-color var(--transition-speed) ease, transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
    border: none;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-2px);
}
.btn:active {
    transform: translateY(-1px);
}

.btn-primary {
    background-color: var(--primary-color); /* Use primary color */
    color: var(--text-on-primary); /* Use text-on-primary color */
}
.btn-primary:hover {
    background-color: #1565C0; /* Darker blue on hover */
    box-shadow: 0 4px 10px rgba(25, 118, 210, 0.2); /* Blue glow */
}

.btn-secondary {
    background-color: var(--element-bg-dark);
    color: var(--text-light);
    border: 1px solid var(--border-color);
    text-transform: none;
    letter-spacing: normal;
    font-weight: 500;
}
.btn-secondary:hover {
    background-color: var(--border-color);
    border-color: var(--text-muted);
    color: var(--text-light);
    box-shadow: none;
}

/* Specific Button Colors for MFA (ensure good contrast and meaning) */
.btn-danger {
    background-color: #dc3545;
    color: white;
    border-color: #dc3545;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: bold;
}
.btn-danger:hover {
    background-color: #c82333;
    border-color: #c82333;
    box-shadow: 0 4px 10px rgba(220, 53, 69, 0.2);
}

.btn-info {
    background-color: #0d6efd;
    color: white;
    border-color: #0d6efd;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: bold;
}
.btn-info:hover {
    background-color: #0a58ca;
    border-color: #0a58ca;
    box-shadow: 0 4px 10px rgba(13, 110, 253, 0.2);
}

.btn-success {
    background-color: #198754;
    color: white;
    border-color: #198754;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: bold;
}
.btn-success:hover {
    background-color: #146c43;
    border-color: #146c43;
    box-shadow: 0 4px 10px rgba(25, 135, 84, 0.2);
}

.crispy-form-button-row .btn,
form > .btn, form > button.btn {
    margin-top: 1.5rem;
}
form .btn + .btn, form button.btn + a.btn, form a.btn + button.btn, form a.btn + a.btn {
    margin-left: 0.75rem;
}


/* === Alert Styling (Matching App Theme) === */
.alert {
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid transparent;
    border-radius: 8px; /* Match app border-radius */
    font-weight: 500;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.alert-dismissible .btn-close {
    margin-left: auto;
    padding: 1rem;
}
.btn-close {
    background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23f4f4f4'%3e%3cpath d='M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z'/%3E%3C/svg%3E") center/1em auto no-repeat;
    border: 0;
    border-radius: .25rem;
    opacity: .8;
    transition: opacity 0.2s ease-in-out;
}
.btn-close:hover {
    opacity: 1;
}

.alert-success {
    color: #d1e7dd;
    background-color: #0f5132;
    border-left: 5px solid #198754;
}
.alert-error, .alert-danger {
    color: #f8d7da;
    background-color: #842029;
    border-left: 5px solid #dc3545;
}
.alert-warning {
    color: #fff3cd;
    background-color: #664d03;
    border-left: 5px solid var(--warning-color); /* Use warning color */
}
.alert-info {
    color: #cff4fc;
    background-color: #087990;
    border-left: 5px solid #0dcaf0;
}


/* === Footer Styling (Matching App Theme) === */
footer {
    text-align: center;
    padding: 1.5rem 0;
    background-color: var(--bg-darker);
    border-top: 1px solid var(--border-color);
    font-size: 0.9em;
    color: var(--text-muted);
    margin-top: 4rem;
}

/* === Profile View Specifics (`profile_view.html`) === */
.card-body .row dt {
    color: var(--text-muted);
    font-weight: bold;
    margin-bottom: 0.5rem;
}
.card-body .row dd {
    color: var(--text-light);
    margin-bottom: 1.5rem;
    font-weight: 400;
}
@media (min-width: 768px) {
    .card-body .row dt {
        padding-right: 1rem;
    }
    .card-body .row dd {
        margin-left: 0;
    }
}

.profile-actions .btn {
    margin-top: 1rem;
}
.profile-actions .btn:not(:last-child) {
    margin-right: 0.75rem;
}


/* === QR Code, Setup Key, OTP Input === */
.qr-code-container {
    margin: 20px auto;
    padding: 15px;
    background-color: var(--text-light); /* Keep white for QR code */
    display: inline-block;
    border-radius: 8px; /* Match app border-radius */
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}
.qr-code-container svg {
    display: block;
    width: 200px;
    height: 200px;
}
.setup-key-container {
    margin-top: 1.5rem;
    font-size: 1em;
    text-align: center;
}
.setup-key-container code {
    background-color: var(--input-bg-dark);
    padding: 8px 12px;
    border-radius: 8px; /* Match app border-radius */
    word-break: break-all;
    color: var(--accent-color); /* Use accent color (cyan) */
    border: 1px solid var(--border-color);
    display: inline-block;
    margin-top: 0.5rem;
    font-weight: 600;
}
.form-control-otp, input.form-control-otp {
    display: block;
    margin: 1rem auto;
    max-width: 200px;
    text-align: center;
    font-size: 1.8em;
    letter-spacing: 0.4em;
    font-weight: 600;
    color: var(--accent-color); /* Use accent color (cyan) */
    background-color: var(--input-bg-dark) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 8px; /* Match app border-radius */
    padding: 0.8rem 0.5rem;
    box-sizing: border-box;
    transition: border-color var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
}
.form-control-otp:focus, input.form-control-otp:focus {
    border-color: var(--primary-color) !important; /* Focus with primary blue */
    box-shadow: 0 0 8px rgba(25, 118, 210, 0.6) !important; /* Blue glow */
    outline: none;
}


/* === Utility Classes === */
.mt-3 { margin-top: 1rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.text-center { text-align: center; }


/* MFA Page Card (Similar to .card but specific for MFA views) */
.mfa-page-card {
    background-color: var(--element-bg-dark);
    padding: 2rem;
    border-radius: 8px; /* Match app border-radius */
    box-shadow: 0 5px 15px rgba(25, 118, 210, 0.1); /* Blue glow */
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}
.mfa-page-card h2,
.container.mt-4 > h2 {
    color: var(--primary-color); /* Use primary color */
    margin-bottom: 1.5rem;
    font-weight: 600;
    font-size: 2.2rem;
    font-family: var(--font-headings);
    text-align: left;
}

/* List Group (for backup codes) */
.list-group {
    border-radius: 8px; /* Match app border-radius */
    overflow: hidden;
    margin-top: 1.5rem;
}
.list-group-item {
    background-color: var(--input-bg-dark);
    border-color: var(--border-color);
    color: var(--text-light);
    padding: 1rem 1.25rem;
    font-weight: 500;
}
.list-group-item.font-monospace {
    font-family: 'SFMono-Regular', Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 1.1em;
    color: var(--accent-color); /* Use accent color (cyan) */
    text-align: center;
    letter-spacing: 2px;
    background-color: var(--input-bg-dark);
    border-color: var(--border-color);
}
.list-group-flush .list-group-item {
    border-right-width: 0;
    border-left-width: 0;
    border-radius: 0;
}
.list-group-item:first-child {
    border-top-left-radius: inherit;
    border-top-right-radius: inherit;
}
.list-group-item:last-child {
    border-bottom-left-radius: inherit;
    border-bottom-right-radius: inherit;
}

/* Card header adjustments for success state in backup codes */
.card-header.bg-success {
    background-color: #198754 !important;
    color: var(--text-light) !important;
    border-bottom: 1px solid #146c43;
    font-weight: 600;
}

/* MFA Setup TOTP Page Specifics (mfa_setup_totp.html) */
.mfa-setup-container .qr-code-container,
.mfa-setup-container .setup-key-container {
    text-align: center;
    margin-bottom: 2rem;
}
#copy-status {
    font-size: 0.9em;
    margin-top: 0.75rem;
    height: 1.5em;
    text-align: center;
    transition: opacity var(--transition-speed) ease-in-out, color var(--transition-speed) ease-in-out;
    font-weight: 500;
}
#copy-status:empty {
    opacity: 0;
}
#copy-status.success {
    color: #198754;
    opacity: 1;
}
#copy-status.error {
    color: #dc3545;
    opacity: 1;
}


/* MFA Status Page Specifics (mfa_status.html) */
.mfa-status-container h4 {
    color: var(--primary-color); /* Use primary color */
    margin-top: 2rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
    font-weight: 600;
    font-size: 1.5rem;
    font-family: var(--font-headings);
    text-align: left;
}
.mfa-status-container h4:first-of-type {
    margin-top: 0;
}
.mfa-status-container ul {
    list-style: none;
    padding-left: 0;
    margin-bottom: 1.5rem;
}
.mfa-status-container ul li {
    background-color: var(--input-bg-dark);
    padding: 1rem 1.25rem;
    border-radius: 8px; /* Match app border-radius */
    margin-bottom: 0.5rem;
    color: var(--text-light);
    font-size: 0.95em;
    border: 1px solid var(--border-color);
}
.mfa-status-container p strong {
    color: var(--primary-color); /* Use primary color */
    font-weight: 600;
}


/* --- Responsiveness (Matching Landing Page Breakpoints) --- */
@media (max-width: 768px) {
    html { font-size: 15px; }

    .navbar {
        flex-direction: column;
        align-items: center;
        padding: 0 15px;
    }
    .nav-links {
        margin-top: 1rem;
        justify-content: center;
        flex-wrap: wrap;
    }
    .nav-links li {
        margin: 0.3rem 0.8rem;
    }
    .nav-user-email {
        margin-right: 0;
        margin-bottom: 0.5rem;
        display: block;
        text-align: center;
    }
    .nav-logout-btn {
        margin-left: 0;
        margin-top: 0.5rem;
    }


    .container {
        padding: 1.5rem 15px;
        margin: 1.5rem auto;
    }

    .card, .mfa-page-card {
        padding: 1.5rem;
        max-width: 100%;
    }

    .auth-container {
        padding: 1.5rem;
        max-width: 100%;
    }

    .card-header h2, .mfa-page-card h2, .container.mt-4 > h2, .auth-container h2 {
        font-size: 1.8rem;
    }

    .btn {
        padding: 0.7rem 1.5rem;
        font-size: 0.9rem;
        letter-spacing: normal;
    }
    .btn-primary, .btn-danger, .btn-info, .btn-success {
        letter-spacing: 0.5px;
    }

    .card-body .row dt {
        margin-bottom: 0.25rem;
        text-align: left;
    }
    .card-body .row dd {
        margin-bottom: 1rem;
    }
    @media (min-width: 768px) {
        .card-body .row dt {
            padding-right: 1rem;
        }
        .card-body .row dd {
            margin-left: 0;
        }
    }


    .qr-code-container svg {
        width: 150px;
        height: 150px;
    }

    .form-control-otp, input.form-control-otp {
        font-size: 1.4em;
        letter-spacing: 0.3em;
        max-width: 180px;
    }
}

@media (max-width: 480px) {
    html { font-size: 14px; }

    .navbar {
        padding: 0 10px;
    }
    .nav-links li {
        margin: 0.2rem 0.5rem;
    }

    .container {
        padding: 1rem 10px;
        margin: 1rem auto;
    }

    .card, .mfa-page-card, .auth-container {
        padding: 1rem;
    }

    .card-header h2, .mfa-page-card h2, .container.mt-4 > h2, .auth-container h2 {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }

    .btn {
        padding: 0.6rem 1.2rem;
        font-size: 0.85rem;
    }

    .list-group-item {
        padding: 0.8rem 1rem;
    }
    .list-group-item.font-monospace {
        font-size: 1em;
        letter-spacing: 1.5px;
    }

    .mfa-status-container h4 {
        font-size: 1.2rem;
        margin-bottom: 0.75rem;
        padding-bottom: 0.5rem;
    }
}
