/* 
  DayPulse Analytics - Premium Style System
  Design: Modern Dark Mode with Glassmorphism and Neon Accents
*/

:root {
    --bg-primary: #080B11;
    --bg-secondary: #0F131E;
    --bg-card: rgba(20, 26, 38, 0.65);
    --border-card: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(0, 242, 254, 0.3);
    
    --text-primary: #F3F4F6;
    --text-secondary: #9CA3AF;
    --text-muted: #6B7280;
    
    --accent-cyan: #00F2FE;
    --accent-blue: #3B82F6;
    --accent-purple: #8B5CF6;
    --accent-pink: #EC4899;
    --accent-green: #10B981;
    --accent-orange: #F59E0B;
    
    --gradient-glow: linear-gradient(135deg, #00F2FE 0%, #4FACFE 100%);
    --gradient-purple: linear-gradient(135deg, #7F00FF 0%, #FF007F 100%);
    --gradient-card: linear-gradient(180deg, rgba(255,255,255,0.02) 0%, rgba(255,255,255,0) 100%);
    
    --shadow-neon: 0 0 20px rgba(0, 242, 254, 0.15);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
    min-height: 100vh;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--bg-secondary);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-blue);
}

/* Main Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    width: 260px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-card);
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 3rem;
}

.brand-icon {
    font-size: 1.8rem;
    background: var(--gradient-glow);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 8px rgba(0, 242, 254, 0.4));
}

.brand-name {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #FFF, #9CA3AF);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 12px;
    font-weight: 500;
    transition: var(--transition-smooth);
}

.nav-item.active a, .nav-item a:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.03);
}

.nav-item.active a {
    background: linear-gradient(90deg, rgba(0, 242, 254, 0.1) 0%, rgba(255,255,255,0) 100%);
    border-left: 3px solid var(--accent-cyan);
}

.nav-item a i {
    font-size: 1.2rem;
    transition: var(--transition-smooth);
}

.nav-item:hover a i {
    transform: translateX(3px);
    color: var(--accent-cyan);
}

.user-profile {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 16px;
    border: 1px solid var(--border-card);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--bg-primary);
    box-shadow: var(--shadow-neon);
}

.user-info .name {
    font-size: 0.9rem;
    font-weight: 600;
}

.user-info .status {
    font-size: 0.75rem;
    color: var(--accent-green);
    display: flex;
    align-items: center;
    gap: 5px;
}

.user-info .status::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: var(--accent-green);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent-green);
}

/* Content Area Styling */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 2rem 3rem;
}

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

.header-title h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.header-title p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 4px;
}

.date-selector {
    background: var(--bg-secondary);
    border: 1px solid var(--border-card);
    padding: 8px 16px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
}

.date-selector input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    outline: none;
    font-family: inherit;
    cursor: pointer;
}

/* Grid of Cards */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.metric-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-card);
    border-radius: 20px;
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    transition: var(--transition-smooth);
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    background: var(--gradient-card);
    pointer-events: none;
}

.metric-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-hover);
    box-shadow: var(--shadow-neon);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 1rem;
}

.card-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.metric-card:nth-child(1) .card-icon {
    background: rgba(0, 242, 254, 0.1);
    color: var(--accent-cyan);
}

.metric-card:nth-child(2) .card-icon {
    background: rgba(139, 92, 246, 0.1);
    color: var(--accent-purple);
}

.metric-card:nth-child(3) .card-icon {
    background: rgba(236, 72, 153, 0.1);
    color: var(--accent-pink);
}

.metric-card:nth-child(4) .card-icon {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-green);
}

.card-value {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #FFF, #E5E7EB);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.card-footer {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 5px;
}

.card-footer span.trend-up {
    color: var(--accent-green);
    font-weight: 600;
}

.card-footer span.trend-down {
    color: var(--accent-pink);
    font-weight: 600;
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

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

.chart-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-card);
    border-radius: 24px;
    padding: 1.8rem;
    display: flex;
    flex-direction: column;
}

.chart-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chart-title span {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 400;
}

/* Sleep Phase Bars */
.sleep-phases {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.phase-bar-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.phase-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
}

.phase-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.phase-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.phase-dot.deep { background: var(--accent-purple); box-shadow: 0 0 8px var(--accent-purple); }
.phase-dot.rem { background: var(--accent-pink); box-shadow: 0 0 8px var(--accent-pink); }
.phase-dot.core { background: var(--accent-blue); box-shadow: 0 0 8px var(--accent-blue); }
.phase-dot.awake { background: var(--accent-orange); box-shadow: 0 0 8px var(--accent-orange); }

.phase-duration {
    font-weight: 600;
}

.phase-progress {
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    overflow: hidden;
}

.phase-fill {
    height: 100%;
    border-radius: 10px;
    width: 0%;
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.phase-fill.deep { background: var(--accent-purple); }
.phase-fill.rem { background: var(--accent-pink); }
.phase-fill.core { background: var(--accent-blue); }
.phase-fill.awake { background: var(--accent-orange); }

/* Activity & Workouts section */
.dashboard-bottom-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 768px) {
    .dashboard-bottom-grid {
        grid-template-columns: 1fr;
    }
}

