/* ========================================
   Global Voyager Log - Main Stylesheet
   ======================================== */

/* CSS Variables - Stitch Design System */
:root {
    /* Colors - "The Ethereal Navigator" Palette */
    --color-primary: #005d90;
    --color-primary-light: #0077b6;
    --color-primary-dark: #004b74;
    --color-primary-fixed: #cde5ff;
    --color-primary-fixed-dim: #94ccff;

    --color-secondary: #006878;
    --color-secondary-light: #004e5b;
    --color-secondary-container: #69e5ff;
    --color-accent: #755200;
    --color-accent-light: #956900;
    --color-accent-container: #ffdea9;

    /* Surface Hierarchy */
    --color-bg: #f7f9ff;
    --color-bg-light: #f1f4f9;
    --color-bg-lighter: #ebeef4;
    --color-surface: #f7f9ff;
    --color-surface-low: #f1f4f9;
    --color-surface-container: #ebeef4;
    --color-surface-high: #e6e8ee;
    --color-surface-highest: #e0e2e8;
    --color-surface-lowest: #ffffff;
    --color-surface-hover: #e6e8ee;

    /* Text */
    --color-text: #181c20;
    --color-text-secondary: #404850;
    --color-text-muted: #707881;

    /* Outline */
    --color-border: rgba(191, 199, 209, 0.15);
    --color-border-light: rgba(191, 199, 209, 0.10);
    --color-outline: #707881;
    --color-outline-variant: #bfc7d1;

    /* Status colors */
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-error: #ba1a1a;
    --color-info: #005d90;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #005d90 0%, #0077b6 100%);
    --gradient-secondary: linear-gradient(135deg, #181c20 0%, #2d3135 100%);
    --gradient-hero: linear-gradient(135deg, #181c20 0%, #005d90 100%);
    --gradient-card: linear-gradient(145deg, #ffffff 0%, #f1f4f9 100%);
    --gradient-stats: linear-gradient(135deg, #005d90 0%, #0077b6 100%);

    /* Typography */
    --font-primary: 'Inter', 'Noto Sans JP', sans-serif;
    --font-display: 'Plus Jakarta Sans', 'Noto Sans JP', sans-serif;

    /* Font sizes */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;
    --text-5xl: 3rem;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;
    --space-20: 5rem;

    /* Border radius - more subtle */
    --radius-sm: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    --radius-xl: 0.75rem;
    --radius-2xl: 1rem;
    --radius-full: 9999px;

    /* Shadows - Ambient, sky-tinted */
    --shadow-sm: 0 1px 3px 0 rgba(0, 93, 144, 0.04);
    --shadow-md: 0 4px 12px -2px rgba(0, 93, 144, 0.06);
    --shadow-lg: 0 10px 24px -4px rgba(0, 93, 144, 0.08);
    --shadow-xl: 0 20px 40px -8px rgba(0, 93, 144, 0.10);
    --shadow-glow: 0 0 20px rgba(0, 93, 144, 0.15);

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Z-index */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;

    /* Additional Colors */
    --color-danger: #ba1a1a;
}

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

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

body {
    font-family: var(--font-primary);
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--color-text);
    background: var(--color-bg);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.2;
    color: var(--color-text);
}

h1 {
    font-size: var(--text-4xl);
}

h2 {
    font-size: var(--text-3xl);
}

h3 {
    font-size: var(--text-2xl);
}

h4 {
    font-size: var(--text-xl);
}

h5 {
    font-size: var(--text-lg);
}

h6 {
    font-size: var(--text-base);
}

a {
    color: var(--color-primary-light);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-primary);
}

/* Container */
.container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 var(--space-8);
}

/* Header - Glassmorphism */
.header {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: none;
    box-shadow: 0 1px 3px rgba(0, 93, 144, 0.05);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) 0;
    gap: var(--space-8);
    position: relative;
}

/* Header User Section (desktop) */
.header-user-section {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-left: auto;
}

