/* Unmoved - Meditation Stillness Monitor */
/* Dark, calm, meditation-focused design */

:root {
    --bg-deep: #0f1419;
    --bg-surface: #1a1f2e;
    --bg-elevated: #252b3b;
    --bg-hover: #2d3548;

    --accent: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.3);
    --accent-soft: #818cf8;

    --success: #34d399;
    --success-glow: rgba(52, 211, 153, 0.2);

    --warning: #fbbf24;
    --danger: #f87171;

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --border: rgba(148, 163, 184, 0.1);
    --border-accent: rgba(99, 102, 241, 0.3);

    --radius: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;

    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-deep);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

.hidden {
    display: none !important;
}

/* App Container */
.app {
    min-height: 100vh;
    position: relative;
}

/* Mode Containers */
.mode {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ==================== SETUP MODE ==================== */

.setup-header {
    text-align: center;
    margin-bottom: 32px;
}

.setup-header h1 {
    font-size: 2.5rem;
    font-weight: 300;
    letter-spacing: 0.1em;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.setup-header p {
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* Camera Preview */
.camera-preview {
    position: relative;
    width: 100%;
    max-width: 480px;
    aspect-ratio: 4/3;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
    margin-bottom: 32px;
}

.camera-preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
    opacity: 0.9;
}

.camera-preview canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    transform: scaleX(-1);
}

.camera-status {
    position: absolute;
    bottom: 16px;
    left: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(15, 20, 25, 0.8);
    padding: 8px 14px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    color: var(--text-secondary);
    backdrop-filter: blur(8px);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Calibration Section */
.calibration-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 40px;
}

.motion-ring {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--bg-surface);
    border: 3px solid var(--border);
    overflow: hidden;
    margin-bottom: 12px;
}

.motion-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 0%;
    background: linear-gradient(to top, var(--success), var(--accent));
    transition: height 0.15s ease-out, background 0.3s ease;
}

.motion-fill.elevated {
    background: linear-gradient(to top, var(--warning), var(--danger));
}

.motion-threshold {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--text-secondary);
    bottom: 30%;
}

.calibration-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
}

/* Start Button */
.start-button {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--accent);
    color: white;
    border: none;
    padding: 18px 48px;
    border-radius: var(--radius-full);
    font-size: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 0 40px var(--accent-glow);
}

.start-button:hover {
    transform: scale(1.05);
    box-shadow: 0 0 60px var(--accent-glow);
}

.start-button:active {
    transform: scale(0.98);
}

.start-icon {
    font-size: 0.9rem;
}

/* Settings Toggle */
.settings-toggle {
    position: fixed;
    top: 24px;
    right: 24px;
    width: 44px;
    height: 44px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.settings-toggle:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

/* Settings Panel */
.settings-panel {
    position: fixed;
    top: 80px;
    right: 24px;
    width: 300px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    z-index: 100;
    animation: slideIn 0.3s ease-out;
}

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

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

.settings-header h3 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
}

.settings-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.settings-close:hover {
    color: var(--text-primary);
}

.setting-row label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.setting-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.setting-value {
    font-size: 0.9rem;
    color: var(--accent-soft);
    font-weight: 600;
}

.setting-row input[type="range"] {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-elevated);
    border-radius: 3px;
    outline: none;
}

.setting-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
}

.setting-row input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.setting-hints {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* History Toggle */
.history-toggle {
    position: fixed;
    bottom: 24px;
    left: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 12px 20px;
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.history-toggle:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

/* ==================== FOCUS MODE ==================== */

#focus-mode {
    background: var(--bg-deep);
    justify-content: center;
}

.focus-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 48px;
}

.focus-timer {
    font-size: 5rem;
    font-weight: 200;
    letter-spacing: 0.05em;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

/* Stillness Ring */
.stillness-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.stillness-ring {
    position: relative;
    width: 180px;
    height: 180px;
}

.stillness-ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.ring-bg {
    fill: none;
    stroke: var(--bg-elevated);
    stroke-width: 8;
}

.ring-progress {
    fill: none;
    stroke: var(--success);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 283;
    stroke-dashoffset: 283;
    transition: stroke-dashoffset 0.3s ease-out, stroke 0.3s ease;
}

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

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

.stillness-score {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    font-weight: 300;
    color: var(--text-primary);
}

.stillness-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.15em;
}

