:root {
    --bg-dark: #0d0f12;
    --bg-surface: rgba(20, 24, 33, 0.65);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --primary: #00d2ff;
    --primary-gradient: linear-gradient(135deg, #00d2ff 0%, #0066ff 100%);
    --secondary: #a855f7;
    --secondary-gradient: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%);
    --accent-orange: #f97316;
    --accent-green: #10b981;
    --accent-red: #ef4444;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Outfit', 'Inter', sans-serif;
    overflow: hidden;
    height: 100vh;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

.sidebar {
    width: 260px;
    background: rgba(15, 20, 30, 0.9);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px;
    z-index: 100;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
}

.logo-icon {
    font-size: 28px;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-header h2 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    border-radius: 12px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
}

.nav-item i {
    font-size: 18px;
}

.nav-item:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    color: #fff;
    background: var(--primary-gradient);
    box-shadow: 0 4px 20px rgba(0, 210, 255, 0.25);
}

.sidebar-footer {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
}

.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
    background: radial-gradient(circle at 50% 0%, #161a25 0%, #0a0c10 70%);
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
    border-bottom: 1px solid var(--border-color);
}

.page-title h1 {
    font-size: 26px;
    font-weight: 600;
}

.user-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-muted);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--accent-green);
    box-shadow: 0 0 10px var(--accent-green);
}

.content-body {
    padding: 32px 40px;
}

.dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.kpi-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.kpi-card {
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    padding: 24px;
    border-radius: 16px;
    transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.kpi-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 12px 24px rgba(0,0,0,0.3);
}

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

.kpi-title {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
}

.kpi-icon {
    font-size: 20px;
}

.kpi-value {
    font-size: 28px;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    margin-bottom: 6px;
}

.kpi-value .unit {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-muted);
}

.kpi-desc {
    font-size: 12px;
    color: var(--text-muted);
}

.text-cyan { color: var(--primary); }
.text-purple { color: var(--secondary); }
.text-orange { color: var(--accent-orange); }
.text-green { color: var(--accent-green); }

.charts-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 24px;
}

.chart-card {
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
}

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

.chart-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.chart-wrapper {
    position: relative;
    height: 300px;
    width: 100%;
}

.details-row {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 24px;
}

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

.detail-card {
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    flex-direction: column;
}

.detail-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 14px;
    margin-bottom: 18px;
}

.detail-header h3 {
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-double {
    grid-column: span 1;
}

.target-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.form-group label {
    font-size: 14px;
    color: var(--text-muted);
}

.form-input {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 16px;
    color: #fff;
    font-family: inherit;
    font-size: 16px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(0, 210, 255, 0.2);
}

.btn-submit {
    background: var(--primary-gradient);
    border: none;
    border-radius: 10px;
    color: #fff;
    font-family: inherit;
    font-weight: 600;
    font-size: 16px;
    padding: 14px;
    cursor: pointer;
    transition: opacity 0.3s ease, transform 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.btn-submit:hover {
    opacity: 0.9;
}

.btn-submit:active {
    transform: scale(0.98);
}

.form-message {
    font-size: 14px;
    margin-top: 10px;
    text-align: center;
}

.form-message.success {
    color: var(--accent-green);
}

.form-message.error {
    color: var(--accent-red);
}

.overflow-y {
    max-height: 380px;
    overflow-y: auto;
}

.premium-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.premium-table th, .premium-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.premium-table th {
    color: var(--text-muted);
    font-weight: 500;
    position: sticky;
    top: 0;
    background: rgba(15, 20, 30, 0.9);
}

.premium-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.activities-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 24px;
    height: calc(100vh - 160px);
}

@media (max-width: 900px) {
    .activities-grid {
        grid-template-columns: 1fr;
        height: auto;
    }
}

.activities-list-card, .set-details-card {
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.card-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 14px;
    margin-bottom: 16px;
}

.card-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.activities-list-body {
    flex-grow: 1;
    overflow-y: auto;
}

.activity-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.activity-item:hover {
    border-color: var(--primary);
    background: rgba(0, 210, 255, 0.05);
    transform: translateX(4px);
}

.activity-icon-wrapper {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
}

.activity-info {
    flex-grow: 1;
}

.activity-type-name {
    font-weight: 600;
    margin-bottom: 4px;
}

.activity-meta {
    display: flex;
    gap: 14px;
    font-size: 12px;
    color: var(--text-muted);
}

.activity-arrow {
    color: var(--text-muted);
}

.set-details-body {
    flex-grow: 1;
    overflow-y: auto;
}

.placeholder-message {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    gap: 16px;
    padding: 40px;
}

.placeholder-message i {
    font-size: 48px;
    opacity: 0.3;
}

.placeholder-message .sub {
    font-size: 12px;
    margin-top: 8px;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    gap: 16px;
}

.loading-spinner i {
    font-size: 32px;
    color: var(--primary);
}

.activity-detail-summary {
    background: rgba(255,255,255,0.02);
    border-left: 4px solid var(--primary);
    padding: 16px;
    border-radius: 0 12px 12px 0;
    margin-bottom: 24px;
}

.activity-detail-summary h4 {
    font-size: 18px;
    margin-bottom: 6px;
}

.activity-detail-summary p {
    font-size: 13px;
    color: var(--text-muted);
}

.exercise-group {
    margin-bottom: 32px;
}

.exercise-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 8px;
}

