/* Mobile App Styles */
:root {
    /* Colors - Reused & Refined */
    --bg-primary: #0d0d0d;
    --bg-secondary: #161616;
    --bg-card: #1a1a1a;
    --bg-highlight: #252525;

    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #6b6b6b;

    --accent: #d4a574;
    --accent-dim: rgba(212, 165, 116, 0.15);
    --accent-glow: rgba(212, 165, 116, 0.3);

    --success: #4ade80;
    --error: #f87171;

    /* Layout */
    --header-height: 60px;
    --nav-height: 60px;
    /* Bottom bar */
    --roast-nav-height: 50px;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 999px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
    /* Prevent pull-to-refresh on mobile if possible/desired */
    overscroll-behavior-y: none;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    /* Dynamic viewport height */
}

/* Top Bar */
.top-bar {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-md);
    background: rgba(13, 13, 13, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.logo-icon {
    font-size: 1.5rem;
}

.logo-text {
    font-weight: 700;
    font-size: 1.1rem;
    background: linear-gradient(135deg, var(--accent) 0%, #fff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Stopwatch */
.stopwatch-container {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 12px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.timer-display {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 42px;
    text-align: right;
}

.timer-btn {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s;
}

.timer-btn:active {
    transform: scale(0.9);
}

.timer-btn.reset {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    padding: var(--space-sm);
    cursor: pointer;
}

/* Roast Nav (Sticky below header) */
.roast-nav {
    height: var(--roast-nav-height);
    background: var(--bg-primary);
    position: sticky;
    top: var(--header-height);
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* Space between scroll and stopwatch */
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-right: var(--space-md);
    /* Padding for stopwatch */
}

.roast-scroll {
    display: flex;
    gap: var(--space-sm);
    padding: 0 var(--space-md);
    overflow-x: auto;
    width: 100%;
    scrollbar-width: none;
    /* Firefox */
    flex: 1;
    /* Take available space */
    margin-right: var(--space-md);
    /* Space before stopwatch */
}

.roast-scroll::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

.roast-chip {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    padding: 6px 16px;
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
}

.roast-chip.active {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
}

/* Main Content */
.content-area {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
    padding-bottom: calc(var(--nav-height) + var(--space-lg));
    /* Space for bottom nav */
}

.view-section {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Style Toggle Card */
.style-toggle-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

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

/* Switch Component */
.switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-highlight);
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-secondary);
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--accent-dim);
    border: 1px solid var(--accent);
}

input:checked+.slider:before {
    transform: translateX(22px);
    background-color: var(--accent);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.stat-item {
    background: var(--bg-card);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-item.full-width {
    grid-column: span 2;
    flex-direction: row;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
}

.stat-item i {
    color: var(--accent);
    font-size: 1.2rem;
    margin-bottom: var(--space-sm);
}

.stat-item.full-width i {
    margin-bottom: 0;
}

.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Instructions List */
.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: var(--space-md);
    color: var(--text-primary);
    padding-left: var(--space-xs);
    border-left: 3px solid var(--accent);
    line-height: 1;
}

.instructions-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.instruction-card {
    background: var(--bg-card);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    gap: var(--space-md);
}

.step-num {
    background: var(--accent-dim);
    color: var(--accent);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 2px;
}

.step-content h4 {
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.step-content p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.step-detail {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--accent);
    background: rgba(212, 165, 116, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Chart */
.chart-wrapper {
    background: var(--bg-card);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    height: 300px;
    margin-bottom: var(--space-lg);
}

/* Phases List */
.phases-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.phase-item {
    background: var(--bg-secondary);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.phase-val {
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent);
    font-size: 0.9rem;
}

/* Tips & Troubleshooting */
.tips-list,
.troubleshooting-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.tip-card,
.trouble-card {
    background: var(--bg-card);
    padding: var(--space-md);
    border-radius: var(--radius-md);
}

.tip-card h4 {
    color: var(--accent);
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.tip-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.trouble-card .problem {
    color: var(--error);
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.trouble-card .solution {
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding-left: 20px;
}

/* Bottom Nav */
.bottom-nav {
    height: var(--nav-height);
    background: rgba(13, 13, 13, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    width: 60px;
    transition: color 0.2s;
}

.nav-item i {
    font-size: 1.2rem;
    margin-bottom: 2px;
}

.nav-item.active {
    color: var(--accent);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    width: 100%;
    max-width: 400px;
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    padding: var(--space-md) 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
}

.setting-val {
    color: var(--accent);
    font-family: 'JetBrains Mono', monospace;
}

.modal-note {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: var(--space-lg);
    text-align: center;
}

/* Landscape Adjustments */
@media (orientation: landscape) and (max-height: 500px) {
    .app-container {
        flex-direction: row;
    }

    .top-bar {
        display: none;
    }

    /* Hide top bar in landscape to save space */

    .bottom-nav {
        position: static;
        width: 70px;
        height: 100vh;
        flex-direction: column;
        justify-content: center;
        gap: var(--space-xl);
        border-top: none;
        border-right: 1px solid rgba(255, 255, 255, 0.05);
        padding-bottom: 0;
    }

    .content-area {
        padding-bottom: var(--space-md);
    }

    .roast-nav {
        top: 0;
    }
}