.list-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-card);
    border-radius: 24px;
    padding: 1.8rem;
    max-height: 400px;
    overflow-y: auto;
}

.workout-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-card);
    border-radius: 16px;
    margin-bottom: 0.8rem;
    transition: var(--transition-smooth);
}

.workout-item:hover {
    border-color: var(--border-hover);
    transform: translateX(4px);
}

.workout-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-green);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.workout-details {
    flex: 1;
}

.workout-name {
    font-size: 0.95rem;
    font-weight: 600;
}

.workout-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.workout-calories {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--accent-cyan);
}

/* Loading overlay */
.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(0, 242, 254, 0.1);
    border-top: 3px solid var(--accent-cyan);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    filter: drop-shadow(0 0 10px rgba(0, 242, 254, 0.3));
    margin-bottom: 1rem;
}

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

/* ==========================================
   AUTH / LOGIN PAGES STYLING (Enigmix-Style)
   ========================================== */

.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background-color: var(--bg-primary);
}

.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-card);
    border-radius: 24px;
    padding: 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
    transition: var(--transition-smooth);
}

.glass-card:hover {
    border-color: var(--border-hover);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5), var(--shadow-neon);
}

.glass-card h1 {
    font-size: 2.2rem;
    font-weight: 800;
    text-align: center;
    background: var(--gradient-glow);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.auth-container .subtitle {
    color: var(--text-secondary);
    text-align: center;
    font-size: 0.9rem;
    margin-bottom: 30px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-container {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.input-container i {
    position: absolute;
    left: 15px;
    color: var(--text-muted);
    font-size: 1rem;
    transition: var(--transition-smooth);
    pointer-events: none;
}

.form-input {
    width: 100%;
    padding: 12px 16px 12px 42px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-card);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition-smooth);
}

.form-input:focus {
    border-color: var(--accent-cyan);
    background: rgba(255, 255, 255, 0.04);
}

.form-input:focus + i {
    color: var(--accent-cyan);
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--gradient-glow);
    border: none;
    border-radius: 12px;
    color: var(--bg-primary);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: var(--transition-smooth);
    box-shadow: var(--shadow-neon);
}

.btn-primary:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

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

.error-msg {
    display: none;
    background: rgba(239, 68, 68, 0.1);
    color: #F87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 10px;
    padding: 10px;
    font-size: 0.85rem;
    text-align: center;
    margin-top: 15px;
}

.logout-btn {
    margin-top: 1.5rem;
    padding: 10px 14px;
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.1);
    border-radius: 10px;
    color: #F87171;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition-smooth);
}

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

/* ==========================================
   TAB FILTERING SYSTEM
   ========================================== */

body.tab-sleep .metric-card:not(:nth-child(1)):not(:nth-child(3)),
body.tab-sleep .chart-card:not(:nth-child(2)),
body.tab-sleep .dashboard-bottom-grid {
    display: none !important;
}
body.tab-sleep .charts-grid {
    grid-template-columns: 1fr !important;
}

body.tab-hrv .metric-card:not(:nth-child(2)):not(:nth-child(3)):not(:nth-child(4)),
body.tab-hrv .chart-card:not(:nth-child(1)),
body.tab-hrv .dashboard-bottom-grid {
    display: none !important;
}
body.tab-hrv .charts-grid {
    grid-template-columns: 1fr !important;
}

body.tab-activity .metric-card,
body.tab-activity .charts-grid {
    display: none !important;
}
body.tab-activity .dashboard-bottom-grid {
    grid-template-columns: 1fr 1fr !important;
}

/* =========================================================================
   📊 RANGE ANALYSIS STYLING (Analisi Storica Intervalli)
   ========================================================================= */

.range-analysis-section {
    display: none;
    margin-top: 1.5rem;
    animation: fadeIn 0.4s ease-in-out;
}

body.tab-range .range-analysis-section {
    display: block;
}

body.tab-range .metrics-grid,
body.tab-range .charts-grid,
body.tab-range .dashboard-bottom-grid,
body.tab-range header .date-selector {
    display: none !important;
}

/* Range Inputs Card */
.range-controls-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    backdrop-filter: blur(12px);
    background-image: var(--gradient-card);
}

.range-inputs {
    display: flex;
    align-items: flex-end;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.range-inputs .input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
    min-width: 200px;
}

.range-inputs label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.range-inputs input[type="date"] {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-card);
    border-radius: 10px;
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    font-size: 1rem;
    outline: none;
    transition: var(--transition-smooth);
}

.range-inputs input[type="date"]:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px rgba(0, 242, 254, 0.1);
}

.range-btn {
    background: var(--gradient-glow);
    border: none;
    border-radius: 10px;
    color: #080B11;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    gap: 8px;
    height: 46px;
}

.range-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 242, 254, 0.3);
}

/* Range Metrics Grid */
.range-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Range Charts Grid */
.range-charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 1.5rem;
}

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

@media (max-width: 1024px) {
    .range-charts-grid {
        grid-template-columns: 1fr;
    }
}