.exercise-group-header h5 {
    font-size: 16px;
    font-weight: 600;
}

.exercise-stats-pill {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--text-muted);
}

.exercise-stats-pill strong {
    color: #fff;
}

.set-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.set-table th, .set-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.set-table th {
    color: var(--text-muted);
    font-weight: 500;
}

.skipped-row {
    opacity: 0.4;
    text-decoration: line-through;
}

.status-badge {
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.status-badge.completed {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
}

.status-badge.skipped {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
}

.period-select {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px 12px;
    color: #fff;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.period-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 8px rgba(0, 210, 255, 0.2);
}

.period-select option {
    background-color: var(--bg-dark);
    color: #fff;
}

/* Phase 2.2 Styles: Calendar and Exercise Trend */
.activities-dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.exercise-trend-card {
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
}

.filter-tabs {
    display: flex;
    gap: 8px;
    background: rgba(0, 0, 0, 0.3);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.filter-tab {
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-tab.active {
    background: var(--primary-gradient);
    color: #fff;
    box-shadow: 0 2px 10px rgba(0, 210, 255, 0.2);
}

.filter-tab:hover:not(.active) {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

/* Calendar Screen Styles */
.calendar-card {
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.calendar-ctrl {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.calendar-ctrl h2 {
    font-size: 24px;
    font-weight: 700;
}

.btn-ctrl {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: #fff;
    padding: 10px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-ctrl:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary);
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 14px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
    margin-bottom: 12px;
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-auto-rows: minmax(110px, 1fr);
    gap: 8px;
}

.calendar-day-cell {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.3s ease;
}

.calendar-day-cell:hover:not(.empty) {
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.03);
}

.calendar-day-cell.empty {
    opacity: 0.2;
    background: none;
    border-style: dashed;
}

.day-num {
    font-size: 14px;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
}

.cell-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
    font-size: 11px;
    font-weight: 500;
}

.cell-weight {
    color: var(--primary);
}

.cell-calories.under {
    color: var(--accent-green);
}

.cell-calories.over {
    color: var(--accent-red);
}

.cell-activity-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.act-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 5px;
    font-size: 11px;
    cursor: default;
}

.act-strength {
    background: rgba(168, 85, 247, 0.2);
    border: 1px solid rgba(168, 85, 247, 0.4);
}

.act-hiit {
    background: rgba(249, 115, 22, 0.2);
    border: 1px solid rgba(249, 115, 22, 0.4);
}

/* Connection Status bar and badges */
.user-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.25);
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-indicator.local-active {
    background-color: var(--primary);
    box-shadow: 0 0 8px var(--primary);
}

.status-indicator.vpn-active {
    background-color: var(--secondary);
    box-shadow: 0 0 8px var(--secondary);
}

.status-indicator.funnel-active {
    background-color: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green);
}

