/* Base CSS - Universal Styles */

/* 1. Colors & Variables */
:root {
    --bg-main: #0F0F0F;
    --bg-card: #1A1A1A;
    --text-main: #E0E0E0;
    --color-accent: #A3B18A;
    --border-main: #333333;
    --color-error: #FF6B6B;
    --success-color: #4CAF50;
}

/* 2. Reset & Body */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    margin: 0;
}

body.no-scroll {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* 3. Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    margin: 0 0 1rem;
    color: #fff;
    line-height: 1.2;
}

h1 {
    font-size: 1.8rem;
    font-weight: 700;
}

h2 {
    font-size: 1.5rem;
    font-weight: 400;
}

h3 {
    font-size: 1.2rem;
    font-weight: 700;
}

p {
    margin: 0 0 1rem;
    line-height: 1.6;
}

/* Mobile Typography Scale */
@media (max-width: 768px) {
    body {
        font-size: 0.75rem;
    }

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 0.9rem;
    }

    h3 {
        font-size: 0.85rem;
    }

    p {
        font-size: 0.75rem;
    }
}

/* 4. Utilities */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
}

/* 5. Buttons */
.btn {
    padding: 1rem 2.5rem;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 50px;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    background: transparent;
    color: #fff;
}

.btn-primary {
    background: var(--color-accent);
    color: #0F0F0F;
    border: 1px solid var(--color-accent);
}

.btn-primary:hover {
    background: transparent;
    color: var(--color-accent);
}

.btn-outline {
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--border-main);
}

.btn-outline:hover {
    border-color: var(--text-main);
}

.btn-delete {
    color: #ff4444;
    border: 1px solid rgba(255, 68, 68, 0.3);
    background: transparent;
}

.btn-delete:hover {
    background: rgba(255, 68, 68, 0.1);
}

@media (max-width: 768px) {
    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.75rem;
    }
}

/* 6. Forms */
.form-group,
.fields-group {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-bottom: 1.2rem;
}

.field-label,
.form-label {
    display: block;
    margin-bottom: 0.4rem;
    color: #bbb;
    font-size: 0.95rem;
}

.form-input,
.form-select,
.form-textarea {
    background: transparent;
    border: 1px solid var(--border-main);
    color: var(--text-main);
    padding: 0.8rem;
    font-size: 0.95rem;
    border-radius: 4px;
    width: 100%;
    transition: border-color 0.3s ease;
    font-family: inherit;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--color-accent);
}

@media (max-width: 768px) {

    .field-label,
    .form-label {
        font-size: 0.75rem;
    }

    .form-input,
    .form-select,
    .form-textarea {
        padding: 0.8rem;
        font-size: 0.75rem;
    }
}

/* 7. Cards */
.card,
.data-card,
.doc-card {
    background: var(--bg-card);
    border: 1px solid var(--border-main);
    border-radius: 8px;
    padding: 1.5rem;
    transition: transform 0.2s, border-color 0.2s;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    box-sizing: border-box;
    height: 100%;
}

.card:hover,
.doc-card:hover {
    border-color: var(--color-accent);
}

@media (max-width: 768px) {

    .card,
    .data-card,
    .doc-card {
        padding: 1rem;
    }
}

/* 8. Modals Service */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

/* Global Modal Flexbox Layout */
.modal-content {
    background: var(--bg-card);
    width: 90%;
    max-width: 650px;
    max-height: 90vh;
    border: 1px solid var(--border-main);
    border-radius: 12px;
    position: relative;

    /* Flex Column Structure */
    display: flex;
    flex-direction: column;
    padding: 0;
    /* Remove container padding -> Move to children */
    overflow: hidden;
    /* Clip everything */
}

/* Header Config */
.modal-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0;
    padding: 1.5rem;
    flex-shrink: 0;
    /* Never shrink */
    border-bottom: 1px solid var(--border-main);
}

