/* ==========================================================================
   Attachment Stretch Lab - Styles
   A soft, calming aesthetic with sage green and warm cream
   ========================================================================== */

:root {
    /* Primary palette */
    --sage-light: #A8C5A8;
    --sage: #8FBC8F;
    --sage-dark: #6B8E6B;

    /* Background & Surface */
    --cream: #FDF8F0;
    --cream-dark: #F5EDE0;
    --white: #FFFFFF;

    /* Text */
    --charcoal: #3D3D3D;
    --charcoal-light: #5A5A5A;
    --muted: #8A8A8A;

    /* Accents */
    --warm-shadow: rgba(139, 119, 101, 0.1);
    --soft-border: rgba(143, 188, 143, 0.3);

    /* Spacing */
    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2rem;
    --space-xl: 3rem;

    /* Typography */
    --font-body: 'Georgia', 'Times New Roman', serif;
    --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Borders */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

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

body {
    font-family: var(--font-body);
    background-color: var(--cream);
    color: var(--charcoal);
    line-height: 1.6;
    min-height: 100vh;
}

#app {
    min-height: 100vh;
}

/* ==========================================================================
   Screen Management
   ========================================================================== */

.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: block;
}

.hidden {
    display: none !important;
}

/* ==========================================================================
   Welcome Screen
   ========================================================================== */

#welcome-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
}

.welcome-container {
    max-width: 600px;
    text-align: center;
}

.welcome-container h1 {
    font-size: 2.5rem;
    font-weight: normal;
    color: var(--sage-dark);
    margin-bottom: var(--space-xs);
}

.subtitle {
    font-size: 1.1rem;
    color: var(--muted);
    font-style: italic;
    margin-bottom: var(--space-xl);
}

.welcome-content {
    text-align: left;
}

.intro-text {
    background: var(--white);
    padding: var(--space-lg);
    border-radius: var(--radius-md);
    box-shadow: 0 2px 12px var(--warm-shadow);
    margin-bottom: var(--space-lg);
}

.intro-text p {
    margin-bottom: var(--space-sm);
}

.intro-text p:last-child {
    margin-bottom: 0;
}

.the-invitation {
    background: linear-gradient(135deg, var(--sage-light) 0%, var(--sage) 100%);
    color: var(--white);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    text-align: center;
}

.the-invitation em {
    font-style: normal;
    font-size: 1.05rem;
}

.api-section {
    margin-bottom: var(--space-lg);
}

.api-section label {
    display: block;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: var(--space-xs);
    color: var(--charcoal-light);
}

.api-section input {
    width: 100%;
    padding: var(--space-sm);
    font-size: 1rem;
    font-family: var(--font-ui);
    border: 2px solid var(--soft-border);
    border-radius: var(--radius-sm);
    background: var(--white);
    transition: border-color 0.2s;
}

.api-section input:focus {
    outline: none;
    border-color: var(--sage);
}

.api-note {
    font-size: 0.85rem;
    color: var(--muted);
    margin-top: var(--space-xs);
}

/* Practice Options */
.practice-options {
    background: var(--cream-dark);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
}

.practice-options h3 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--charcoal-light);
    margin-bottom: var(--space-md);
    font-family: var(--font-ui);
}

.option-row {
    margin-bottom: var(--space-md);
}

.option-row:last-child {
    margin-bottom: 0;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    margin-bottom: var(--space-xs);
}

.toggle-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--sage);
    cursor: pointer;
}

.toggle-text {
    font-family: var(--font-ui);
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--charcoal);
}

.option-description {
    font-size: 0.85rem;
    color: var(--muted);
    margin-left: 30px;
    line-height: 1.4;
}

.primary-btn {
    display: block;
    width: 100%;
    padding: var(--space-sm) var(--space-lg);
    font-family: var(--font-ui);
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--white);
    background: var(--sage);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.primary-btn:hover {
    background: var(--sage-dark);
}

.primary-btn:active {
    transform: scale(0.98);
}

.secondary-btn {
    padding: var(--space-xs) var(--space-sm);
    font-family: var(--font-ui);
    font-size: 0.9rem;
    color: var(--sage-dark);
    background: transparent;
    border: 2px solid var(--sage);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color 0.2s;
}

.secondary-btn:hover {
    background: var(--sage-light);
    color: var(--white);
}

.disclaimer {
    margin-top: var(--space-lg);
    text-align: center;
    font-size: 0.85rem;
    color: var(--muted);
    font-style: italic;
}

/* ==========================================================================
   Practice Screen
   ========================================================================== */

#practice-screen {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.practice-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    background: var(--white);
    border-bottom: 1px solid var(--soft-border);
}

.practice-header h2 {
    font-size: 1.2rem;
    font-weight: normal;
    color: var(--sage-dark);
}

.session-info {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

#round-display {
    font-family: var(--font-ui);
    font-size: 0.9rem;
    color: var(--muted);
}

.practice-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Conversation Panel */
.conversation-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--cream-dark);
    border-right: 1px solid var(--soft-border);
}