/* Stop Button */
.stop-button {
    background: transparent;
    border: 2px solid var(--border);
    color: var(--text-secondary);
    padding: 14px 36px;
    border-radius: var(--radius-full);
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    opacity: 0.6;
}

.stop-button:hover {
    opacity: 1;
    border-color: var(--danger);
    color: var(--danger);
}

/* Focus Hint */
.focus-hint {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.focus-hint.visible {
    opacity: 1;
}

.focus-hint kbd {
    display: inline-block;
    background: var(--bg-elevated);
    padding: 4px 10px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.85rem;
    margin: 0 2px;
}

/* ==================== REVIEW MODE ==================== */

#review-mode {
    padding-top: 60px;
}

.review-container {
    width: 100%;
    max-width: 700px;
    animation: slideUp 0.6s ease-out;
}

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

.review-header {
    text-align: center;
    margin-bottom: 40px;
}

.review-header h2 {
    font-size: 1.75rem;
    font-weight: 400;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.review-date {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Summary Grid */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 16px;
    margin-bottom: 40px;
}

.summary-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 16px;
    text-align: center;
    transition: var(--transition);
}

.summary-card:hover {
    border-color: var(--border-accent);
    transform: translateY(-2px);
}

.summary-card.primary {
    border-color: var(--accent);
    background: linear-gradient(135deg, var(--bg-surface), rgba(99, 102, 241, 0.1));
}

.summary-card.success {
    border-color: var(--success);
    background: linear-gradient(135deg, var(--bg-surface), rgba(52, 211, 153, 0.1));
}

.summary-card.warning {
    border-color: var(--warning);
    background: linear-gradient(135deg, var(--bg-surface), rgba(251, 191, 36, 0.1));
}

.summary-icon {
    display: block;
    font-size: 1.25rem;
    margin-bottom: 8px;
    opacity: 0.7;
}

.summary-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.summary-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Chart Section */
.chart-section {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 32px;
}

.chart-section h3 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.chart-wrapper {
    position: relative;
}

#session-chart {
    width: 100%;
    height: auto;
}

/* Review Actions */
.review-actions {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

.action-button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 32px;
    border-radius: var(--radius-full);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.action-button.primary {
    background: var(--accent);
    border: none;
    color: white;
}

.action-button.primary:hover {
    transform: scale(1.05);
    box-shadow: 0 0 40px var(--accent-glow);
}

.action-button.secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.action-button.secondary:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

/* ==================== HISTORY SIDEBAR ==================== */

.history-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    animation: fadeIn 0.3s ease;
}

.history-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 360px;
    max-width: 90vw;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    z-index: 300;
    display: flex;
    flex-direction: column;
    animation: slideFromLeft 0.3s ease-out;
}

@keyframes slideFromLeft {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h3 {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-primary);
}

.sidebar-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.75rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.sidebar-close:hover {
    color: var(--text-primary);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.history-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
    font-size: 0.9rem;
    line-height: 1.6;
}

.history-item {
    background: var(--bg-elevated);
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.history-item:hover {
    border-color: var(--border-accent);
}

.history-item.selected {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.1);
}

.history-item-date {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.history-item-stats {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.history-item-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.history-item-actions button {
    flex: 1;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.history-item-actions .view-btn {
    background: var(--accent);
    border: none;
    color: white;
}

.history-item-actions .view-btn:hover {
    background: var(--accent-soft);
}

.history-item-actions .delete-btn {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
}

.history-item-actions .delete-btn:hover {
    background: var(--danger);
    color: white;
}

.clear-history-btn {
    margin: 16px;
    padding: 12px;
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
    border-radius: var(--radius);
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
}

.clear-history-btn:hover {
    background: var(--danger);
    color: white;
}

/* ==================== RESPONSIVE ==================== */

@media (max-width: 640px) {
    .mode {
        padding: 24px 16px;
    }

    .setup-header h1 {
        font-size: 2rem;
    }

    .camera-preview {
        max-width: 100%;
    }

    .start-button {
        padding: 16px 40px;
        font-size: 1rem;
    }

    .focus-timer {
        font-size: 3.5rem;
    }

    .stillness-ring {
        width: 140px;
        height: 140px;
    }

    .stillness-score {
        font-size: 2.25rem;
    }

    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .chart-section {
        padding: 20px 16px;
    }

    .review-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .action-button {
        justify-content: center;
    }

    .settings-panel {
        left: 16px;
        right: 16px;
        width: auto;
    }

    .history-sidebar {
        width: 100%;
        max-width: 100%;
    }
}

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

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