.btn-login-header {
    white-space: nowrap;
    font-size: var(--text-sm);
    padding: var(--space-2);
    background: none;
    color: var(--color-text-secondary);
    border: none;
    cursor: pointer;
    transition: color var(--transition-fast);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.header-user-section .user-info {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.header-user-section .user-name {
    color: var(--color-text);
    font-size: var(--text-sm);
    font-weight: 600;
}

.header-user-section .btn-secondary {
    font-size: var(--text-xs);
    padding: var(--space-1) var(--space-3);
    background: var(--color-surface-container);
    color: var(--color-text-secondary);
    border: none;
}

.header-user-section .btn-secondary:hover {
    background: var(--color-surface-high);
    color: var(--color-text);
}

/* Logo */
.logo {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--color-primary-dark);
    cursor: pointer;
    letter-spacing: -0.03em;
    transition: transform var(--transition-fast);
    flex-shrink: 0;
}

.logo:hover {
    transform: scale(1.02);
}

.logo-text {
    background: none;
    -webkit-text-fill-color: var(--color-primary-dark);
    color: var(--color-primary-dark);
}

/* Navigation - Text links with underline active */
.nav {
    display: none;
    gap: var(--space-6);
    align-items: center;
}

.nav.nav-authenticated {
    display: flex;
}

.nav-site-header {
    display: none;
}

.nav-terms-link {
    display: flex;
    align-items: center;
}

.nav-link-terms {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    text-decoration: none;
    font-family: var(--font-display);
    font-weight: 500;
    transition: color var(--transition-fast);
    white-space: nowrap;
}

.nav-link-terms:hover {
    color: var(--color-primary);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-2) 0;
    border-radius: 0;
    color: var(--color-text-muted);
    font-weight: 500;
    font-size: var(--text-sm);
    font-family: var(--font-display);
    transition: color var(--transition-fast);
    border-bottom: 2px solid transparent;
    text-decoration: none;
}

.nav-link:hover {
    color: var(--color-primary);
    background: none;
}

.nav-link.active {
    color: var(--color-primary);
    font-weight: 700;
    border-bottom-color: var(--color-primary);
    background: none;
    box-shadow: none;
}

.nav-link i {
    display: none;
}

/* Hamburger Menu */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--color-text);
    cursor: pointer;
    padding: var(--space-2);
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
    margin-left: auto;
    order: 3;
}

.menu-toggle:hover {
    background: var(--color-surface-hover);
}

/* User Section in Nav */
.nav-user-section {
    display: none;
    padding-top: var(--space-4);
    margin-top: var(--space-4);
    border-top: 1px solid var(--color-border);
}

.nav-user-section .user-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.nav-user-section .user-photo {
    width: 50px;
    height: 50px;
    border-radius: var(--radius-full);
    border: 2px solid var(--color-primary-light);
}

.nav-user-section .user-name {
    font-weight: 600;
    color: var(--color-text);
}

.nav-user-section .btn-primary,
.nav-user-section .btn-secondary {
    width: 100%;
}

/* User Section */
.user-section {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.user-info {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.user-photo {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    border: 2px solid var(--color-primary-light);
    box-shadow: var(--shadow-md);
}

.user-name {
    font-weight: 600;
    color: var(--color-text);
}

/* Main Content */
.main {
    min-height: calc(100vh - 80px);
    padding: var(--space-8) 0;
}

/* Sections */
.section {
    display: none;
    animation: fadeIn var(--transition-base);
}

.section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

.section-header {
    text-align: left;
    margin-bottom: var(--space-8);
}

.section-title {
    font-size: var(--text-5xl);
    font-weight: 800;
    color: var(--color-text);
    letter-spacing: -0.03em;
    margin-bottom: var(--space-2);
}

.section-subtitle {
    font-size: var(--text-base);
    color: var(--color-text-secondary);
    font-weight: 400;
    max-width: 36rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-6);
    margin-bottom: var(--space-12);
}

.stat-card {
    background: var(--color-surface-lowest);
    border: none;
    border-left: 4px solid var(--color-primary);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    text-align: left;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.stat-card:nth-child(2) {
    border-left-color: var(--color-secondary);
}

.stat-card:nth-child(3) {
    border-left-color: var(--color-accent);
}

.stat-card:nth-child(4) {
    border-left-color: var(--color-primary-light);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--color-primary-fixed);
    border-radius: var(--radius-lg);
    color: var(--color-primary);
    margin-bottom: var(--space-4);
    transition: all var(--transition-base);
}

.stat-card:hover .stat-icon {
    transform: scale(1.05);
}

.stat-value {
    font-size: var(--text-4xl);
    font-weight: 800;
    font-family: var(--font-display);
    color: var(--color-text);
    letter-spacing: -0.03em;
    margin-bottom: var(--space-1);
}

.stat-label {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    font-weight: 600;
}

/* Chart Grid */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: var(--space-6);
    margin-top: var(--space-8);
}