.panel-header {
    padding: var(--space-sm) var(--space-md);
    background: var(--white);
    border-bottom: 1px solid var(--soft-border);
}

.panel-header h3 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--charcoal-light);
    font-family: var(--font-ui);
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.message {
    max-width: 80%;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    line-height: 1.5;
}

.message.user {
    align-self: flex-end;
    background: var(--sage);
    color: var(--white);
    border-bottom-right-radius: 4px;
}

.message.assistant {
    align-self: flex-start;
    background: var(--white);
    color: var(--charcoal);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px var(--warm-shadow);
}

.waiting-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    color: var(--muted);
    font-family: var(--font-ui);
    font-size: 0.9rem;
}

.breathing-dots {
    display: flex;
    gap: 4px;
}

.breathing-dots span {
    width: 8px;
    height: 8px;
    background: var(--sage);
    border-radius: 50%;
    animation: breathe 1.5s ease-in-out infinite;
}

.breathing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.breathing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes breathe {
    0%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    50% {
        opacity: 1;
        transform: scale(1);
    }
}

.input-area {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-md);
    background: var(--white);
    border-top: 1px solid var(--soft-border);
}

.input-area textarea {
    flex: 1;
    padding: var(--space-sm);
    font-family: var(--font-body);
    font-size: 1rem;
    border: 2px solid var(--soft-border);
    border-radius: var(--radius-sm);
    resize: none;
}

.input-area textarea:focus {
    outline: none;
    border-color: var(--sage);
}

.send-btn {
    padding: var(--space-sm) var(--space-md);
    font-family: var(--font-ui);
    font-weight: 500;
    color: var(--white);
    background: var(--sage);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color 0.2s;
}

.send-btn:hover {
    background: var(--sage-dark);
}

.send-btn:disabled {
    background: var(--muted);
    cursor: not-allowed;
}

/* Journal Panel */
.journal-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--white);
    overflow-y: auto;
}

.journal-invitation {
    padding: var(--space-md);
    text-align: center;
    border-bottom: 1px solid var(--soft-border);
}

.invitation-text {
    font-size: 1.1rem;
    font-style: italic;
    color: var(--sage-dark);
}

.journal-input-area {
    padding: var(--space-md);
    border-bottom: 1px solid var(--soft-border);
}

.journal-input-area textarea {
    width: 100%;
    padding: var(--space-md);
    font-family: var(--font-body);
    font-size: 1rem;
    border: 2px solid var(--soft-border);
    border-radius: var(--radius-md);
    resize: none;
    margin-bottom: var(--space-sm);
    background: var(--cream);
}

.journal-input-area textarea:focus {
    outline: none;
    border-color: var(--sage);
}

.journal-input-area textarea::placeholder {
    color: var(--muted);
    font-style: italic;
}

.save-btn {
    display: block;
    width: 100%;
    padding: var(--space-xs) var(--space-sm);
    font-family: var(--font-ui);
    font-size: 0.9rem;
    color: var(--sage-dark);
    background: var(--sage-light);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color 0.2s;
}

.save-btn:hover {
    background: var(--sage);
    color: var(--white);
}

.journal-examples {
    padding: var(--space-sm) var(--space-md);
    font-size: 0.85rem;
    font-style: italic;
    color: var(--muted);
    background: var(--cream);
    border-bottom: 1px solid var(--soft-border);
}

.journal-history {
    flex: 1;
    padding: var(--space-md);
    overflow-y: auto;
}

.journal-history h4 {
    font-family: var(--font-ui);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--charcoal-light);
    margin-bottom: var(--space-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#reflection-entries {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.reflection-entry {
    padding: var(--space-sm);
    background: var(--cream);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--sage);
}

.reflection-entry .wait-time {
    font-family: var(--font-ui);
    font-size: 0.75rem;
    color: var(--muted);
    margin-bottom: 4px;
}

.reflection-entry .reflection-text {
    font-size: 0.95rem;
    color: var(--charcoal);
}

.grounding-link {
    padding: var(--space-sm);
    text-align: center;
    background: var(--cream);
    border-top: 1px solid var(--soft-border);
}

.grounding-link a {
    font-size: 0.85rem;
    color: var(--sage-dark);
    text-decoration: none;
}

.grounding-link a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Analysis Screen
   ========================================================================== */

#analysis-screen {
    padding: var(--space-lg);
    overflow-y: auto;
}

.analysis-container {
    max-width: 700px;
    margin: 0 auto;
}

.analysis-container h1 {
    font-size: 2rem;
    font-weight: normal;
    color: var(--sage-dark);
    text-align: center;
    margin-bottom: var(--space-xs);
}

