/* Copyright (c) 2024-2026 Jericho Crosby (Chalwk). All Rights Reserved. */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-header h1 {
    margin: 0 0 0.25rem;
    color: var(--dark);
}

.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

@media (min-width: 992px) {
    .app-grid {
        grid-template-columns: 2fr 1fr;
    }
}

.scripts-library,
.premade-scripts {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 300px;
    overflow-y: auto;
    padding: 0.5rem;
}

.script-card {
    padding: 1rem;
    border-radius: var(--radius);
    background: var(--light);
    border: 1px solid var(--gray-light);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.script-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.script-card h4 {
    margin: 0 0 0.5rem;
    color: var(--dark);
    font-size: 1rem;
}

.script-card p {
    margin: 0;
    color: var(--gray);
    font-size: 0.875rem;
}

.script-card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.premade-script-card {
    background: rgba(124, 58, 237, 0.05);
    border-color: rgba(124, 58, 237, 0.2);
}

.premade-script-card h4 {
    color: var(--secondary);
}

.steps-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 400px;
    overflow-y: auto;
    padding: 0.5rem;
    margin-bottom: 1rem;
}

.step-item {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    padding: 1rem;
    border-radius: var(--radius);
    background: var(--light);
    border: 1px solid var(--gray-light);
    animation: fadeIn 0.3s ease;
}

.step-content {
    flex: 1;
}

.step-item textarea {
    width: 100%;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-light);
    font-size: 0.9rem;
    resize: vertical;
    min-height: 60px;
    font-family: var(--font-primary), sans-serif;
    background: white;
}

.step-item textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.step-type {
    min-width: 140px;
}

.step-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.step-type-statement {
    background: #dbeafe;
    color: #1e40af;
}

.step-type-question {
    background: #f0fdf4;
    color: #166534;
}

.step-type-action {
    background: #fef3c7;
    color: #92400e;
}

.step-type-reminder {
    background: #f3e8ff;
    color: #7c3aed;
}

.step-type-transition {
    background: #e0f2fe;
    color: #0369a1;
}

.step-type-observation {
    background: #f0f9ff;
    color: #0c4a6e;
}

.step-type-validation {
    background: #f0fdfa;
    color: #0f766e;
}

.step-type-boundary {
    background: #fef2f2;
    color: #991b1b;
}

.step-type-followup {
    background: #faf5ff;
    color: #7c3aed;
}

.step-type-closure {
    background: #fffbeb;
    color: #92400e;
}

.preview-modal {
    border: none;
    border-radius: var(--radius-lg);
    padding: 0;
    max-width: 600px;
    width: 90vw;
    box-shadow: var(--shadow-lg);
}

.preview-content {
    padding: 1.5rem;
    max-height: 60vh;
    overflow-y: auto;
}

