/* ========================================
   DAILY DEVOTIONAL STYLES
   ======================================== */

/* --- CSS Variables --- */
:root {
    --devo-bg: #fff;
    --devo-text: #333;
    --devo-text-muted: #6c757d;
    --devo-border: #dee2e6;
    --devo-scripture-bg: #f8f5f0;
    --devo-scripture-border: #d4a574;
    --devo-scripture-text: #5c4a32;
    --devo-body-text: #444;
    --devo-tab-active: #304e96;
    --devo-tab-inactive: #6c757d;
    --devo-tab-active-bg: rgba(48, 78, 150, 0.08);
    --devo-selector-bg: #f8f9fa;
    --devo-selector-border: #dee2e6;
    --devo-badge-bg: #dc3545;
    --devo-author-text: #6c757d;
    --devo-date-text: #304e96;
    --devo-link: #304e96;
    --devo-sub-tab-bg: #f0f0f0;
    --devo-sub-tab-active-bg: #304e96;
    --devo-sub-tab-active-text: #fff;
}

[data-theme="dark"] {
    --devo-bg: #252538;
    --devo-text: #e0e0e0;
    --devo-text-muted: #a0a0a0;
    --devo-border: #404055;
    --devo-scripture-bg: #2d2a24;
    --devo-scripture-border: #8b7355;
    --devo-scripture-text: #d4c4a8;
    --devo-body-text: #c0c0c0;
    --devo-tab-active: #7fb3ff;
    --devo-tab-inactive: #888;
    --devo-tab-active-bg: rgba(127, 179, 255, 0.1);
    --devo-selector-bg: #2d2d44;
    --devo-selector-border: #404055;
    --devo-badge-bg: #dc3545;
    --devo-author-text: #a0a0a0;
    --devo-date-text: #7fb3ff;
    --devo-link: #7fb3ff;
    --devo-sub-tab-bg: #2d2d44;
    --devo-sub-tab-active-bg: #7fb3ff;
    --devo-sub-tab-active-text: #1a1a2e;
}

/* --- Compact Header Toggle (replaces full-width body tabs) --- */
.devo-header-toggle {
    display: flex;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    padding: 2px;
    margin-left: auto;
    margin-right: 0.75rem;
    gap: 2px;
}

.devo-header-btn {
    padding: 0.3rem 0.7rem;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    white-space: nowrap;
    line-height: 1.3;
}

.devo-header-btn:hover {
    color: rgba(255, 255, 255, 0.85);
    background: rgba(255, 255, 255, 0.1);
}

.devo-header-btn.active {
    background: rgba(255, 255, 255, 0.28);
    color: #fff;
    font-weight: 600;
}

.devo-header-btn i {
    font-size: 0.8rem;
}

/* Dark mode header toggle */
[data-theme="dark"] .devo-header-toggle {
    background: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .devo-header-btn {
    color: rgba(255, 255, 255, 0.5);
}

[data-theme="dark"] .devo-header-btn:hover {
    color: rgba(255, 255, 255, 0.75);
    background: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .devo-header-btn.active {
    background: rgba(255, 255, 255, 0.15);
    color: #e0e0e0;
}

/* --- Tab Panes --- */
.bible-modal .devo-tab-pane {
    display: none;
}

.bible-modal .devo-tab-pane.active {
    display: block;
}

/* --- Grid Layout Fix for Desktop ---
   The .modal-body uses CSS grid on desktop (992px+).
   Devotional pane must span full width.
   Bible pane uses display:contents so its columns become grid items. */
@media (min-width: 992px) {
    .bible-modal .devo-tab-pane#devoTabPaneDevotional {
        grid-column: 1 / -1;
    }

    .bible-modal .devo-tab-pane#devoTabPaneBible.active {
        display: contents;
    }

    /* On desktop, cap the devotional body so it doesn't push the modal too tall */
    .devo-body {
        max-height: calc(60vh - 200px);
    }
}

/* --- Devotional Content Area --- */
.devo-content {
    color: var(--devo-text);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#devoContentArea {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* Hide content area when JS sets display:none */
#devoContentArea[style*="display: none"] {
    display: none !important;
}

