/* ===========================
   Shared Monitoring Tool Styles
   Used by all FX Posture tools
   =========================== */

/* Navigation Bar */
.main-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(10px);
    background: rgba(var(--surface-rgb), 0.95);
}

.main-nav .logo {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.main-nav .nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.main-nav .nav-links a {
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
    position: relative;
}

.main-nav .nav-links a:hover {
    color: var(--accent);
}

.main-nav .nav-links a.active::after {
    content: '';
    position: absolute;
    bottom: -0.5rem;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
}

/* Adjust body padding when nav is present */
body.with-nav {
    padding-top: 4rem;
}

/* Statistics Card */
.stats-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.stats-card .stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stats-card .stat-label {
    color: var(--subtle);
    font-size: 0.9rem;
}

.stats-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
}

.stats-card .stat-value.good {
    color: var(--accent);
}

.stats-card .stat-value.warning {
    color: #FFA500;
}

.stats-card .stat-value.error {
    color: var(--error);
}

/* Progress Ring */
.progress-ring {
    position: relative;
    width: 200px;
    height: 200px;
}

.progress-ring circle {
    fill: none;
    stroke-width: 8;
    stroke-linecap: round;
    transform: rotate(-90deg);
    transform-origin: 50% 50%;
    transition: stroke-dashoffset 0.3s;
}

.progress-ring .ring-bg {
    stroke: var(--border);
}

.progress-ring .ring-progress {
    stroke: var(--accent);
}

.progress-ring .ring-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.progress-ring .ring-time {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
}

.progress-ring .ring-label {
    font-size: 0.9rem;
    color: var(--subtle);
    margin-top: 0.25rem;
}

/* Tool Cards (for dashboard) */
.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.tool-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
    text-decoration: none;
    color: var(--text);
    transition: all 0.3s;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.tool-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--accent);
    transform: scaleX(0);
    transition: transform 0.3s;
}

.tool-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    border-color: var(--accent);
}

.tool-card:hover::before {
    transform: scaleX(1);
}

.tool-card .tool-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.tool-card .tool-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.tool-card .tool-description {
    color: var(--subtle);
    font-size: 0.9rem;
    line-height: 1.5;
}

.tool-card .tool-badge {
    display: inline-block;
    background: var(--accent);
    color: var(--bg);
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 1rem;
}

/* Timer Display */
.timer-display {
    font-size: 4rem;
    font-weight: 700;
    text-align: center;
    margin: 2rem 0;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

.timer-label {
    text-align: center;
    color: var(--subtle);
    font-size: 1.1rem;
    margin-top: -1rem;
    margin-bottom: 2rem;
}

/* Exercise Overlay */
.exercise-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 2rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.exercise-overlay.active {
    opacity: 1;
    visibility: visible;
}

.exercise-content {
    background: var(--surface);
    border-radius: 24px;
    padding: 3rem;
    max-width: 600px;
    text-align: center;
}

.exercise-content .exercise-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.exercise-content .exercise-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text);
}

.exercise-content .exercise-description {
    font-size: 1.1rem;
    color: var(--subtle);
    line-height: 1.6;
    margin-bottom: 2rem;
}

.exercise-content .exercise-timer {
    font-size: 3rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 2rem;
}

/* Level Indicator (for neck tilt) */
.level-indicator {
    width: 300px;
    height: 60px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 30px;
    position: relative;
    overflow: hidden;
    margin: 2rem auto;
}

.level-bubble {
    width: 40px;
    height: 40px;
    background: var(--accent);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    transition: left 0.3s;
    box-shadow: 0 4px 12px rgba(64, 220, 165, 0.4);
}

.level-indicator .center-line {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--text);
    opacity: 0.3;
    transform: translateX(-50%);
}

/* Heatmap Visualization */
.heatmap-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin: 1rem 0;
}

.heatmap-cell {
    aspect-ratio: 1;
    background: var(--surface);
    border-radius: 4px;
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.heatmap-cell.intensity-0 {
    opacity: 0.2;
}

.heatmap-cell.intensity-1 {
    background: rgba(64, 220, 165, 0.2);
}

.heatmap-cell.intensity-2 {
    background: rgba(64, 220, 165, 0.4);
}

.heatmap-cell.intensity-3 {
    background: rgba(64, 220, 165, 0.6);
}

.heatmap-cell.intensity-4 {
    background: rgba(64, 220, 165, 0.8);
}

.heatmap-cell.intensity-5 {
    background: rgba(64, 220, 165, 1);
}

/* Distance Indicator */
.distance-meter {
    width: 100%;
    height: 30px;
    background: linear-gradient(to right,
            #FF6B6B 0%,
            #FFA500 33%,
            #40DCA5 50%,
            #FFA500 67%,
            #FF6B6B 100%);
    border-radius: 15px;
    position: relative;
    margin: 1rem 0;
}

.distance-marker {
    width: 4px;
    height: 40px;
    background: white;
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    transition: left 0.3s;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
}

.distance-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--subtle);
}