.preview-steps {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

.preview-step {
    padding: 1rem;
    border-radius: var(--radius);
    border-left: 4px solid;
    background: var(--light);
}

.preview-step-type {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

.preview-step-text {
    font-size: 0.95rem;
    line-height: 1.4;
}

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

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

.fade-in {
    animation: fadeIn 0.3s ease both;
}

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

    .step-item {
        flex-direction: column;
        gap: 0.75rem;
    }

    .step-type {
        min-width: 100%;
    }

    .scripts-library,
    .premade-scripts {
        max-height: 250px;
    }
}

@media (max-width: 480px) {
    .script-card-actions {
        flex-wrap: wrap;
    }

    .step-actions {
        flex-wrap: wrap;
    }

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

    .script-actions .btn {
        width: 100%;
    }
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.field span {
    font-weight: 500;
    color: var(--dark);
    font-size: 0.9rem;
}

.field input,
.field textarea {
    padding: 0.75rem;
    border-radius: var(--radius);
    border: 1px solid var(--gray-light);
    font-size: 0.95rem;
    background: white;
    font-family: var(--font-primary), sans-serif;
}

.field input:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.skip {
    position: absolute;
    left: -999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.skip:focus {
    left: 1rem;
    top: 1rem;
    width: auto;
    height: auto;
    padding: 0.5rem 1rem;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 1001;
}

.panel-style {
    background: var(--light);
    border: 1px solid var(--gray-light);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.step-actions-container {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    align-items: center;
}

.script-actions-container {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.search-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--gray-light);
    border-radius: var(--radius);
}

.premade-scripts-section {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--gray-light);
}

.practice-tools-section {
    margin-top: 2rem;
}

.tool-option-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-input {
    width: 1.25rem;
    height: 1.25rem;
}

.modal-base {
    border: none;
    border-radius: var(--radius-lg);
    padding: 0;
    width: 90vw;
    box-shadow: var(--shadow-lg);
}

.practice-modal {
    max-width: 500px;
}

.help-modal {
    max-width: 600px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--gray-light);
}

.practice-content {
    padding: 1.5rem;
}

.practice-step {
    text-align: center;
    padding: 2rem;
    border-radius: var(--radius);
    background: var(--light);
    margin-bottom: 1.5rem;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.step-content {
    font-size: 1.1rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.step-type-badge {
    padding: 0.25rem 1rem;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 600;
}

.practice-progress {
    margin: 1.5rem 0;
}

.progress-bar {
    height: 6px;
    background: var(--gray-light);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s;
    width: 0;
}

.practice-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.practice-timer {
    display: none;
    text-align: center;
    margin-top: 1rem;
    padding: 0.75rem;
    background: var(--light);
    border-radius: var(--radius);
    font-weight: 600;
}

.help-content {
    padding: 1.5rem;
    max-height: 60vh;
    overflow-y: auto;
}

.help-section {
    margin-bottom: 1.5rem;
}

.help-section h4 {
    margin: 0 0 0.5rem;
    color: var(--dark);
}

.help-section ul {
    padding-left: 1.5rem;
    color: var(--dark);
}

.modal-actions {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-light);
    display: flex;
    justify-content: flex-end;
}

.empty-library {
    color: var(--gray);
    text-align: center;
    padding: 2rem;
}

.panel-head h2 {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.panel-head .small {
    color: var(--gray);
}

.script-steps h3 {
    color: var(--dark);
    margin-bottom: 1rem;
}

.premade-scripts-section h3 {
    color: var(--dark);
    margin-bottom: 0.5rem;
}

.premade-scripts-section .small {
    color: var(--gray);
    margin-bottom: 1rem;
}

.practice-tools h3 {
    color: var(--dark);
    margin-bottom: 1rem;
}

/* --- Enhancements: autosave, import/export, toasts, confirm modal, a11y --- */

.draft-status {
    min-height: 1.1em;
    color: var(--gray);
    font-style: italic;
}

.search-controls {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.search-controls .search-input {
    flex: 1;
    min-width: 160px;
}

.sort-select {
    padding: 0.75rem;
    border: 1px solid var(--gray-light);
    border-radius: var(--radius);
    background: white;
    font-family: var(--font-primary), sans-serif;
}

.library-actions {
    display: flex;
    gap: 0.75rem;
    margin: 0.75rem 0 1rem;
    flex-wrap: wrap;
}

.auto-advance-delay-field {
    margin-bottom: 0;
}

.step-item {
    border-left: 4px solid var(--gray-light);
}

.step-item.step-type-statement-accent {
    border-left-color: #1e40af;
}

.step-item.step-type-question-accent {
    border-left-color: #166534;
}

.step-item.step-type-action-accent {
    border-left-color: #92400e;
}

.step-item.step-type-reminder-accent {
    border-left-color: #7c3aed;
}

.step-item.step-type-transition-accent {
    border-left-color: #0369a1;
}

.step-item.step-type-observation-accent {
    border-left-color: #0c4a6e;
}

.step-item.step-type-validation-accent {
    border-left-color: #0f766e;
}

.step-item.step-type-boundary-accent {
    border-left-color: #991b1b;
}

.step-item.step-type-followup-accent {
    border-left-color: #7c3aed;
}

.step-item.step-type-closure-accent {
    border-left-color: #92400e;
}

.practice-step-tools {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.auto-advance-countdown {
    color: var(--gray);
    min-height: 1.1em;
}

.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 2000;
    max-width: min(90vw, 360px);
    pointer-events: none;
}

.toast {
    background: var(--dark);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 0.9rem;
    line-height: 1.4;
    animation: fadeIn 0.2s ease both;
    transition: opacity 0.3s ease;
    pointer-events: auto;
}

.toast.toast-success {
    background: #166534;
}

.toast.toast-error {
    background: #991b1b;
}

.confirm-modal {
    max-width: 420px;
}

.confirm-content {
    padding: 1.5rem;
}

.confirm-content p {
    margin: 0;
    color: var(--dark);
    line-height: 1.5;
}

@media (max-width: 480px) {
    .toast-container {
        left: 1rem;
        right: 1rem;
        max-width: none;
    }

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

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.text-size-controls {
    display: flex;
    gap: 0.5rem;
}

.text-size-controls .btn {
    padding: 0.5rem 0.75rem;
    font-weight: 700;
}

body.text-scale-2 .container {
    font-size: 1.1em;
}

body.text-scale-3 .container {
    font-size: 1.25em;
}

.premade-filter-row {
    margin-bottom: 0.75rem;
}

.premade-filter-row select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--gray-light);
    border-radius: var(--radius);
    background: white;
    font-family: var(--font-primary), sans-serif;
}

.premade-category {
    display: inline-block;
    margin: 0 0 0.4rem;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(124, 58, 237, 0.12);
    color: var(--secondary);
}

.script-meta-line {
    margin-top: 0.25rem;
    color: var(--gray);
    font-size: 0.8rem;
}

.personalize-fields {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.5rem;
    max-height: 60vh;
    overflow-y: auto;
}

.breathing-pacer {
    text-align: center;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border-radius: var(--radius);
    background: var(--light);
}

.breathing-circle {
    width: 80px;
    height: 80px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: var(--primary);
    opacity: 0.7;
    animation: breathePulse 12s ease-in-out infinite;
}

@keyframes breathePulse {
    0% {
        transform: scale(0.6);
    }

    33% {
        transform: scale(1);
    }

    66% {
        transform: scale(1);
    }

    100% {
        transform: scale(0.6);
    }
}

#breathing-text {
    font-weight: 600;
    color: var(--dark);
    margin: 0 0 1rem;
}

/* Printable cue card */
.print-only {
    display: none;
}

@media print {
    body * {
        visibility: hidden;
    }

    #print-area,
    #print-area * {
        visibility: visible;
    }

    #print-area {
        display: block !important;
        position: absolute;
        inset: 0;
        padding: 1.5in 0.75in;
        font-size: 14pt;
        line-height: 1.5;
    }

    #print-area h2 {
        margin-bottom: 0.25em;
    }

    #print-area .print-step {
        margin-bottom: 0.75em;
        padding-left: 0.5em;
        border-left: 3px solid #333;
    }

    #print-area .print-step-type {
        font-weight: 700;
        text-transform: uppercase;
        font-size: 0.75em;
        letter-spacing: 0.03em;
    }
}