/* ===== CSS Variables ===== */
:root {
    --bg-color: #f5f5f5;
    --card-bg: #ffffff;
    --text-primary: #1a1a2e;
    --text-secondary: #4a4a68;
    --text-muted: #6b7280;
    --border-color: #e5e5e5;
    --accent-color: #4CAF50;
    /* Green */
    --accent-hover: #45a049;
    --reflection-bg: #fafafa;
    --reflection-border: #e0e0e0;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ===== Container ===== */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* ===== Input Section ===== */
.input-section {
    text-align: center;
    padding: 3rem 0;
    min-height: calc(100vh - 4rem);
    display: flex;
    flex-direction: column;
}

.input-section .attribution {
    margin-top: auto;
    padding-top: 3rem;
}

.header {
    margin-bottom: 2.5rem;
}

.title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

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

.input-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    max-width: 500px;
    margin: 0 auto;
}

.input-row {
    display: flex;
    gap: 1rem;
    width: 100%;
}

.input-row .input-group {
    flex: 1;
}

.lectionary-select {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    font-family: var(--font-family);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--card-bg);
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.lectionary-select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.input-group {
    width: 100%;
    text-align: left;
}

.input-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.date-input {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    font-family: var(--font-family);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--card-bg);
    color: var(--text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.date-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.generate-btn {
    width: 100%;
    padding: 0.875rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: var(--font-family);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: white;
    background-color: var(--accent-color);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.generate-btn:hover:not(:disabled) {
    background-color: var(--accent-hover);
}

.generate-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.generate-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== Status Message ===== */
.status-message {
    margin-top: 1.5rem;
    padding: 1rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    background-color: var(--card-bg);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    animation: fadeIn 0.3s ease;
}

.status-message.loading {
    animation: fadeIn 0.3s ease, pulse 2s ease-in-out infinite;
}

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

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

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

/* ===== API Key Section ===== */
.api-key-section {
    margin-top: 2rem;
    text-align: left;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.api-toggle {
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem 0;
}

.api-toggle:hover {
    color: var(--text-secondary);
}

.api-input-container {
    margin-top: 1rem;
    padding: 1rem;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.api-key-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    font-family: var(--font-family);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

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

.api-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ===== Output Section ===== */
.output-section {
    animation: fadeIn 0.5s ease;
}

/* ===== Handout Styles ===== */
.handout {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.handout-header {
    text-align: center;
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.handout-date {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.handout-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.liturgical-day {
    font-size: 1rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* ===== Reading Section ===== */
.reading-section {
    margin-bottom: 2.5rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.reading-section:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.reading-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.75rem;
}

.reading-type {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-primary);
}

.reading-reference {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.reading-context {
    font-size: 0.9rem;
    font-style: italic;
    color: var(--text-muted);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.reading-text {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

/* ===== Reflection Block ===== */
.reflection-block {
    background-color: var(--reflection-bg);
    border-left: 4px solid var(--accent-color);
    padding: 1.25rem;
    border-radius: 0 8px 8px 0;
    margin-top: 1.5rem;
    margin-bottom: 2rem;
}

.reflection-block h4 {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    margin-top: 1.25rem;
}

.reflection-block h4:first-child {
    margin-top: 0;
}

.context-reflection {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 0.5rem;
}

.reflection-q {
    font-size: 1rem;
    font-weight: 500;
    font-style: italic;
    color: var(--text-primary);
    line-height: 1.5;
}

/* ===== For Reflection Section ===== */
.reflection-section {
    margin-top: 2.5rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.reflection-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.reflection-list {
    list-style-position: outside;
    padding-left: 1.25rem;
}

.reflection-list li {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    line-height: 1.5;
    font-weight: 500;
}

/* ===== Handout Footer ===== */
.handout-footer {
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.closing-prayer {
    font-size: 0.9rem;
    font-style: italic;
    color: var(--text-muted);
}

/* ===== Action Buttons ===== */
.action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}

.action-btn {
    padding: 0.75rem 1.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: var(--font-family);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn:hover {
    background-color: var(--bg-color);
    border-color: var(--text-muted);
}

/* ===== About Section ===== */
.about-section {
    margin-top: 2rem;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
    text-align: left;
}

.about-toggle {
    background: none;
    border: none;
    font-family: var(--font-family);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem 0;
    letter-spacing: 0.03em;
    transition: color 0.2s ease;
}

.about-toggle:hover {
    color: var(--text-secondary);
}

.about-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.3s ease;
    opacity: 0;
}

.about-section.open .about-toggle {
    color: var(--text-secondary);
}

.about-section.open .about-content {
    max-height: 600px;
    opacity: 1;
}

.about-content p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 0.75rem;
}

.about-content p:last-child {
    margin-bottom: 0;
    padding-bottom: 0.5rem;
}

.about-content a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
}

.about-content a:hover {
    text-decoration: underline;
}

/* ===== Attribution ===== */
.attribution {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.6;
}

/* ===== Print Styles ===== */
@media print {
    body {
        background-color: white;
        font-size: 11pt;
    }

    .container {
        max-width: 100%;
        padding: 0;
    }

    .input-section,
    .action-buttons,
    .attribution,
    .api-key-section {
        display: none !important;
    }

    .output-section {
        display: block !important;
    }

    .handout {
        border: none;
        box-shadow: none;
        padding: 0;
    }

    .reading-section {
        page-break-inside: avoid;
    }

    .reflection-section {
        page-break-before: auto;
    }
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
    .container {
        padding: 1.5rem 1rem;
    }

    .title {
        font-size: 1.5rem;
    }

    .handout {
        padding: 1.5rem;
    }

    .reading-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

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

    .action-btn {
        width: 100%;
    }
}

/* ===== Toast Notification Animations ===== */
@keyframes toastFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes toastFadeOut {
    from {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
}