/* === Buteyko Page Overrides === */

body {
    --accent-color: #c0392b;
    --secondary-accent: #2563eb;

    line-height: normal;
    padding: 20px;
    min-height: 100vh;
    box-sizing: border-box;
}

/* Container for the main content area */
.container {
    margin: 20px auto;
    background: var(--card-bg);
    border-radius: 16px;
    padding: 40px;
    box-shadow: var(--shadow-md);
    text-align: center;
}

p {
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.timer-display {
    font-size: 4rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 20px 0;
    font-variant-numeric: tabular-nums;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
}

button {
    padding: 12px 24px;
    font-size: 1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
    font-weight: 600;
}

button:active {
    transform: scale(0.98);
}

.btn-start {
    background-color: var(--secondary-accent);
    color: white;
}

.btn-stop {
    background-color: var(--accent-color);
    color: white;
}

.btn-reset {
    background-color: var(--gray-muted);
    color: white;
}

.session-info {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
}

.quick-info-list {
    text-align: left;
    margin: 0 auto;
    max-width: 400px;
    padding-left: 20px;
}

/* Protocol Specifics */
.step-indicator {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.step-title {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-bottom: 20px;
}

.pulse-input {
    font-size: 2.5rem;
    padding: 10px;
    width: 120px;
    text-align: center;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    color: var(--primary-color);
    outline: none;
    margin: 20px 0;
    background: var(--card-bg);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.pulse-input:focus {
    border-color: var(--secondary-accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Roadmap List */
.roadmap-title {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.2rem;
    color: var(--primary-color);
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 10px;
}

.step-list {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: step-counter;
}

.step-item {
    padding: 10px 12px;
    margin-bottom: 8px;
    border-radius: 8px;
    background: var(--bg-hover);
    border: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.step-item::before {
    counter-increment: step-counter;
    content: counter(step-counter) ". ";
    color: var(--text-muted);
    margin-right: 8px;
    font-weight: bold;
}

.step-item.active {
    border-left: 4px solid var(--secondary-accent);
    background: var(--card-bg);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

.step-item.completed {
    background-color: #edf5ef;
    border-color: #c4d8c8;
    color: var(--text-secondary);
}

.step-item.completed::before {
    color: var(--success-color);
    content: "\2713  ";
}

.step-result-text {
    font-weight: bold;
    color: var(--primary-color);
    font-size: 0.85rem;
}

/* Pulse timer buttons */
.pulse-timer-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
}

.pulse-timer-btn {
    padding: 10px 20px;
    font-size: 1rem;
}

.pulse-timer-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pulse-bpm-info {
    font-size: 0.85rem;
    color: var(--success-color);
    margin-top: 8px;
    min-height: 1.2em;
}

.tab-body {
    min-height: 420px;
    display: flex;
    flex-direction: column;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Protocol two-column layout */
.protocol-layout {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    text-align: center;
}

.protocol-main {
    flex: 1;
    min-width: 0;
}

.protocol-sidebar {
    width: 280px;
    flex-shrink: 0;
    text-align: left;
}

/* Responsive: stack on small screens */
@media (max-width: 860px) {
    .protocol-layout {
        flex-direction: column;
    }

    .protocol-sidebar {
        width: 100%;
    }
}

@media (max-width: 768px) {
    body {
        padding: 12px;
    }

    .container {
        padding: 20px 16px;
        margin: 10px auto;
    }

    .timer-display {
        font-size: 2.8rem;
        margin: 16px 0;
    }

    .controls {
        gap: 10px;
        margin-bottom: 20px;
        flex-wrap: wrap;
    }

    button {
        padding: 10px 18px;
        font-size: 0.9rem;
    }

    .tab-body {
        min-height: auto;
    }

    .step-title {
        font-size: 1.2rem;
    }

    .pulse-input {
        font-size: 2rem;
        width: 100px;
    }

    .step-item {
        font-size: 0.85rem;
        padding: 8px 10px;
    }
}

/* === Breathing Animation (5-5 Audio) === */
.breathing-scene {
    position: relative;
    width: 100%;
    max-width: 420px;
    height: 280px;
    margin: 10px auto 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    overflow: hidden;
    background: url('image/natura_montagna.webp') center/cover no-repeat;
}

[data-theme="dark"] .breathing-scene {
    background-image: url('image/natura_montagna_notte.webp');
}

#particles-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.breathing-orb {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%,
            rgba(37, 99, 235, 0.25) 0%,
            rgba(37, 99, 235, 0.10) 60%,
            transparent 100%);
    border: 2px solid rgba(37, 99, 235, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.breathing-orb.animating {
    animation: breathe-55 11s ease-in-out infinite;
}

.breathing-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--secondary-accent);
    opacity: 0;
    transition: opacity 0.4s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    pointer-events: none;
}

.breathing-label.visible {
    opacity: 1;
}

/* Ciclo 11s: 5s inspira → 0.5s pausa → 5s espira → 0.5s pausa */
@keyframes breathe-55 {
    0% {
        transform: scale(1);
        border-color: rgba(37, 99, 235, 0.3);
        background: radial-gradient(circle at 40% 35%,
                rgba(37, 99, 235, 0.25) 0%,
                rgba(37, 99, 235, 0.10) 60%,
                transparent 100%);
    }
    45.5%, 50% {
        transform: scale(1.7);
        border-color: rgba(37, 99, 235, 0.6);
        background: radial-gradient(circle at 40% 35%,
                rgba(37, 99, 235, 0.35) 0%,
                rgba(37, 99, 235, 0.15) 60%,
                transparent 100%);
    }
    95.5%, 100% {
        transform: scale(1);
        border-color: rgba(37, 99, 235, 0.3);
        background: radial-gradient(circle at 40% 35%,
                rgba(37, 99, 235, 0.25) 0%,
                rgba(37, 99, 235, 0.10) 60%,
                transparent 100%);
    }
}

/* === 4-7-8 Triangle Breathing (Weil) === */
.triangle-breathing-container {
    position: relative;
    width: 300px;
    height: 300px;
    margin: 10px auto 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#triangle-canvas {
    width: 100%;
    height: 100%;
}

/* === Ratio 1:2:3 Breathing === */
.ratio-selector {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}

.ratio-btn {
    padding: 8px 18px;
    font-size: 0.9rem;
    background: var(--bg-hover);
    color: var(--text-secondary);
    border-radius: 20px;
    transition: background 0.2s, color 0.2s;
}

.ratio-btn.active {
    background: var(--secondary-accent);
    color: white;
}

[data-theme="dark"] .ratio-btn {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

[data-theme="dark"] .ratio-btn.active {
    background: var(--secondary-accent);
    color: white;
}

#ratio-canvas {
    width: 100%;
    height: 100%;
}

/* === Bhramari Pranayama === */
.bhramari-container {
    position: relative;
    width: 300px;
    height: 300px;
    margin: 10px auto 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#bhramari-canvas {
    width: 100%;
    height: 100%;
}

.bhramari-btn {
    padding: 8px 18px;
    font-size: 0.9rem;
    background: var(--bg-hover);
    color: var(--text-secondary);
    border-radius: 20px;
    transition: background 0.2s, color 0.2s;
}

.bhramari-btn.active {
    background: #7a5a9a;
    color: white;
}

[data-theme="dark"] .bhramari-btn {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

[data-theme="dark"] .bhramari-btn.active {
    background: #7a5a9a;
    color: white;
}

/* === Nadi Shodhana === */
.nadi-container {
    position: relative;
    width: 300px;
    height: 300px;
    margin: 10px auto 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#nadi-canvas {
    width: 100%;
    height: 100%;
}

.nadi-btn {
    padding: 8px 18px;
    font-size: 0.9rem;
    background: var(--bg-hover);
    color: var(--text-secondary);
    border-radius: 20px;
    transition: background 0.2s, color 0.2s;
}

.nadi-btn.active {
    background: #2563eb;
    color: white;
}

[data-theme="dark"] .nadi-btn {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

[data-theme="dark"] .nadi-btn.active {
    background: #2563eb;
    color: white;
}

/* === Coerenza Cardiaca HRV === */
.hrv-container {
    position: relative;
    width: 300px;
    height: 300px;
    margin: 10px auto 0;
}

.hrv-container canvas {
    width: 100%;
    height: 100%;
}

.hrv-btn {
    padding: 8px 18px;
    font-size: 0.9rem;
    background: var(--bg-hover);
    border: none;
    border-radius: 20px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background 0.2s, color 0.2s;
}

.hrv-btn.active {
    background: var(--success-color);
    color: white;
}

[data-theme="dark"] .hrv-btn {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

[data-theme="dark"] .hrv-btn.active {
    background: var(--success-color);
    color: white;
}

/* === Box Breathing (4-4-4-4) === */
.box-breathing-container {
    position: relative;
    width: 300px;
    height: 300px;
    margin: 10px auto 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#box-canvas {
    width: 100%;
    height: 100%;
}

.box-sound-label {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

.box-sound-label input[type="checkbox"] {
    accent-color: var(--secondary-accent);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* ================================================================
   Dark Mode — Buteyko
   ================================================================ */

[data-theme="dark"] p {
    color: var(--text-secondary);
}

[data-theme="dark"] .session-info {
    border-top-color: var(--border-light);
}

[data-theme="dark"] .roadmap-title {
    border-bottom-color: var(--border-light);
}

[data-theme="dark"] .step-item {
    background: var(--bg-hover);
    border-color: var(--border-light);
}

[data-theme="dark"] .step-item.active {
    background: var(--card-bg);
    box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .step-item.completed {
    background: #1a2a20;
    border-color: #2a3a2a;
    color: var(--text-secondary);
}

[data-theme="dark"] .step-indicator {
    color: var(--text-muted);
}

[data-theme="dark"] .pulse-input {
    background: var(--card-bg);
    color: var(--primary-color);
    border-color: var(--border-light);
}

[data-theme="dark"] .pulse-bpm-info {
    color: var(--success-color);
}

/* ================================================================ */

/* === CP Log Diario === */

.cp-diary-hint {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: -4px 0 20px;
}

.cp-diary-link {
    color: var(--secondary-accent);
    text-decoration: none;
    font-weight: 600;
}

.cp-diary-link:hover {
    text-decoration: underline;
}

.diary-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    text-align: left;
}

#cp-log-section {
    width: 230px;
    flex-shrink: 0;
    text-align: left;
}

@media (max-width: 720px) {
    .diary-layout {
        flex-direction: column;
    }
    #cp-log-section {
        width: 100%;
    }
}

.cp-saved-notification {
    font-size: 0.85rem;
    color: var(--success-color);
    height: 1.6em;
    margin: -8px 0 16px;
    opacity: 0;
    transition: opacity 0.4s;
}

.cp-saved-notification.visible {
    opacity: 1;
}

.cp-log-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.cp-log-list {
    list-style: none;
    padding: 0;
    margin: 0 0 16px;
    text-align: left;
}

.cp-log-entry {
    padding: 12px 14px;
    border-radius: 8px;
    background: var(--bg-hover);
    border: 1px solid var(--border-light);
    margin-bottom: 8px;
}

.cp-log-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 0.8rem;
}

.cp-log-date {
    color: var(--text-muted);
}

.cp-log-type {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    background: rgba(37, 99, 235, 0.1);
    color: var(--secondary-accent);
}

.cp-log-values {
    font-size: 0.9rem;
    color: var(--primary-color);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 3px;
}

.cp-value {
    font-weight: 700;
}

.cp-level-optimal { color: var(--success-color); }
.cp-level-good    { color: #2563eb; }
.cp-level-avg     { color: #c07050; }
.cp-level-low     { color: #c0392b; }

.cp-arrow {
    color: var(--gray-muted);
    font-size: 0.8rem;
}

.cp-log-pulse {
    margin-left: 10px;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 400;
}

.cp-log-clear-btn {
    width: 100%;
    margin-top: 4px;
    font-size: 0.85rem;
    padding: 8px;
}

[data-theme="dark"] .cp-log-entry {
    background: var(--bg-hover);
    border-color: var(--border-light);
}

[data-theme="dark"] .cp-log-date {
    color: var(--text-muted);
}

[data-theme="dark"] .cp-saved-notification {
    color: var(--success-color);
}

/* === Grafico Andamento CP === */

#cp-chart-wrap {
    flex: 1;
    min-width: 0;
    border-radius: 10px;
    background: var(--bg-hover);
    border: 1px solid var(--border-light);
    padding: 10px 8px 6px;
}

.cp-chart-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin: 0 0 6px 38px;
}

#cp-chart {
    display: block;
    width: 100%;
    height: 320px;
}

[data-theme="dark"] #cp-chart-wrap {
    background: var(--bg-hover);
    border-color: var(--border-light);
}

@media (max-width: 400px) {
    .timer-display {
        font-size: 2.2rem;
    }

    button {
        padding: 10px 14px;
        font-size: 0.85rem;
    }

    .breathing-scene {
        width: 180px;
        height: 180px;
    }

    .breathing-orb {
        width: 100px;
        height: 100px;
    }

    .box-breathing-container,
    .triangle-breathing-container,
    .bhramari-container,
    .nadi-container,
    .hrv-container {
        width: 240px;
        height: 240px;
    }
}

/* === Print / PDF studio: solo contenuti, senza timer interattivi === */
@media print {
    body {
        --accent-color: #111;
        --secondary-accent: #111;
        line-height: 1.45;
        padding: 0 !important;
        min-height: 0;
    }

    .container {
        background: #fff !important;
        border-radius: 0;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
        text-align: left;
    }

    .tab-body {
        display: block;
        min-height: 0;
    }

    .tab-content,
    .tab-content.active {
        display: block;
        border-bottom: 1px solid #ddd;
        margin-bottom: 8mm;
        padding-bottom: 6mm;
        break-inside: auto;
        page-break-inside: auto;
    }

    .tab-content::before {
        display: block;
        color: #111;
        font-family: var(--heading-font);
        font-size: 17pt;
        font-weight: 400;
        margin: 0 0 5mm;
        break-after: avoid;
        page-break-after: avoid;
    }

    #tab-cp::before { content: "CP / BOLT"; }
    #tab-audio::before { content: "Respirazione coerente 5-5"; }
    #tab-478::before { content: "Respirazione 4-7-8"; }
    #tab-123::before { content: "Respirazione 1:2:3"; }
    #tab-bhramari::before { content: "Bhramari Pranayama"; }
    #tab-nadi::before { content: "Nadi Shodhana"; }
    #tab-hrv::before { content: "Coerenza cardiaca HRV"; }
    #tab-box::before { content: "Box Breathing"; }
    #tab-walking::before { content: "Walking Buteyko"; }

    #tab-diary,
    #tab-protocol,
    .timer-display,
    .controls,
    .breathing-scene,
    .triangle-breathing-container,
    .ratio-selector,
    .bhramari-container,
    .nadi-container,
    .hrv-container,
    .box-breathing-container,
    .box-sound-label,
    .cp-saved-notification,
    .cp-diary-hint,
    .diary-layout,
    #cp-chart-wrap,
    canvas {
        display: none !important;
    }

    p {
        color: #222 !important;
        margin: 0 0 4mm;
    }

    .session-info {
        border-top: 1px solid #ddd;
        margin-top: 5mm;
        padding-top: 4mm;
    }

    .quick-info-list {
        max-width: none;
        margin: 0 0 4mm;
    }
}
