/**
 * LongevityCreation App Common Styles v2.0
 * Unified Light Theme - No emojis, color-differentiated navigation
 * 
 * Color Scheme:
 * - Advisor Chat: Light Blue (#3B82F6, #EFF6FF)
 * - Health Profile: Light Green (#10B981, #ECFDF5)
 * - Longevity Protocols: Soft Purple (#8B5CF6, #F5F3FF)
 */

@import url('./design-tokens.css');

:root {
    /* Light theme colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --bg-card: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.9);

    /* Text colors */
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;

    /* Page-specific accent colors */
    --color-advisor: #3B82F6;
    --color-advisor-light: #EFF6FF;
    --color-advisor-border: #BFDBFE;

    --color-profile: #10B981;
    --color-profile-light: #ECFDF5;
    --color-profile-border: #A7F3D0;

    --color-protocols: #8B5CF6;
    --color-protocols-light: #F5F3FF;
    --color-protocols-border: #DDD6FE;

    /* Library theme - Amber/Orange for knowledge & learning */
    --color-library: #F59E0B;
    --color-library-light: #FFFBEB;
    --color-library-border: #FDE68A;

    /* Default accent (advisor) */
    --accent-primary: var(--color-advisor);
    --accent-light: var(--color-advisor-light);
    --accent-border: var(--color-advisor-border);

    /* Status colors */
    --status-success: #10b981;
    --status-warning: #f59e0b;
    --status-error: #ef4444;
    --status-info: #3b82f6;

    /* Borders */
    --border-subtle: #e5e7eb;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;

    /* Typography - DM Sans */
    --font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;

    /* Sidebar */
    --sidebar-width: 220px;
}

/* Page-specific theme overrides */
body.page-advisor {
    --accent-primary: var(--color-advisor);
    --accent-light: var(--color-advisor-light);
    --accent-border: var(--color-advisor-border);
}

body.page-profile {
    --accent-primary: var(--color-profile);
    --accent-light: var(--color-profile-light);
    --accent-border: var(--color-profile-border);
}

body.page-protocols {
    --accent-primary: var(--color-protocols);
    --accent-light: var(--color-protocols-light);
    --accent-border: var(--color-protocols-border);
}

body.page-library {
    --accent-primary: var(--color-library);
    --accent-light: var(--color-library-light);
    --accent-border: var(--color-library-border);
    overflow-y: auto;
    height: auto;
}

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

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.5;
}

/* ==================== SIDEBAR ==================== */

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width var(--transition-normal);
}

.sidebar-header {
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    text-decoration: none;
    color: inherit;
}

.logo-icon {
    width: 24px;
    height: 24px;
    background: var(--text-primary);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-icon svg {
    width: 14px;
    height: 14px;
    fill: white;
}

.logo span {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Navigation Links - Color differentiated, no emojis */
.nav-links {
    padding: var(--space-md) var(--space-sm);
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    border-left: 3px solid transparent;
}

.nav-link:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Color-coded navigation links */
.nav-link[href="/advisor"],
.nav-link[href*="advisor"] {
    border-left-color: transparent;
}

.nav-link[href="/advisor"]:hover,
.nav-link[href*="advisor"]:hover,
.nav-link[href="/advisor"].active,
.nav-link[href*="advisor"].active {
    background: var(--color-advisor-light);
    color: var(--color-advisor);
    border-left-color: var(--color-advisor);
}

.nav-link[href="/profile"],
.nav-link[href*="profile"] {
    border-left-color: transparent;
}

.nav-link[href="/profile"]:hover,
.nav-link[href*="profile"]:hover,
.nav-link[href="/profile"].active,
.nav-link[href*="profile"].active {
    background: var(--color-profile-light);
    color: var(--color-profile);
    border-left-color: var(--color-profile);
}

.nav-link[href="/protocols"],
.nav-link[href*="protocols"] {
    border-left-color: transparent;
}

.nav-link[href="/protocols"]:hover,
.nav-link[href*="protocols"]:hover,
.nav-link[href="/protocols"].active,
.nav-link[href*="protocols"].active {
    background: var(--color-protocols-light);
    color: var(--color-protocols);
    border-left-color: var(--color-protocols);
}

/* Library navigation link color */
.nav-link[href="/library"],
.nav-link[href*="library"] {
    border-left-color: transparent;
}

.nav-link[href="/library"]:hover,
.nav-link[href*="library"]:hover,
.nav-link[href="/library"].active,
.nav-link[href*="library"].active {
    background: var(--color-library-light);
    color: var(--color-library);
    border-left-color: var(--color-library);
}

/* Navigation badge for new items */
.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 6px;
    margin-left: auto;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--color-library);
    color: white;
    border-radius: 4px;
}

