/* CSS Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #1683d6;
    --secondary-color: #1683d6;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --background: #fdfcf9;
    --card-background: rgba(255, 255, 255, 0.95);
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --glass-background: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.18);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #fdfcf9;
    background-attachment: fixed;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding-bottom: 80px;
    overflow-x: hidden;
    min-height: 100vh;
}

/* Header */
.header {
    position: sticky;
    top: 0;
    background: #f7f1e5;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    z-index: 100;
    padding: 16px 20px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-image {
    height: 60px;
    width: auto;
    object-fit: contain;
}

.logo-icon {
    font-size: 28px;
}

.logo-text {
    font-size: 22px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: rgba(236, 253, 245, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 24px;
    border: 1px solid rgba(16, 185, 129, 0.2);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.15);
}

.guest-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: linear-gradient(135deg, rgba(254, 243, 199, 0.9), rgba(253, 230, 138, 0.9));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 24px;
    border: 1px solid rgba(245, 158, 11, 0.3);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.15);
    margin-left: 12px;
}

.guest-icon {
    font-size: 16px;
}

.guest-text {
    font-size: 14px;
    font-weight: 500;
    color: #92400e;
}

.guest-notice {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border: 1px solid #f59e0b;
    margin-bottom: 20px;
}

.guest-notice-content {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.guest-notice-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.guest-notice-text h3 {
    margin: 0 0 8px 0;
    color: #92400e;
    font-size: 18px;
    font-weight: 600;
}

.guest-notice-text p {
    margin: 0 0 16px 0;
    color: #78350f;
    line-height: 1.5;
}

.guest-upgrade-btn {
    background: #1683d6;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.guest-upgrade-btn:hover {
    background: #0f6bb8;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(22, 131, 214, 0.3);
}

.guest-info {
    margin-top: 16px;
    padding: 12px;
    background: rgba(254, 243, 199, 0.3);
    border-radius: 8px;
    border: 1px solid rgba(245, 158, 11, 0.2);
    font-size: 14px;
    color: #78350f;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--success-color);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.status-text {
    font-size: 12px;
    color: var(--success-color);
    font-weight: 600;
}

/* Main Content */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
}

/* Force hide app pages (not auth pages) when in auth mode */
body.auth-mode .main-content .page:not(.auth-page) {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* Cards */
.card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px) saturate(180%);
    -webkit-backdrop-filter: blur(10px) saturate(180%);
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

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

/* Patient Card */
.patient-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.patient-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 56px;
    height: 56px;
    background: #1683d6;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 20px;
    box-shadow: 0 8px 16px rgba(22, 131, 214, 0.4);
    border: 3px solid rgba(255, 255, 255, 0.9);
}

.patient-details {
    display: flex;
    flex-direction: column;
}

.patient-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.patient-condition {
    font-size: 14px;
    color: var(--text-secondary);
}

.last-sync {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.sync-icon {
    font-size: 14px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 18px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.4);
    display: flex;
    align-items: center;
    gap: 14px;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.stat-icon {
    font-size: 32px;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(22, 131, 214, 0.15), rgba(22, 131, 214, 0.15));
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(22, 131, 214, 0.1);
}

.stat-content {
    flex: 1;
}