/* On mobile (full-screen modal), devotional tab fills the modal body */
@media (max-width: 576px) {
    .bible-modal .devo-tab-pane#devoTabPaneDevotional.active {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
    }

    .devo-content {
        flex: 1;
        min-height: 0;
    }
}

/* Devotional Selector */
.devo-selector {
    margin-bottom: 1rem;
}

.devo-selector select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--devo-selector-border);
    border-radius: 0.375rem;
    background-color: var(--devo-selector-bg);
    color: var(--devo-text);
    font-size: 0.9rem;
    cursor: pointer;
    appearance: auto;
}

.devo-selector select:focus {
    border-color: var(--devo-tab-active);
    outline: none;
    box-shadow: 0 0 0 0.15rem rgba(48, 78, 150, 0.2);
}

/* Date Navigation Row */
.devo-date-nav {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
}

.devo-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--devo-border);
    border-radius: 50%;
    background: var(--devo-selector-bg);
    color: var(--devo-text-muted);
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
    flex-shrink: 0;
}

.devo-nav-btn:hover {
    background: var(--devo-tab-active-bg);
    color: var(--devo-tab-active);
    border-color: var(--devo-tab-active);
}

.devo-nav-btn i {
    font-size: 0.75rem;
}

.devo-today-btn {
    margin-left: 0.5rem;
    padding: 0.15rem 0.6rem;
    border: 1px solid var(--devo-tab-active);
    border-radius: 1rem;
    background: transparent;
    color: var(--devo-tab-active);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}

.devo-today-btn:hover {
    background: var(--devo-tab-active);
    color: #fff;
}

[data-theme="dark"] .devo-today-btn:hover {
    color: #1a1a2e;
}

/* Date Header */
.devo-date {
    font-size: 0.85rem;
    color: var(--devo-date-text);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    user-select: none;
}

.devo-date i {
    font-size: 1rem;
}

/* Scripture Block */
.devo-scripture {
    background: var(--devo-scripture-bg);
    border-left: 3px solid var(--devo-scripture-border);
    padding: 0.875rem 1rem;
    margin-bottom: 1rem;
    border-radius: 0 0.25rem 0.25rem 0;
}

.devo-scripture-text {
    font-style: italic;
    color: var(--devo-scripture-text);
    font-size: 0.95rem;
    line-height: 1.6;
    margin: 0 0 0.4rem 0;
}

.devo-scripture-ref {
    font-size: 0.8rem;
    color: var(--devo-author-text);
    font-weight: 600;
    text-align: right;
}

/* Body */
.devo-body {
    font-size: 0.92rem;
    line-height: 1.75;
    color: var(--devo-body-text);
    overflow-y: auto;
    padding-right: 0.5rem;
    flex: 1;
    min-height: 0;
}

.devo-body p {
    margin-bottom: 0.75rem;
}

.devo-body p:last-child {
    margin-bottom: 0;
}

/* Custom scrollbar for devotional body */
.devo-body::-webkit-scrollbar {
    width: 5px;
}
.devo-body::-webkit-scrollbar-track {
    background: transparent;
}
.devo-body::-webkit-scrollbar-thumb {
    background: var(--devo-border);
    border-radius: 3px;
}

/* Entry title (e.g. Faith's Checkbook daily titles) */
.devo-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--devo-text);
    margin-bottom: 0.6rem;
    line-height: 1.4;
}

.devo-title:empty {
    display: none;
}

/* Author attribution */
.devo-author {
    font-size: 0.8rem;
    color: var(--devo-author-text);
    text-align: right;
    margin-top: 0.75rem;
    font-style: italic;
}

/* --- Toolbar (font size + copy) --- */
.devo-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.75rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--devo-border);
}

.devo-font-controls {
    display: flex;
    gap: 0.25rem;
}

.devo-font-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--devo-border);
    border-radius: 4px;
    background: var(--devo-selector-bg);
    color: var(--devo-text-muted);
    cursor: pointer;
    font-weight: 700;
    font-family: serif;
    transition: background-color 0.15s, border-color 0.15s;
}

.devo-font-btn:hover {
    background: var(--devo-tab-active-bg);
    border-color: var(--devo-tab-active);
    color: var(--devo-tab-active);
}