/* Desktop Optimization - Compact Horizontal Layout */
@media (min-width: 769px) {

    /* Main monitoring layout - single column grid for all tools */
    .zen-container {
        display: grid;
        grid-template-columns: 1fr;
        gap: 2rem;
        padding: 2rem;
        padding-bottom: 120px;
        /* Space for sticky CTA */
        max-width: 800px;
        align-items: center;
        margin: 0 auto;
    }

    /* Dashboard specific layout - single column */
    .zen-container.dashboard-layout {
        max-width: 1200px;
    }

    .zen-container.dashboard-layout>* {
        grid-column: 1 / -1 !important;
        width: 100%;
    }


    /* Override for How To Use page - restore vertical layout */
    body.how-to-use .zen-container {
        display: flex;
        flex-direction: column;
        max-width: 1000px;
        height: auto;
        min-height: auto;
    }

    .zen-container .main-header {
        grid-column: 1 / -1;
        text-align: center;
        margin-bottom: 0;
    }

    /* Limit visual area height on desktop to reduce vertical scroll */
    .visual-area video,
    .visual-area canvas {
        max-height: 400px;
        width: 100%;
        object-fit: contain;
    }

    /* Ensure container fills viewport without overflow */
    .zen-container {
        min-height: 100vh;
        overflow-y: auto;
    }

    .zen-container .visual-area {
        grid-column: 1 / -1;
        grid-row: auto;
        max-width: 100%;
        justify-self: center;
        margin: 0 auto;
        width: 100%;
    }

    .zen-container #statsPanel,
    .zen-container #positionPanel {
        grid-column: 1 / -1;
        grid-row: auto;
        justify-self: center;
        margin-left: 0;
        margin-top: 0 !important;
        width: 100%;
        max-width: 600px;
    }

    .zen-container .primary-actions,
    .zen-container #actionContainer {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 50;
        background: rgba(var(--surface-rgb), 0.95);
        backdrop-filter: blur(20px);
        border-top: 1px solid var(--border);
        padding: 1.5rem 2rem;
        margin: 0;
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.1);
        display: flex;
        justify-content: center;
    }

    /* Compact stats cards */
    .stats-card {
        padding: 1rem;
        gap: 0.75rem;
    }

    .stats-card .stat-value {
        font-size: 1.2rem;
    }

    .stats-card .stat-label {
        font-size: 0.85rem;
    }

    /* Smaller timer on desktop */
    .timer-display {
        font-size: 3rem;
        margin: 1rem 0;
    }

    .timer-label {
        font-size: 0.95rem;
        margin-top: -0.5rem;
        margin-bottom: 1rem;
    }

    /* Compact progress ring */
    .progress-ring {
        width: 220px;
        height: 220px;
    }

    .progress-ring .ring-time {
        font-size: 1.6rem;
    }

    .progress-ring .ring-label {
        font-size: 0.85rem;
    }

    /* Reduce visual area aspect ratio on desktop for compactness */
    .visual-area {
        aspect-ratio: 16/9;
    }

    /* Compact level indicator */
    .level-indicator {
        width: 250px;
        height: 50px;
        margin: 0.5rem auto;
    }

    .level-bubble {
        width: 36px;
        height: 36px;
    }

    /* Compact position panel (neck monitor) */
    /* Fixed selectors for position panel */
    #positionPanel>div:first-child {
        margin-bottom: 1rem !important;
    }

    #positionPanel>div:last-child {
        margin-top: 1rem !important;
        padding: 1rem !important;
    }

    /* Compact heatmap */
    .heatmap-grid {
        margin: 0.5rem 0;
        gap: 3px;
    }

    /* Compact exercise overlay */
    .exercise-content {
        padding: 2rem;
    }

    .exercise-content .exercise-title {
        font-size: 1.75rem;
        margin-bottom: 0.75rem;
    }

    .exercise-content .exercise-description {
        font-size: 1rem;
        margin-bottom: 1.5rem;
    }

    .exercise-content .exercise-timer {
        font-size: 2.5rem;
        margin-bottom: 1.5rem;
    }

    /* Compact navigation */
    body.with-nav {
        padding-top: 3.5rem;
    }

    .main-nav {
        padding: 0.5rem 2rem;
    }

    /* Break reminder specific - center ring on desktop */
    /* Break reminder specific - center ring on desktop */
    .zen-container .timer-container {
        grid-column: 1 / -1;
        justify-self: center;
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        margin-bottom: 2rem;
    }
}

/* Responsive adjustments for mobile */
@media (max-width: 768px) {
    .main-nav {
        padding: 0.5rem 1rem;
    }

    .main-nav .nav-links {
        gap: 1rem;
    }

    .main-nav .nav-links a {
        font-size: 0.85rem;
    }

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

    .timer-display {
        font-size: 3rem;
    }

    .progress-ring {
        width: 150px;
        height: 150px;
    }

    .level-indicator {
        width: 200px;
    }

    .exercise-content {
        padding: 2rem 1.5rem;
    }
}

/* Print styles */
@media print {

    .main-nav,
    .primary-actions,
    .settings-drawer,
    .overlay,
    .tool-card:hover {
        display: none !important;
    }
}