.modal-title {
    margin: 0;
    font-size: 1.5rem;
    color: #fff;
    line-height: 1.2;
}

.modal-close {
    cursor: pointer;
    font-size: 1.5rem;
    color: #888;
    padding: 0.5rem;
    /* Increased touch target */
}

.modal-close:hover {
    color: #fff;
}

/* Scrollable Content */
.modal-content>div:not(.modal-header-row):not(.tabs-nav),
.modal-content>form,
#view-lib,
#view-custom,
#view-personal,
#view-params {
    flex: 1;
    /* Take remaining space */
    overflow-y: auto;
    /* Scroll internally */
    padding: 1.5rem;
    min-height: 0;
    /* Critical for flex scrolling */
}

/* Tabs inside Modal */
.modal-content .tabs-nav {
    flex-shrink: 0;
    margin: 0;
    border-radius: 0;
    border-bottom: 1px solid var(--border-main);
    padding: 0.5rem 1.5rem;
    background: transparent;
    /* Changed from var(--bg-card) */
}

@media (max-width: 768px) {
    .modal-content {
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        border-radius: 0;
        border: none;
        /* Padding stays 0 from global */
    }

    .modal-title {
        font-size: 1.2rem;
    }

    .modal-header-row {
        padding: 1rem;
        /* Smaller padding on mobile */
    }

    .modal-content>div:not(.modal-header-row):not(.tabs-nav),
    .modal-content>form,
    #view-lib,
    #view-custom,
    #view-personal,
    #view-params {
        padding: 1rem;
        -webkit-overflow-scrolling: touch;
        /* Add back for mobile scrolling */
    }

    .tabs-nav {
        padding: 0 1rem;
        /* Adjust padding since background is gone */
        flex-shrink: 0;
        margin: 0;
        border-radius: 0;
        background: transparent;
        position: static;
        z-index: auto;
        border-bottom: 1px solid var(--border-main);
        overflow-x: auto;
    }

    .tab-btn {
        flex: 0 0 auto;
        min-width: 30%;
        padding: 0.6rem 1rem;
        font-size: 0.8rem;
    }

    .tab-text {
        display: none;
    }

    .tab-icon {
        display: inline-block;
        line-height: 0;
    }
}

/* 9. Animations */
.animate-in {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.6s forwards;
}

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

/* 10. Tabs */
.tabs-nav {
    display: flex;
    background: transparent;
    /* Removed bg-card */
    padding: 0.5rem 0;
    /* Removed horizontal padding */
    border-radius: 0;
    /* Removed radius */
    margin-bottom: 2rem;
    gap: 0.5rem;
    overflow-x: auto;
    scrollbar-width: none;
    /* Hide scrollbar Firefox */
}

.tabs-nav::-webkit-scrollbar {
    display: none;
    /* Hide scrollbar Chrome/Safari */
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: #888;
    padding: 0.8rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    text-align: center;
    white-space: nowrap;
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #ccc;
}

.tab-btn.active {
    background: var(--color-accent);
    color: #111;
    font-weight: 800;
}


/* 11. Navigation (Merged from style.css) */
/* Header Styles */
.dashboard-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(15, 15, 15, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--border-main);
    margin-bottom: 2rem;
}

.header-main {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.header-title-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-title {
    font-size: 1.5rem;
    margin: 0;
}

.client-id {
    font-family: monospace;
    color: var(--color-accent);
    background: rgba(255, 217, 61, 0.1);
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.client-id:hover {
    background: rgba(255, 217, 61, 0.2);
}

.trainer-badge {
    background: #FFD93D;
    color: #000;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

@media (max-width: 768px) {
    .dashboard-header {
        padding: 0.8rem 1rem !important;
        margin: 0 -1rem 1.5rem -1rem !important;
    }

    .header-title {
        display: none !important;
    }
}

/* Trainer Mode - Client ID Badge */
.dashboard-header.trainer-mode .client-id {
    background-color: #4A0404;
    border: 1px solid #660000;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
}

/* Hamburger Menu Styles */
.header-menu-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    margin-right: 0.5rem;
    line-height: 1;
}

.nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.nav-overlay.active {
    opacity: 1;
    visibility: visible;
}

.nav-menu {
    position: fixed;
    top: 0;
    right: 0;
    left: auto;
    width: 280px;
    height: 100%;
    background: #1a1a1a;
    z-index: 999;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border-main);
    border-right: none;
}

.nav-menu.active {
    transform: translateX(0);
}

@media (max-width: 768px) {
    .nav-menu {
        width: 100%;
        border-left: none;
    }
}

.nav-header {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-main);
}