.devo-font-decrease {
    font-size: 0.7rem;
}

.devo-font-increase {
    font-size: 0.95rem;
}

.devo-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.3rem 0.65rem;
    border: 1px solid var(--devo-border);
    border-radius: 4px;
    background: var(--devo-selector-bg);
    color: var(--devo-text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.devo-copy-btn:hover {
    background: var(--devo-tab-active-bg);
    border-color: var(--devo-tab-active);
    color: var(--devo-tab-active);
}

.devo-copy-btn.copied {
    background: #198754;
    border-color: #198754;
    color: #fff;
}

[data-theme="dark"] .devo-copy-btn.copied {
    background: #157347;
    border-color: #157347;
}

/* Morning/Evening sub-tabs (paired devotionals: Spurgeon, Winslow) */
.devo-sub-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
}

.devo-sub-tab {
    flex: 1;
    padding: 0.4rem 0.75rem;
    border: none;
    border-radius: 0.25rem;
    background: var(--devo-sub-tab-bg);
    color: var(--devo-text);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    text-align: center;
}

.devo-sub-tab:hover {
    opacity: 0.85;
}

.devo-sub-tab.active {
    background: var(--devo-sub-tab-active-bg);
    color: var(--devo-sub-tab-active-text);
}

/* Loading state */
.devo-loading {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--devo-text-muted);
}

.devo-loading .spinner-border {
    width: 1.5rem;
    height: 1.5rem;
    border-width: 0.15rem;
    margin-right: 0.5rem;
}

/* Error state */
.devo-error {
    text-align: center;
    padding: 1rem;
    color: #dc3545;
    font-size: 0.9rem;
}

/* Empty state (no devotional selected) */
.devo-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--devo-text-muted);
}

.devo-empty i {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    display: block;
}

/* --- Badge on Floating Button --- */
.bible-lookup-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 10px;
    height: 10px;
    background: var(--devo-badge-bg);
    border-radius: 50%;
    border: 2px solid #fff;
    display: none;
    animation: devo-badge-pulse 2s infinite;
}

[data-theme="dark"] .bible-lookup-badge {
    border-color: #1a1a2e;
}

.bible-lookup-badge.active {
    display: block;
}

@keyframes devo-badge-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* --- Settings Page Styles --- */
.devo-prefs-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.devo-prefs-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--devo-border);
}

.devo-prefs-list li:last-child {
    border-bottom: none;
}

.devo-prefs-list .form-check-label {
    font-size: 0.9rem;
}

.devo-prefs-list .form-check-label small {
    display: block;
    color: var(--devo-text-muted);
    font-size: 0.8rem;
    margin-top: 0.15rem;
}

/* Short text label (mobile) — hidden on desktop */
.devo-header-btn-short {
    display: none;
}

/* --- Responsive --- */
@media (max-width: 576px) {
    /* On mobile: hide full label + icon, show short text label */
    .devo-header-btn-label {
        display: none;
    }

    .devo-header-btn i {
        display: none;
    }

    .devo-header-btn-short {
        display: inline;
    }

    .devo-header-btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.72rem;
        font-weight: 600;
        letter-spacing: 0.02em;
        text-transform: uppercase;
    }

    .devo-body {
        font-size: 0.88rem;
    }

    .devo-scripture {
        padding: 0.65rem 0.75rem;
    }

    /* Sub-tabs: icon-only on mobile */
    .devo-sub-tab {
        font-size: 0;      /* Hide text */
        padding: 0.45rem;
    }

    .devo-sub-tab i {
        font-size: 0.9rem; /* Show icon */
    }

    /* Copy button: icon-only on mobile */
    .devo-copy-label {
        display: none;
    }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    .bible-lookup-badge {
        animation: none;
    }

    .devo-header-btn,
    .devo-sub-tab,
    .devo-nav-btn,
    .devo-today-btn,
    .devo-font-btn,
    .devo-copy-btn {
        transition: none;
    }
}

/* --- Print --- */
@media print {
    .devo-header-toggle,
    .devo-selector,
    .devo-sub-tabs,
    .devo-nav-btn,
    .devo-today-btn,
    .devo-toolbar {
        display: none;
    }
}
