/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #8b5cf6;
    --accent-color: #06b6d4;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --bg-primary: rgba(15, 23, 42, 0.95);
    --bg-secondary: rgba(30, 41, 59, 0.8);
    --bg-card: rgba(51, 65, 85, 0.6);
    --border-color: rgba(148, 163, 184, 0.2);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0f172a;
    min-height: 100vh;
    color: var(--text-primary);
    overflow-x: hidden;
    position: relative;
    line-height: 1.6;
}

/* Animated Space Background */
.space-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
}

.stars, .twinkling, .clouds {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.stars {
    background: transparent url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400"><circle cx="50" cy="50" r="1" fill="%23ffffff" opacity="0.8"/><circle cx="150" cy="100" r="0.5" fill="%23ffffff" opacity="0.6"/><circle cx="300" cy="80" r="1.5" fill="%23ffffff" opacity="0.9"/><circle cx="250" cy="200" r="0.8" fill="%23ffffff" opacity="0.7"/><circle cx="100" cy="250" r="1" fill="%23ffffff" opacity="0.8"/><circle cx="350" cy="180" r="0.5" fill="%23ffffff" opacity="0.5"/><circle cx="80" cy="350" r="1.2" fill="%23ffffff" opacity="0.8"/><circle cx="200" cy="300" r="0.7" fill="%23ffffff" opacity="0.6"/><circle cx="320" cy="320" r="1" fill="%23ffffff" opacity="0.7"/><circle cx="180" cy="150" r="0.5" fill="%23ffffff" opacity="0.5"/></svg>') repeat;
    background-size: 400px 400px;
    animation: move-stars 200s linear infinite;
}

.twinkling {
    background: transparent url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400"><circle cx="100" cy="80" r="1" fill="%236366f1" opacity="0.8"><animate attributeName="opacity" values="0.3;1;0.3" dur="3s" repeatCount="indefinite"/></circle><circle cx="300" cy="150" r="0.8" fill="%238b5cf6" opacity="0.6"><animate attributeName="opacity" values="0.2;0.9;0.2" dur="4s" repeatCount="indefinite"/></circle><circle cx="200" cy="250" r="1.2" fill="%2306b6d4" opacity="0.7"><animate attributeName="opacity" values="0.4;1;0.4" dur="2.5s" repeatCount="indefinite"/></circle><circle cx="80" cy="320" r="0.9" fill="%2310b981" opacity="0.5"><animate attributeName="opacity" values="0.3;0.8;0.3" dur="3.5s" repeatCount="indefinite"/></circle></svg>') repeat;
    background-size: 400px 400px;
    animation: move-twinkling 100s linear infinite;
}

.clouds {
    background: transparent url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400"><ellipse cx="150" cy="100" rx="60" ry="20" fill="%23334155" opacity="0.1"/><ellipse cx="300" cy="200" rx="80" ry="25" fill="%23475569" opacity="0.08"/><ellipse cx="100" cy="300" rx="70" ry="22" fill="%23334155" opacity="0.09"/></svg>') repeat;
    background-size: 800px 600px;
    animation: move-clouds 300s linear infinite;
}

@keyframes move-stars {
    from { transform: translateX(0); }
    to { transform: translateX(-400px); }
}

@keyframes move-twinkling {
    from { transform: translateX(0); }
    to { transform: translateX(-400px); }
}

@keyframes move-clouds {
    from { transform: translateX(0); }
    to { transform: translateX(-800px); }
}

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

.page {
    display: none;
}

.page.active {
    display: block;
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

/* Glass morphism effect */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border-color: rgba(148, 163, 184, 0.3);
}

/* Login Page Styles */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1rem;
}