.nav-logo {
    font-weight: bold;
    font-size: 1.2rem;
    color: #fff;
}

.nav-close {
    background: none;
    border: none;
    color: #888;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.2rem;
    line-height: 1;
}

.nav-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.nav-group {
    margin-bottom: 1.5rem;
}

/* 20. Tab Navigation (Shared) */
.tabs-nav {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-main);
    padding-bottom: 1rem;
    overflow-x: auto;
}

.tab-btn {
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    /* Standard rounded corners, not pill */
    background: rgba(255, 255, 255, 0.05);
    /* Dark filled background */
    border: 1px solid transparent;
    /* No visible border by default */
    color: #888;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.tab-btn.active {
    background: var(--color-accent);
    color: #0F0F0F;
    border-color: var(--color-accent);
    font-weight: 600;
}

.nav-group-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #666;
    margin-bottom: 0.5rem;
    padding-left: 0.5rem;
    font-weight: bold;
    letter-spacing: 0.05em;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: #ccc;
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 0.2rem;
    transition: background 0.2s;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.nav-item.main {
    font-weight: bold;
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
    margin-bottom: 1.5rem;
}

.nav-item.logout {
    color: #ff6b6b;
}

.nav-item.logout:hover {
    background: rgba(255, 107, 107, 0.1);
}

.nav-icon {
    margin-right: 0.8rem;
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.nav-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border-main);
}

/* Hide desktop buttons on mobile if needed, or adjust */
@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }
}

.header-back-link {
    color: #888;
    text-decoration: none;
    font-size: 1.5rem;
    margin-right: 1rem;
    padding: 0.2rem;
    line-height: 1;
    display: inline-block;
}

/* 12. Progress Bars & Brief Header */
.wizard-header {
    margin-bottom: 3rem;
    text-align: center;
}

.logo {
    font-size: 1.2rem;
    letter-spacing: 0.2em;
    margin-bottom: 2rem;
    color: var(--color-accent);
    text-transform: uppercase;
}

.progress-bar {
    height: 2px;
    background: var(--border-main);
    width: 100%;
    margin-bottom: 1rem;
    position: relative;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--color-accent);
    width: 0%;
    transition: width 0.5s ease;
}

.step-counter {
    font-size: 0.9rem;
    color: #888;
}

/* 13. Wizard / Form Steps */
.wizard-form {
    position: relative;
    flex: 1;
}