.stat-value {
    font-size: 22px;
    font-weight: 800;
    background: #1683d6;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Alert Card */
.alert-card {
    background: linear-gradient(135deg, rgba(254, 243, 199, 0.9), rgba(253, 230, 138, 0.9));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-left: 5px solid var(--warning-color);
    border-radius: 20px;
    display: flex;
    gap: 16px;
    align-items: start;
    box-shadow: 0 8px 32px rgba(245, 158, 11, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.alert-icon {
    font-size: 24px;
}

.alert-content {
    flex: 1;
}

.alert-title {
    font-size: 16px;
    font-weight: 700;
    color: #92400e;
    margin-bottom: 4px;
}

.alert-message {
    font-size: 14px;
    color: #78350f;
}

/* Chart Cards */
.chart-card {
    padding: 20px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.foot-selector {
    padding: 10px 14px;
    border-radius: 10px;
    border: 2px solid rgba(22, 131, 214, 0.2);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.foot-selector:hover {
    border-color: rgba(22, 131, 214, 0.4);
    box-shadow: 0 4px 12px rgba(22, 131, 214, 0.15);
}

.chart-container {
    position: relative;
    height: 250px;
}

/* Charts inherit page visibility - no additional rules needed */

/* Metrics Card */
.metrics-card {
    padding: 20px;
}

.metrics-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 16px;
}

.metric-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.metric-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.metric-label {
    font-size: 14px;
    color: var(--text-secondary);
}

.metric-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Desktop Navigation */
.desktop-nav {
    display: none;
    gap: 8px;
}

.desktop-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 10px 16px;
    transition: all 0.3s ease;
    font-family: inherit;
    border-radius: 12px;
    position: relative;
}

.desktop-nav-item:hover {
    background: rgba(22, 131, 214, 0.15);
    color: var(--primary-color);
    transform: translateY(-2px);
}

.desktop-nav-item.active {
    background: linear-gradient(135deg, rgba(22, 131, 214, 0.2), rgba(22, 131, 214, 0.2));
    color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(22, 131, 214, 0.3);
}

.desktop-nav-item.active::after {
    content: '';
    position: absolute;
    bottom: -18px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 2px;
}

.desktop-nav-item .nav-icon {
    font-size: 20px;
}

.desktop-nav-item .nav-label {
    font-size: 11px;
    font-weight: 500;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #f7f1e5;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.1);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-around;
    padding: 8px 0 max(8px, env(safe-area-inset-bottom));
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px 16px;
    transition: all 0.3s ease;
    font-family: inherit;
    border-radius: 12px;
    position: relative;
}

.nav-item.active {
    color: var(--primary-color);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 0 0 3px 3px;
}

.nav-icon {
    font-size: 24px;
}

.nav-label {
    font-size: 11px;
    font-weight: 500;
}

/* Responsive Design */
@media (min-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .main-content {
        padding: 24px;
    }

    .card {
        padding: 24px;
    }
}

@media (min-width: 1024px) {
    body {
        padding-bottom: 0;
    }

    .bottom-nav {
        display: none;
    }

    .desktop-nav {
        display: flex;
    }

    .chart-container {
        height: 300px;
    }
}

/* Loading Animation */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.loading {
    animation: shimmer 2s infinite;
    background: linear-gradient(to right, #f0f0f0 4%, #f8f8f8 25%, #f0f0f0 36%);
    background-size: 1000px 100%;
}

/* PWA Install Prompt */
.install-prompt {
    position: fixed;
    bottom: 90px;
    left: 16px;
    right: 16px;
    background: var(--primary-color);
    color: white;
    padding: 16px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    display: none;
    align-items: center;
    gap: 12px;
    z-index: 1000;
}

.install-prompt.show {
    display: flex;
}

.install-prompt button {
    background: white;
    color: var(--primary-color);
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

/* Page Navigation - SIMPLIFIED APPROACH */
.page {
    display: none;
    position: relative;
    width: 100%;
}

.page.active {
    display: block;
}

/* Specific page rules to ensure they work correctly */
#dashboardPage:not(.active),
#historyPage:not(.active),
#settingsPage:not(.active),
#profilePage:not(.active) {
    display: none;
}

#dashboardPage.active,
#historyPage.active,
#settingsPage.active,
#profilePage.active {
    display: block;
}

/* Auth pages */
.auth-page {
    display: none;
}

.auth-page.active {
    display: flex !important;
}

/* Foot Visualization */
.foot-visualization {
    padding: 20px 0;
}

.foot-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

/* Dual Foot Display */
.dual-foot-container {
    display: flex;
    gap: 24px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.single-foot-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.foot-label {
    font-size: 16px;
    font-weight: 700;
    background: #1683d6;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

/* P5.js Foot Heatmap */
.foot-heatmap-container {
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 20px;
    padding: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.foot-heatmap-container canvas {
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    max-width: 100%;
    height: auto;
    background: white;
}

.pressure-legend {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    width: 100%;
    max-width: 320px;
    margin: 20px auto 0;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-primary);
    font-weight: 600;
    background: rgba(255, 255, 255, 0.6);
    padding: 8px 10px;
    border-radius: 10px;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.legend-color {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.5);
    flex-shrink: 0;
}

/* Page Titles */
.page-title {
    font-size: 28px;
    font-weight: 800;
    background: #1683d6;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.page-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Timeline */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 16px;
}

.timeline-item {
    display: flex;
    gap: 16px;
    position: relative;
}

.timeline-item:not(:last-child)::after {
    content: '';
    position: absolute;
    left: 11px;
    top: 30px;
    bottom: -20px;
    width: 2px;
    background: var(--border-color);
}

.timeline-dot {
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 4px rgba(22, 131, 214, 0.15), 0 4px 12px rgba(22, 131, 214, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.9);
}

.timeline-content {
    flex: 1;
}

.timeline-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.timeline-meta {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.timeline-stats {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Settings */
.settings-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 16px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.setting-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.setting-info {
    flex: 1;
}

.setting-label {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.setting-description {
    font-size: 13px;
    color: var(--text-secondary);
}

.setting-select {
    padding: 10px 14px;
    border-radius: 10px;
    border: 2px solid rgba(22, 131, 214, 0.2);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.setting-select:hover {
    border-color: rgba(22, 131, 214, 0.4);
    box-shadow: 0 4px 12px rgba(22, 131, 214, 0.15);
}

/* Toggle Switch */
.toggle {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
    flex-shrink: 0;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: 0.3s;
    border-radius: 28px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle input:checked + .toggle-slider {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    box-shadow: 0 4px 12px rgba(22, 131, 214, 0.3);
}

.toggle input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

/* Profile */
.profile-header {
    text-align: center;
    padding: 32px 20px;
}

.profile-avatar-large {
    width: 120px;
    height: 120px;
    background: #1683d6;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 800;
    font-size: 42px;
    margin-bottom: 20px;
    box-shadow: 0 12px 28px rgba(22, 131, 214, 0.4);
    border: 4px solid rgba(255, 255, 255, 0.9);
}

.profile-name {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.profile-email {
    font-size: 14px;
    color: var(--text-secondary);
}

.profile-info-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 16px;
}

.profile-info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.profile-info-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.info-label {
    font-size: 14px;
    color: var(--text-secondary);
}

.info-value {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.profile-button {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    font-family: inherit;
    box-shadow: 0 4px 15px rgba(22, 131, 214, 0.3);
}

.profile-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(22, 131, 214, 0.4);
}

.profile-button:active {
    transform: translateY(0);
}

.profile-button.secondary {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--text-primary);
    border: 2px solid rgba(22, 131, 214, 0.2);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.profile-button.secondary:hover {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(22, 131, 214, 0.3);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.profile-button.danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.profile-button.danger:hover {
    box-shadow: 0 8px 25px rgba(239, 68, 68, 0.4);
}

/* Responsive adjustments */
@media (min-width: 768px) {
    .pressure-legend {
        grid-template-columns: repeat(4, 1fr);
        max-width: 100%;
    }
    
    .dual-foot-container {
        gap: 32px;
    }
    
    .timeline-stats {
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .dual-foot-container {
        flex-direction: column;
        gap: 20px;
    }
    
    .foot-heatmap-container {
        padding: 12px;
    }
    
    .pressure-legend {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ===========================
   AUTHENTICATION PAGES
   =========================== */

.auth-page {
    display: none;
    min-height: 100vh;
    background: #fdfcf9;
    background-attachment: fixed;
    padding: 20px;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.auth-page::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
    background-size: 50px 50px;
    animation: backgroundMove 20s linear infinite;
}

@keyframes backgroundMove {
    0% {
        transform: translate(0, 0);
    }
    100% {
        transform: translate(50px, 50px);
    }
}

.auth-page.active {
    display: flex;
}

.auth-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: 24px;
    padding: 40px 32px;
    max-width: 480px;
    width: 100%;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.3);
    animation: slideUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    z-index: 1;
    overflow: hidden;
}

.auth-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: #f7f1e5;
    z-index: -1;
    border-radius: 24px 24px 0 0;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
    position: relative;
    z-index: 1;
}

.auth-logo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
}

.auth-logo-image {
    height: 80px;
    width: auto;
    object-fit: contain;
}

.auth-logo .logo-icon {
    font-size: 40px;
}

.auth-logo .logo-text {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-color);
}

.auth-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.auth-subtitle {
    font-size: 15px;
    color: var(--text-secondary);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
    z-index: 1;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.form-input {
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 15px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--card-background);
    transition: all 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(22, 131, 214, 0.1);
}

.form-input::placeholder {
    color: #94a3b8;
}

.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    margin-top: -8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.text-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.text-link:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

.auth-error {
    padding: 12px 16px;
    background: #fee2e2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #991b1b;
    font-size: 14px;
    font-weight: 500;
}

.auth-button {
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.auth-button.primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    box-shadow: 0 4px 15px rgba(22, 131, 214, 0.4);
}

.auth-button.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(22, 131, 214, 0.5);
}

.auth-button.primary:active {
    transform: translateY(0);
}

.auth-button.secondary {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--text-primary);
    border: 2px solid rgba(22, 131, 214, 0.2);
}

.auth-button.secondary:hover {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(22, 131, 214, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.auth-button.guest {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    pointer-events: auto;
    z-index: 1;
}

.auth-button.guest:hover {
    background: linear-gradient(135deg, #059669, #047857);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.auth-button.guest:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
}

.auth-button.guest::before {
    content: '👤';
    margin-right: 8px;
    font-size: 16px;
}

.auth-divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin: 8px 0;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-color);
}

.auth-divider span {
    padding: 0 12px;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 13px;
    color: var(--text-secondary);
    position: relative;
    z-index: 1;
}

.password-strength {
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 4px;
}

.password-strength::after {
    content: '';
    display: block;
    height: 100%;
    width: 0%;
    transition: all 0.3s;
}

.password-strength.weak::after {
    width: 33%;
    background: var(--danger-color);
}

.password-strength.medium::after {
    width: 66%;
    background: var(--warning-color);
}

.password-strength.strong::after {
    width: 100%;
    background: var(--success-color);
}

/* Hide header and nav on auth pages */
body.auth-mode .header {
    display: none !important;
}

body.auth-mode .bottom-nav {
    display: none !important;
}

/* Only hide pages with class "page", NOT auth-page */
body.auth-mode .page:not(.auth-page) {
    display: none !important;
}

body.auth-mode #dashboardPage,
body.auth-mode #historyPage,
body.auth-mode #settingsPage,
body.auth-mode #profilePage {
    display: none !important;
    visibility: hidden !important;
}

body.auth-mode {
    padding-bottom: 0;
}

/* Responsive Auth */
@media (max-width: 640px) {
    .auth-container {
        padding: 32px 24px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .auth-title {
        font-size: 24px;
    }
}

/* ===========================
   SURVEY MODAL STYLES
   =========================== */

.survey-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px); /* Safari support */
    z-index: 9999;
    animation: fadeIn 0.3s ease;
    overflow-y: auto;
    padding: 20px;
}

/* Fallback for browsers without backdrop-filter */
@supports not (backdrop-filter: blur(4px)) {
    .survey-modal {
        background: rgba(0, 0, 0, 0.75);
    }
}

.survey-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.survey-content {
    background: white;
    border-radius: 16px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.4s ease;
}

.survey-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: transparent;
    border: none;
    font-size: 32px;
    color: #64748b;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
    z-index: 10;
}

.survey-close:hover {
    background: #f1f5f9;
    color: var(--text-primary);
}

.survey-header {
    padding: 40px 40px 24px 40px;
    text-align: center;
    border-bottom: 2px solid #f1f5f9;
}

.survey-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.survey-subtitle {
    font-size: 15px;
    color: var(--text-secondary);
}

.survey-disclaimer {
    margin-top: 16px;
    padding: 12px 16px;
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 8px;
    text-align: left;
}

.survey-disclaimer p {
    font-size: 13px;
    color: #92400e;
    margin: 0;
    line-height: 1.4;
}

.survey-form {
    padding: 32px 40px;
}

.survey-question {
    margin-bottom: 32px;
}

.survey-question:last-of-type {
    margin-bottom: 0;
}

.survey-label {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.survey-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.survey-radio,
.survey-checkbox {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
}

.survey-radio:hover,
.survey-checkbox:hover {
    border-color: var(--primary-color);
    background: #f8fafc;
}

.survey-radio input[type="radio"],
.survey-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.survey-radio input[type="radio"]:checked ~ span,
.survey-checkbox input[type="checkbox"]:checked ~ span {
    color: var(--primary-color);
    font-weight: 600;
}

/* Browser-compatible checked state styling */
.survey-radio input[type="radio"]:checked,
.survey-checkbox input[type="checkbox"]:checked {
    accent-color: var(--primary-color);
}

.survey-radio:has(input:checked),
.survey-checkbox:has(input:checked) {
    border-color: var(--primary-color);
    background: #eff6ff;
}

/* Fallback for browsers without :has() support */
@supports not (selector(:has(*))) {
    .survey-radio input[type="radio"]:checked,
    .survey-checkbox input[type="checkbox"]:checked {
        outline: 2px solid var(--primary-color);
        outline-offset: -2px;
    }
}

.survey-radio span,
.survey-checkbox span {
    font-size: 15px;
    color: var(--text-primary);
}

.survey-textarea {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-family: inherit;
    font-size: 15px;
    color: var(--text-primary);
    resize: vertical;
    transition: all 0.2s ease;
}

.survey-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(22, 131, 214, 0.1);
}

.survey-textarea::placeholder {
    color: #94a3b8;
}

.survey-actions {
    display: flex;
    gap: 12px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 2px solid #f1f5f9;
}

.survey-button {
    flex: 1;
    padding: 14px 24px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.survey-button.primary {
    background: var(--primary-color);
    color: white;
}

.survey-button.primary:hover {
    background: #1269b0;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(22, 131, 214, 0.3);
}

.survey-button.secondary {
    background: #f1f5f9;
    color: var(--text-secondary);
}

.survey-button.secondary:hover {
    background: #e2e8f0;
    color: var(--text-primary);
}

.survey-thank-you {
    padding: 60px 40px;
    text-align: center;
}

.thank-you-icon {
    font-size: 72px;
    margin-bottom: 24px;
    animation: bounce 0.6s ease;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
}

.survey-thank-you h3 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.survey-thank-you p {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.survey-thank-you .survey-button {
    width: auto;
    min-width: 200px;
}

/* Responsive Survey */
@media (max-width: 640px) {
    .survey-modal {
        padding: 0;
        align-items: flex-end;
    }
    
    .survey-content {
        max-height: 95vh;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
    }
    
    .survey-header,
    .survey-form,
    .survey-thank-you {
        padding: 24px 20px;
    }
    
    .survey-title {
        font-size: 24px;
    }
    
    .survey-actions {
        flex-direction: column;
    }
    
    .survey-button {
        width: 100%;
    }
}