/* New Chat / Primary Button */
.new-chat-btn,
.nav-btn.primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    width: calc(100% - 16px);
    margin: var(--space-sm) var(--space-sm) 0;
    padding: 10px 12px;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.new-chat-btn:hover,
.nav-btn.primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* Session List */
.session-list-header {
    padding: var(--space-md) var(--space-md) var(--space-sm);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.session-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 var(--space-sm);
}

.session-item {
    display: flex;
    flex-direction: column;
    padding: 10px 12px;
    margin-bottom: 4px;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.session-item:hover {
    background: var(--bg-tertiary);
}

.session-item.active {
    background: var(--accent-light);
    border-left: 3px solid var(--accent-primary);
}

.session-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Session Actions (Edit/Delete) */
.session-actions {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    gap: 4px;
}

.session-item:hover .session-actions {
    display: flex;
}

.session-action-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-muted);
    transition: all var(--transition-fast);
}

.session-action-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.session-action-btn.delete:hover {
    background: #FEE2E2;
    color: #EF4444;
    border-color: #FECACA;
}

/* Sidebar Footer */
.sidebar-footer {
    margin-top: auto;
    padding: var(--space-md);
    border-top: 1px solid var(--border-subtle);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-tertiary);
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==================== MAIN CONTENT ==================== */

.main-content,
.main-chat,
.main-workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
    position: relative;
    width: 100%;
}

/* ==================== AUTH SCREENS ==================== */

.auth-check-screen,
.not-auth-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 20px;
    background: var(--bg-primary);
    z-index: 10;
}

.spinner-large {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-subtle);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.not-auth-card {
    max-width: 360px;
    padding: 40px 32px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.not-auth-card h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.not-auth-card p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.btn-signin {
    padding: 10px 20px;
    background: var(--text-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: all var(--transition-fast);
}

.btn-signin:hover {
    background: #374151;
    transform: translateY(-1px);
}

/* ==================== CARDS ==================== */

.glass-card,
.profile-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.card-title-block h1,
.card-title-block h2 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 4px 0;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 10px;
    color: var(--text-muted);
    margin: 0 0 4px 0;
}

.card-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0;
}

/* ==================== MODALS ==================== */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-card);
    padding: 28px;
    border-radius: 12px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    position: relative;
    box-shadow: var(--shadow-lg);
    max-height: 80vh;
    overflow-y: auto;
}

.modal-content.modal-large {
    max-width: 560px;
}

.close-modal {
    position: absolute;
    right: 16px;
    top: 16px;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}

.close-modal:hover {
    color: var(--text-primary);
}

.modal-content h2 {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.modal-content p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* ==================== FORM ELEMENTS ==================== */

.input-field {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    font-size: 13px;
    font-family: var(--font-family);
    color: var(--text-primary);
    background: var(--bg-card);
    transition: all var(--transition-fast);
}

.input-field:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.input-field::placeholder {
    color: var(--text-muted);
}

.info-group {
    margin-bottom: 16px;
    text-align: left;
}

.info-group label {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

/* ==================== BUTTONS ==================== */

.btn-primary,
.btn-primary-lg,
.btn-create-protocol {
    padding: 10px 20px;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-family);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition-fast);
}

.btn-primary:hover,
.btn-primary-lg:hover,
.btn-create-protocol:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-full {
    width: 100%;
    justify-content: center;
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    padding: 8px 16px;
}

.btn-text:hover {
    color: var(--text-primary);
}

.btn-google-signin {
    width: 100%;
    padding: 10px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all var(--transition-fast);
}

.btn-google-signin:hover {
    background: var(--bg-secondary);
    border-color: var(--text-muted);
}

.login-disclaimer {
    margin-top: 16px;
    font-size: 11px;
    color: var(--text-muted);
}

/* ==================== HAMBURGER MENU ==================== */

.hamburger-menu {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 90;
    width: 36px;
    height: 36px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    cursor: pointer;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    box-shadow: var(--shadow-sm);
}

.hamburger-menu span {
    width: 16px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
}

/* ==================== RESPONSIVE ==================== */

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: calc(-1 * var(--sidebar-width));
        height: 100vh;
        z-index: 100;
        transition: left var(--transition-normal);
    }

    .sidebar.open {
        left: 0;
    }

    .hamburger-menu {
        display: flex;
    }
}

/* ==================== SCROLLBAR ==================== */

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

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

::-webkit-scrollbar-thumb {
    background: var(--border-subtle);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}