.analysis-container > .subtitle {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.session-stats {
    display: flex;
    justify-content: center;
    gap: var(--space-xl);
    margin-bottom: var(--space-xl);
}

.stat {
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 2rem;
    color: var(--sage-dark);
    font-weight: 500;
}

.stat-label {
    font-family: var(--font-ui);
    font-size: 0.85rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.journal-review,
.pattern-analysis,
.bridge-section {
    background: var(--white);
    padding: var(--space-lg);
    border-radius: var(--radius-md);
    box-shadow: 0 2px 12px var(--warm-shadow);
    margin-bottom: var(--space-lg);
}

.journal-review h3,
.pattern-analysis h3,
.bridge-section h3 {
    font-size: 1.2rem;
    font-weight: normal;
    color: var(--sage-dark);
    margin-bottom: var(--space-md);
}

#all-reflections {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.analysis-text {
    line-height: 1.7;
}

.analysis-text p {
    margin-bottom: var(--space-sm);
}

.analysis-text .section-header {
    display: block;
    color: var(--sage-dark);
    font-size: 1.05rem;
    margin-top: var(--space-md);
    margin-bottom: var(--space-xs);
    font-family: var(--font-ui);
}

.analysis-text p:first-child .section-header {
    margin-top: 0;
}

.loading-text {
    color: var(--muted);
    font-style: italic;
}

.bridge-section p {
    margin-bottom: var(--space-sm);
    color: var(--charcoal-light);
}

.bridge-section textarea {
    width: 100%;
    padding: var(--space-md);
    font-family: var(--font-body);
    font-size: 1rem;
    border: 2px solid var(--soft-border);
    border-radius: var(--radius-sm);
    resize: none;
    background: var(--cream);
}

.bridge-section textarea:focus {
    outline: none;
    border-color: var(--sage);
}

.action-buttons {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
}

.action-buttons .secondary-btn {
    padding: var(--space-sm) var(--space-lg);
}

.action-buttons .primary-btn {
    width: auto;
    padding: var(--space-sm) var(--space-lg);
}

/* ==========================================================================
   Modal
   ========================================================================== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--white);
    padding: var(--space-xl);
    border-radius: var(--radius-lg);
    max-width: 400px;
    text-align: center;
    position: relative;
}

.close-modal {
    position: absolute;
    top: var(--space-sm);
    right: var(--space-sm);
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--muted);
    cursor: pointer;
}

.modal-content h3 {
    color: var(--sage-dark);
    margin-bottom: var(--space-md);
}

.modal-content p {
    margin-bottom: var(--space-sm);
    color: var(--charcoal-light);
}

.modal-content .primary-btn {
    margin-top: var(--space-md);
    width: auto;
    display: inline-block;
}

/* ==========================================================================
   Starter Message
   ========================================================================== */

.starter-message {
    text-align: center;
    padding: var(--space-lg);
    color: var(--sage-dark);
    font-style: italic;
    background: var(--cream);
    border-radius: var(--radius-md);
    margin: var(--space-md);
}

.starter-message p {
    margin-bottom: var(--space-xs);
}

.starter-message p:last-child {
    margin-bottom: 0;
    font-size: 0.9rem;
    color: var(--muted);
}

/* ==========================================================================
   Mobile Tabs
   ========================================================================== */

.mobile-tabs {
    display: none;
    background: var(--white);
    border-bottom: 1px solid var(--soft-border);
}

.tab-btn {
    flex: 1;
    padding: var(--space-sm);
    font-family: var(--font-ui);
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--muted);
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    color: var(--sage-dark);
    border-bottom-color: var(--sage);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    /* Show mobile tabs */
    .mobile-tabs {
        display: flex;
    }

    .practice-container {
        flex-direction: column;
        position: relative;
    }

    /* Hide panel headers on mobile - tabs replace them */
    .conversation-panel .panel-header,
    .journal-panel .panel-header {
        display: none;
    }

    /* Full height panels that stack */
    .conversation-panel,
    .journal-panel {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        height: 100%;
        border: none;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s;
    }

    /* Default: show conversation on mobile */
    .conversation-panel {
        opacity: 1;
        pointer-events: auto;
    }

    .journal-panel {
        opacity: 0;
        pointer-events: none;
    }

    /* When hidden class is added */
    .mobile-hidden {
        opacity: 0 !important;
        pointer-events: none !important;
    }

    /* When active class is added */
    .mobile-active {
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    /* Fix the practice container height */
    #practice-screen {
        display: flex;
        flex-direction: column;
    }

    #practice-screen .practice-container {
        flex: 1;
        overflow: hidden;
    }

    /* Improve input area on mobile */
    .input-area {
        padding: var(--space-sm);
    }

    .input-area textarea {
        font-size: 16px; /* Prevents iOS zoom */
    }

    /* Journal panel mobile improvements */
    .journal-input-area {
        padding: var(--space-sm);
    }

    .journal-input-area textarea {
        font-size: 16px; /* Prevents iOS zoom */
    }

    /* Welcome screen mobile */
    #welcome-screen {
        padding: var(--space-md);
    }

    .welcome-container h1 {
        font-size: 1.8rem;
    }

    .intro-text {
        padding: var(--space-md);
    }

    /* Analysis screen mobile */
    .session-stats {
        gap: var(--space-md);
    }

    .stat-number {
        font-size: 1.5rem;
    }

    .action-buttons {
        flex-direction: column;
    }

    .action-buttons .secondary-btn,
    .action-buttons .primary-btn {
        width: 100%;
    }

    /* Grounding link */
    .grounding-link {
        padding: var(--space-xs);
    }
}