.chart-card {
    background: var(--color-surface-lowest);
    border: none;
    border-radius: var(--radius-xl);
    padding: var(--space-8);
}

.chart-title {
    font-size: var(--text-xl);
    font-weight: 600;
    margin-bottom: var(--space-6);
    color: var(--color-text);
}

/* Buttons */
.btn-primary,
.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    border: none;
    border-radius: var(--radius-xl);
    font-family: var(--font-primary);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 14px rgba(0, 93, 144, 0.2);
}

.btn-primary:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 20px rgba(0, 93, 144, 0.3);
}

.btn-secondary {
    background: var(--color-surface-high);
    color: var(--color-text-secondary);
    border: none;
}

.btn-secondary:hover {
    background: var(--color-surface-highest);
    color: var(--color-text);
    transform: translateY(-1px);
}

.btn-sm {
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
}

.btn-lg {
    padding: var(--space-4) var(--space-8);
    font-size: var(--text-base);
}

.btn-icon {
    font-size: var(--text-xl);
}

/* Loading Overlay */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(247, 249, 255, 0.9);
    backdrop-filter: blur(8px);
    z-index: var(--z-modal);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: var(--space-6);
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--color-surface-high);
    border-top-color: var(--color-primary);
    border-radius: var(--radius-full);
    animation: spin 1s linear infinite;
}

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

.loading-text {
    font-size: var(--text-lg);
    color: var(--color-text-secondary);
    font-weight: 500;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .menu-toggle {
        display: block;
    }

    .container {
        padding: 0 var(--space-6);
    }

    .nav.nav-authenticated {
        position: fixed;
        top: 64px;
        left: 0;
        right: 0;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(20px);
        flex-direction: column;
        padding: var(--space-6);
        gap: var(--space-2);
        border-bottom: 1px solid var(--color-border);
        box-shadow: var(--shadow-lg);
        display: none;
        z-index: var(--z-fixed);
        max-height: calc(100vh - 64px);
        overflow-y: auto;
    }

    .nav.nav-authenticated.open {
        display: flex;
        animation: slideDown var(--transition-base);
    }

    .nav.open .nav-link {
        color: var(--color-text-secondary);
        background: none;
        border-bottom: none;
        padding: var(--space-3) var(--space-4);
        border-radius: var(--radius-lg);
    }

    .nav.open .nav-link:hover {
        background: var(--color-surface-low);
        color: var(--color-primary);
    }

    .nav.open .nav-link.active {
        background: var(--color-primary-fixed);
        color: var(--color-primary);
        font-weight: 700;
    }

    .nav-terms-link {
        margin-top: var(--space-2);
        padding-top: var(--space-4);
        border-top: 1px solid var(--color-border);
        width: 100%;
    }

    .nav-link-terms {
        font-size: var(--text-sm);
        padding: var(--space-2) var(--space-4);
    }

    .nav-user-section {
        display: block;
    }

    /* Hide desktop user section on mobile */
    .header-user-section {
        display: none;
    }

    @keyframes slideDown {
        from {
            transform: translateY(-10px);
            opacity: 0;
        }

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

    .chart-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .header-content {
        padding: var(--space-3) 0;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .section-title {
        font-size: var(--text-3xl);
    }

    .section-subtitle {
        font-size: var(--text-sm);
    }

    .user-name {
        display: none;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .logo-text {
        display: block;
        font-size: var(--text-base);
    }

    .user-name {
        display: none;
    }
}