.status-badge-ts {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: #fff;
    letter-spacing: 0.3px;
}

.status-badge-ts.funnel {
    background: #10b981; /* Tailscale Green */
}

.status-badge-ts.vpn {
    background: #3b82f6; /* Tailscale Blue */
}

.status-badge-ts.local {
    background: #6b7280; /* Gray */
}

.status-text-ts {
    font-weight: 500;
    color: var(--text-main);
}

.logout-nav-item:hover {
    background: rgba(239, 68, 68, 0.1) !important;
    color: var(--accent-red) !important;
}

/* --- Mobile Bottom Navigation and Responsive Styles --- */
.mobile-nav {
    display: none;
}

@media (max-width: 768px) {
    body {
        overflow-y: auto;
        height: auto;
    }
    
    .app-container {
        flex-direction: column;
        height: auto;
        width: 100%;
    }
    
    .sidebar {
        display: none !important;
    }
    
    .main-content {
        width: 100%;
        height: auto;
        min-height: 100vh;
        padding-bottom: 80px; /* Margin for bottom nav */
    }
    
    .top-bar {
        padding: 16px 20px;
        flex-direction: row; /* Keep title and badge side-by-side but tighter */
        justify-content: space-between;
        align-items: center;
        background: rgba(15, 20, 30, 0.8);
        backdrop-filter: blur(10px);
        border-bottom: 1px solid var(--border-color);
        position: sticky;
        top: 0;
        z-index: 100;
    }
    
    .page-title h1 {
        font-size: 18px;
    }
    
    .user-status {
        font-size: 11px;
        padding: 4px 10px;
    }
    
    .content-body {
        padding: 16px 12px 32px 12px;
    }
    
    .kpi-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .kpi-card {
        padding: 14px;
        border-radius: 12px;
    }
    
    .kpi-value {
        font-size: 20px;
    }
    
    .kpi-value .unit {
        font-size: 11px;
    }
    
    .charts-row, .details-row, .activities-grid {
        grid-template-columns: 1fr !important;
        gap: 16px;
    }
    
    .chart-card, .detail-card, .activities-list-card, .set-details-card, .calendar-card {
        padding: 16px;
        border-radius: 12px;
    }
    
    .chart-wrapper {
        height: 220px;
    }
    
    .overflow-y {
        max-height: none;
        overflow-x: auto;
    }
    
    .premium-table {
        min-width: 500px;
    }
    
    .premium-table th, .premium-table td {
        padding: 8px 10px;
        font-size: 12px;
    }
    
    /* Calendar Cell Optimizations */
    .calendar-days {
        grid-auto-rows: minmax(70px, 1fr);
        gap: 4px;
    }
    
    .calendar-day-cell {
        padding: 6px;
        border-radius: 8px;
    }
    
    .day-num {
        font-size: 11px;
    }
    
    .cell-content {
        margin-top: 4px;
        font-size: 9px;
        gap: 2px;
    }
    
    .cell-activity-badges {
        margin-top: 4px;
        gap: 2px;
    }
    
    .act-badge {
        width: 14px;
        height: 14px;
        border-radius: 3px;
        font-size: 8px;
    }
    
    /* Mobile Bottom Navigation Styles */
    .mobile-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 64px;
        background: rgba(15, 20, 30, 0.95);
        backdrop-filter: blur(20px);
        border-top: 1px solid var(--border-color);
        justify-content: space-around;
        align-items: center;
        z-index: 999;
        padding: 0 10px;
    }
    
    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        text-decoration: none;
        color: var(--text-muted);
        font-size: 10px;
        font-weight: 600;
        transition: all 0.3s ease;
        padding: 8px 0;
        flex-grow: 1;
        text-align: center;
    }
    
    .mobile-nav-item i {
        font-size: 18px;
    }
    
    .mobile-nav-item:hover {
        color: var(--text-main);
    }
    
    .mobile-nav-item.active {
        color: var(--primary);
    }
    
    .logout-nav-item-mobile {
        color: var(--accent-red) !important;
    }
}