.wizard-step {
    display: none;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.wizard-step.active {
    display: block;
    opacity: 1;
}

.step-title {
    font-size: 2.5rem;
    font-weight: 300;
    margin-bottom: 2rem;
    color: var(--text-main);
}

@media (max-width: 768px) {
    .step-title {
        font-size: 1.5rem !important;
    }
}

.step-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

/* 14. Custom Form Inputs (Checkboxes, Scales) */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.checkbox-option {
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    padding: 0.8rem;
    border: 1px solid var(--border-main);
    border-radius: 4px;
    transition: all 0.3s ease;
}

.checkbox-option:hover {
    border-color: #666;
}

.checkbox-option input {
    display: none;
}

.checkbox-custom {
    width: 20px;
    height: 20px;
    border: 1px solid #666;
    border-radius: 2px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.checkbox-option input:checked+.checkbox-custom {
    background: var(--color-accent);
    border-color: var(--color-accent);
}

.checkbox-option input:checked+.checkbox-custom::after {
    content: '✓';
    color: #000;
    font-size: 14px;
}

.checkbox-option input:checked~.checkbox-label {
    color: var(--color-accent);
}

/* Scale Inputs */
.scale-group {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
}

.scale-option {
    cursor: pointer;
    flex: 1;
}

.scale-option input {
    display: none;
}

.scale-number {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 50px;
    border: 1px solid var(--border-main);
    border-radius: 4px;
    transition: all 0.3s ease;
    font-size: 1.1rem;
}

.scale-option input:checked+.scale-number {
    background: var(--color-accent);
    color: #0F0F0F;
    border-color: var(--color-accent);
}

/* 15. Success & Status Screens */
.success-step-container {
    text-align: center;
    padding: 2rem;
}

.success-title {
    margin-bottom: 1rem;
}

.success-description {
    color: #888;
    margin-bottom: 2rem;
}

.success-card {
    background: rgba(255, 255, 255, 0.05);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    border: 1px solid var(--border-main);
    max-width: 500px;
    margin: 0 auto 2rem;
}

.success-warning {
    color: #FFD93D;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    display: flex;
    align-items: start;
    gap: 0.5rem;
    text-align: left;
}

.warning-icon {
    font-size: 1.2rem;
}

.copy-row {
    display: flex;
    gap: 0.5rem;
    margin: 0 auto;
}

.success-id-input {
    width: 100%;
    padding: 0.8rem;
    background: #000;
    border: 1px solid #333;
    color: #fff;
    border-radius: 4px;
    font-family: monospace;
    text-align: center;
    font-size: 1.1rem;
}

.btn-copy-success {
    padding: 0 1.5rem;
    white-space: nowrap;
}

.copy-msg-success {
    color: #6BCB77;
    font-size: 0.8rem;
    margin-top: 0.5rem;
    height: 1.2em;
    opacity: 0;
    transition: opacity 0.3s;
}

.btn-start-analysis {
    width: 100%;
    max-width: 300px;
}

.analysis-time-estimate {
    margin-top: 1rem;
    font-size: 0.8rem;
    color: #666;
}

/* 16. Data Tables */
.measurements-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.measurements-table th,
.measurements-table td {
    padding: 1rem;
    border: 1px solid var(--border-main);
    text-align: left;
    white-space: nowrap;
}

.measurements-table th {
    background: var(--bg-card);
    color: #888;
}

.input-cell {
    background: transparent;
    border: none;
    color: #fff;
    width: 100%;
    font-family: inherit;
    min-width: 60px;
}

.input-cell:focus {
    outline: none;
    color: var(--color-accent);
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}

@media (max-width: 768px) {

    .measurements-table th,
    .measurements-table td {
        padding: 0.75rem;
        font-size: 0.75rem;
    }

    .input-cell {
        font-size: 0.75rem;
    }
}

/* 17. AI Chat Components */
.message {
    max-width: 80%;
    padding: 1rem;
    border-radius: 12px;
    line-height: 1.4;
    margin-bottom: 0.5rem;
}

.ai-message {
    background: var(--bg-card);
    border: 1px solid var(--border-main);
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

.user-message {
    background: var(--color-accent);
    color: #000;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.typing-indicator {
    font-style: italic;
    color: #888;
    font-size: 0.8rem;
    margin-left: 1rem;
}

/* 18. Validation */
.input-error {
    border-color: var(--color-error) !important;
}

/* 19. Floating Action Button */
.floating-btn-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 100;
}

.floating-btn-container .btn {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    padding: 1rem 1.5rem;
    font-size: 1rem;
}

@media (max-width: 768px) {
    .floating-btn-container {
        bottom: 1rem;
        right: 1rem;
    }

    .floating-btn-container .btn {
        padding: 0.8rem 1.2rem;
        font-size: 0.9rem;
    }
}