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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8fafc;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Landing Page Styles */
.landing-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
}

.hero-section {
    text-align: center;
    color: white;
    padding: 60px 0;
}

.hero-title {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.hero-subtitle {
    font-size: 1.25rem;
    margin-bottom: 3rem;
    opacity: 0.9;
}

/* Apple Sign In Button */
.apple-signin-btn {
    background: #000;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 16px 32px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
    margin-bottom: 2rem;
}

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

.apple-signin-btn i {
    font-size: 20px;
}

/* Loading Spinner */
.loading-spinner {
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.spinner-sm {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(59,130,246,0.3);
    border-top: 2px solid #3B82F6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Privacy Notice */
.privacy-notice {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    opacity: 0.8;
}

.privacy-notice i {
    font-size: 24px;
    color: #10B981;
}

/* Features Section */
.features-section {
    background: white;
    padding: 80px 0;
    margin-top: 60px;
}

.features-section h2 {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 3rem;
    color: #1f2937;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.feature-card {
    text-align: center;
    padding: 2rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}

.feature-card:hover {
    transform: translateY(-2px);
}

.feature-card i {
    font-size: 3rem;
    color: #3B82F6;
    margin-bottom: 1rem;
}

.feature-card h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: #1f2937;
}

/* Dashboard Styles */
.dashboard-page {
    background-color: #f8fafc;
    min-height: 100vh;
}

/* Hide dashboard content by default until loaded */
.dashboard-page .container > *:not(.loading-state) {
    display: none;
}

.dashboard-page .container.loaded > *:not(.loading-state) {
    display: block;
}

.dashboard-page .container.loaded .loading-state {
    display: none;
}

/* Navigation */
.navbar {
    background: white;
    border-bottom: 1px solid #e5e7eb;
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.nav-brand h2 {
    color: #1f2937;
    font-weight: 700;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sync-btn {
    background: #3B82F6;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.sync-btn:hover {
    background: #2563eb;
}

.sync-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.user-menu {
    position: relative;
}

.user-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.user-btn:hover {
    background: #f3f4f6;
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    padding: 8px;
    min-width: 150px;
}

.user-dropdown button {
    width: 100%;
    background: none;
    border: none;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.user-dropdown button:hover {
    background: #f3f4f6;
}

/* Dashboard Header */
.dashboard-header {
    padding: 2rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 2rem;
}

.welcome-section h1 {
    font-size: 2rem;
    color: #1f2937;
    margin-bottom: 0.5rem;
}

.welcome-section p {
    color: #6b7280;
}

/* Sync Status */
.sync-status {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #3B82F6;
    font-size: 14px;
}

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

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.stat-icon {
    flex-shrink: 0;
}

.stat-icon i {
    font-size: 2rem;
}

.stat-content h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.stat-value span:first-child {
    font-size: 1.875rem;
    font-weight: 700;
    color: #1f2937;
}

.stat-unit {
    font-size: 0.875rem;
    color: #6b7280;
}

/* Charts Section */
.charts-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.chart-container {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.chart-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1f2937;
}

.chart-controls select {
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 14px;
    cursor: pointer;
}

/* No Data State */
.no-data-state {
    text-align: center;
    padding: 4rem 0;
}

.no-data-content {
    max-width: 500px;
    margin: 0 auto;
}

.no-data-content i {
    font-size: 4rem;
    color: #9ca3af;
    margin-bottom: 1.5rem;
}

.no-data-content h3 {
    font-size: 1.5rem;
    color: #1f2937;
    margin-bottom: 1rem;
}

.no-data-content p {
    color: #6b7280;
    margin-bottom: 2rem;
}

.setup-steps {
    background: #f3f4f6;
    border-radius: 8px;
    padding: 1.5rem;
    margin: 2rem 0;
    text-align: left;
}

.setup-steps h4 {
    color: #1f2937;
    margin-bottom: 1rem;
}

.setup-steps ul {
    list-style: none;
    padding: 0;
}

.setup-steps li {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0.5rem;
    color: #4b5563;
}

.setup-steps li:before {
    content: '✓';
    color: #10b981;
    font-weight: bold;
}

.cta-button {
    background: #000;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 16px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.cta-button:hover {
    background: #333;
}

/* Loading State */
.loading-state {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
    text-align: center;
}

.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.loading-content .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(59,130,246,0.3);
    border-top: 3px solid #3B82F6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-content p {
    color: #6b7280;
    font-size: 1.125rem;
}

/* Error Messages */
.error-message {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.error-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.error-content i {
    color: #ef4444;
    font-size: 1.25rem;
}

.error-content p {
    margin: 0;
    color: #dc2626;
    flex: 1;
}

.retry-btn {
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.2s;
}

.retry-btn:hover {
    background: #dc2626;
}

/* Chart Loading and Error States */
.chart-loading,
.chart-no-data,
.chart-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    text-align: center;
    color: #6b7280;
}

.chart-loading .spinner-sm {
    margin-bottom: 1rem;
}

.chart-loading p,
.chart-no-data p,
.chart-error p {
    margin: 0;
    font-size: 0.875rem;
}

.chart-error p {
    color: #ef4444;
}

/* Auth Error Notifications */
.auth-error {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    max-width: 400px;
    animation: slideIn 0.3s ease-out;
}

.auth-error-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.auth-error-content i {
    color: #ef4444;
    font-size: 1.25rem;
}

.auth-error-content span {
    color: #dc2626;
    flex: 1;
    font-size: 0.875rem;
}

.close-error {
    background: none;
    border: none;
    color: #dc2626;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.close-error:hover {
    background: #fecaca;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }
    
    .hero-title {
        font-size: 2rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .charts-section {
        grid-template-columns: 1fr;
    }
    
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .nav-menu {
        flex-direction: column;
        gap: 0.5rem;
    }
}