@media (min-width: 768px) {
    .login-container {
        padding: 2rem;
    }
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 2rem;
    animation: fadeInUp 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (min-width: 768px) {
    .login-card {
        padding: 3rem;
    }
}

.login-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.logo-icon {
    width: 3rem;
    height: 3rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: 1.25rem;
    color: white;
    box-shadow: var(--shadow-lg);
}

.login-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    margin: 0;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.form-group input {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: rgba(30, 41, 59, 0.5);
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s ease;
    backdrop-filter: blur(8px);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    background: rgba(30, 41, 59, 0.7);
}

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

/* Button Styles */
.primary-btn {
    width: 100%;
    padding: 0.875rem 1.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.primary-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

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

.primary-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Header Styles - Mobile First */
.header {
    margin: 1rem;
    padding: 1rem;
    animation: fadeInDown 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (min-width: 768px) {
    .header {
        margin: 2rem 2rem 0 2rem;
        padding: 1.5rem 2rem;
    }
}

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

@media (min-width: 768px) {
    .header-content {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        flex-wrap: wrap;
    }
}

.user-welcome h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

@media (min-width: 768px) {
    .user-welcome h1 {
        font-size: 1.875rem;
    }
}

.header-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

.logout-btn {
    padding: 0.75rem 1.5rem;
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger-color);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(8px);
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.3);
    transform: translateY(-1px);
}

/* Main Content - Mobile First */
.main-content {
    flex: 1;
    padding: 1rem;
}

@media (min-width: 768px) {
    .main-content {
        padding: 2rem;
    }
}

.section {
    margin-bottom: 2rem;
}

@media (min-width: 768px) {
    .section {
        margin-bottom: 3rem;
    }
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

@media (min-width: 768px) {
    .section-title {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
    }
}

.section-title::before {
    content: '';
    width: 4px;
    height: 1.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 2px;
}

/* Info Grid - Mobile First */
.info-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

/* Mobile first - single column by default */
@media (min-width: 640px) {
    .info-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .info-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    }
}

.info-card {
    padding: 1rem;
    animation: fadeInUp 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    animation-fill-mode: both;
}

@media (min-width: 768px) {
    .info-card {
        padding: 1.5rem;
    }
}

.info-card:nth-child(1) { animation-delay: 0.1s; }
.info-card:nth-child(2) { animation-delay: 0.2s; }
.info-card:nth-child(3) { animation-delay: 0.3s; }
.info-card:nth-child(4) { animation-delay: 0.4s; }

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

.card-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-icon {
    font-size: 1.5rem;
    opacity: 0.8;
}

.card-content {
    color: var(--text-secondary);
    line-height: 1.6;
}

.card-content p {
    margin-bottom: 0.5rem;
}

.card-content strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* Stats Grid - Mobile First */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

/* Tablet and up - 2 columns */
@media (min-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
    }
}

/* Large screens - 3 columns for better layout with 3 charts */
@media (min-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.chart-container {
    padding: 1rem;
    animation: fadeInUp 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    animation-fill-mode: both;
}

/* Enhanced padding for larger screens */
@media (min-width: 768px) {
    .chart-container {
        padding: 1.5rem;
    }
}

.chart-container:nth-child(1) { animation-delay: 0.1s; }
.chart-container:nth-child(2) { animation-delay: 0.2s; }
.chart-container:nth-child(3) { animation-delay: 0.3s; }
.chart-container:nth-child(4) { animation-delay: 0.4s; }

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

.chart-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.chart-icon {
    font-size: 1.5rem;
    opacity: 0.8;
}

.chart-content {
    border-radius: var(--radius-md);
    overflow: hidden;
    background: rgba(248, 250, 252, 0.05);
    padding: 1rem;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-content svg {
    max-width: 100%;
    height: auto;
    background: rgba(248, 250, 252, 0.02);
    border-radius: var(--radius-sm);
}

/* Enhanced Chart Styles for Better Visibility */
.chart-line {
    stroke-width: 2.5;
    fill: none;
}

.chart-point {
    r: 4;
    fill: var(--primary-color);
    stroke: var(--text-primary);
    stroke-width: 2;
}

.chart-bar {
    opacity: 0.9;
    transition: opacity 0.3s ease;
}

.chart-bar:hover {
    opacity: 1;
}

/* Pie chart improvements */
.pie-slice {
    stroke: var(--text-primary);
    stroke-width: 1;
    transition: all 0.3s ease;
}

.pie-slice:hover {
    stroke-width: 2;
    filter: brightness(1.1);
}

/* Grid lines for better readability */
.chart-grid-line {
    stroke: rgba(248, 250, 252, 0.1);
    stroke-width: 1;
    stroke-dasharray: 2,2;
}

/* Axis styling */
.chart-axis-line {
    stroke: var(--text-secondary);
    stroke-width: 1;
}

/* Text elements */
.chart-text {
    fill: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 11px;
}

.chart-text.bold {
    font-weight: 600;
    fill: var(--text-primary);
}

/* Loading Styles */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(8px);
}

.loading-container {
    text-align: center;
    padding: 3rem;
}

.spinner-modern {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

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

/* Error Styles */
.error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 1px solid rgba(239, 68, 68, 0.2);
    margin-top: 1rem;
    font-weight: 500;
}

.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 1px solid rgba(16, 185, 129, 0.2);
    margin-top: 1rem;
    font-weight: 500;
}

/* Chart Styles */
.chart-title {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 14px;
    fill: var(--text-primary);
}

.chart-label {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: 12px;
    fill: var(--text-secondary);
}

.chart-axis {
    stroke: var(--border-color);
    stroke-width: 1;
}

.chart-grid {
    stroke: var(--border-color);
    stroke-width: 0.5;
    opacity: 0.5;
}

.tooltip {
    position: absolute;
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    font-size: 0.875rem;
    font-weight: 500;
    z-index: 1000;
    pointer-events: none;
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-lg);
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Additional responsive adjustments */
@media (max-width: 360px) {
    .login-container {
        padding: 0.5rem;
    }
    
    .login-card {
        padding: 1.5rem;
    }
    
    .logo-container {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .login-header h1 {
        font-size: 1.5rem;
    }
    
    .chart-content {
        padding: 0.5rem;
    }
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

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

/* Focus styles for accessibility */
*:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

button:focus,
input:focus {
    outline: none;
}
