/* ═══════════════════════════════════════
   JOURNAL — Core Styles
   ═══════════════════════════════════════ */

/* ── Gate Overlay ── */
.gate-overlay {
    position: fixed; inset: 0; z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    background: var(--deft-base, #08090D);
}
.gate-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: var(--deft-txt, #E8ECF1);
    background: var(--deft-surface, #11131A);
    border: 1px solid var(--deft-border, #2A2E3D);
    border-radius: 0.5rem;
    outline: none;
    transition: border-color 0.15s;
}
.gate-input:focus { border-color: var(--deft-accent, #06D6A0); }
.gate-error {
    color: var(--deft-danger, #FF6B6B);
    font-size: 0.75rem;
    margin-top: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s;
}
.gate-error.show { opacity: 1; }

/* ── Buttons ── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem;
    padding: 0.5rem 1rem;
    font-size: 0.75rem; font-weight: 600;
    border-radius: 0.5rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
    text-decoration: none;
    white-space: nowrap;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary {
    background: var(--deft-accent, #06D6A0);
    color: #000;
    border-color: var(--deft-accent, #06D6A0);
}
.btn-primary:hover:not(:disabled) { opacity: 0.85; }
.btn-ghost {
    background: transparent;
    color: var(--deft-txt-2, #8A95A9);
    border-color: var(--deft-border, #2A2E3D);
}
.btn-ghost:hover:not(:disabled) {
    background: rgba(255,255,255,0.04);
    color: var(--deft-txt, #E8ECF1);
}
.btn-sm { padding: 0.3rem 0.625rem; font-size: 0.65rem; }
.btn-xs { padding: 0.2rem 0.5rem; font-size: 0.6rem; }
.btn-icon {
    width: 32px; height: 32px;
    padding: 0;
    border-radius: 0.375rem;
    background: rgba(17, 19, 26, 0.5);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(42, 46, 61, 0.6);
    color: var(--deft-txt-2, #8A95A9);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s, color 0.15s;
}
.btn-icon:hover { background: rgba(17, 19, 26, 0.8); color: var(--deft-txt, #E8ECF1); }

/* ── Journal Tabs ── */
.journal-tabs {
    display: flex;
    gap: 0.25rem;
    padding: 0.5rem 1rem;
    background: var(--deft-surface, #11131A);
    border-bottom: 1px solid var(--deft-border, #2A2E3D);
}
.journal-tab {
    padding: 0.4rem 0.875rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--deft-txt-3, #525E73);
    background: transparent;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.journal-tab:hover { color: var(--deft-txt-2, #8A95A9); background: rgba(255,255,255,0.04); }
.journal-tab.active {
    color: var(--deft-accent, #06D6A0);
    background: rgba(6,214,160,0.08);
}

/* ── Modal System ── */
.modal-backdrop {
    position: fixed; inset: 0; z-index: 100;
    display: none;
    align-items: center; justify-content: center;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
}
.modal-backdrop.active {
    display: flex;
}
.modal-content {
    width: 92vw;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
    background: var(--deft-surface-el, #1A1D28);
    border: 1px solid var(--deft-border, #2A2E3D);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}
.modal-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--deft-txt, #E8ECF1);
}

/* ── Toast System ── */
.toast-container {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.toast {
    padding: 0.625rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: #fff;
    background: var(--deft-surface-el, #1A1D28);
    border: 1px solid var(--deft-border, #2A2E3D);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    opacity: 1;
    transition: opacity 0.3s;
}
.toast-success { border-left: 3px solid var(--deft-success, #06D6A0); }
.toast-error { border-left: 3px solid var(--deft-danger, #FF6B6B); }
.toast-info { border-left: 3px solid var(--deft-accent-warm, #4CC9F0); }

/* ── Daily View Layout ── */
.daily-wrapper {
    position: relative;
    min-height: calc(100vh - 130px);
    border-radius: 0.75rem;
    overflow: hidden;
}
.daily-background {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}
.daily-content {
    position: relative;
    z-index: 1;
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem 1.5rem;
}
.daily-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    padding: 0.625rem 0.75rem;
    background: var(--journal-panel-bg, rgba(26,29,40,0.75));
    backdrop-filter: blur(var(--journal-panel-blur));
    border-radius: 0.5rem;
}
.daily-date-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.daily-date-label {
    font-size: 1rem;
    font-weight: 700;
    color: var(--jday-heading-color, var(--deft-txt, #E8ECF1));
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    min-width: 160px;
    text-align: center;
}
.daily-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ── Sticker Canvas Overlay ── */
.sticker-canvas-wrapper {
    position: absolute;
    inset: 0;
    z-index: 5;
    pointer-events: none;
}

/* ── Journal Transparency (configurable via settings sliders) ── */
:root {
    --journal-panel-opacity: 0.75;
    --journal-panel-blur: 8px;
    --journal-panel-bg: rgba(26, 29, 40, 0.75);
    --journal-panel-bg-hover: rgba(26, 29, 40, 0.85);
}

/* ── Quill Editor Overrides ── */
.ql-toolbar.ql-snow {
    border-color: var(--deft-border, #2A2E3D) !important;
    background: var(--journal-panel-bg, rgba(26,29,40,0.75)) !important;
    backdrop-filter: blur(var(--journal-panel-blur));
    border-radius: 0.5rem 0.5rem 0 0;
}
.ql-container.ql-snow {
    border-color: var(--deft-border, #2A2E3D) !important;
    background: var(--journal-panel-bg, rgba(26,29,40,0.75)) !important;
    backdrop-filter: blur(var(--journal-panel-blur));
    border-radius: 0 0 0.5rem 0.5rem;
    min-height: 300px;
    font-family: var(--deft-body-font, 'IBM Plex Sans'), system-ui, sans-serif;
}
.ql-editor {
    color: var(--jday-body-color, var(--deft-txt, #E8ECF1)) !important;
    font-size: 0.875rem;
    line-height: 1.7;
    min-height: 300px;
    padding: 1rem 1.25rem;
}
.ql-editor.ql-blank::before {
    color: var(--deft-txt-3, #525E73) !important;
    font-style: normal !important;
}
.ql-snow .ql-stroke { stroke: var(--deft-txt-2, #8A95A9) !important; }
.ql-snow .ql-fill { fill: var(--deft-txt-2, #8A95A9) !important; }
.ql-snow .ql-picker-label { color: var(--deft-txt-2, #8A95A9) !important; }
.ql-snow .ql-picker-options {
    background: var(--deft-surface-el, #1A1D28) !important;
    border-color: var(--deft-border, #2A2E3D) !important;
}
.ql-snow .ql-picker-item { color: var(--deft-txt-2, #8A95A9) !important; }
.ql-snow .ql-picker-item:hover { color: var(--deft-txt, #E8ECF1) !important; }
.ql-snow .ql-active .ql-stroke { stroke: var(--deft-accent, #06D6A0) !important; }
.ql-snow .ql-active .ql-fill { fill: var(--deft-accent, #06D6A0) !important; }
.ql-snow .ql-active { color: var(--deft-accent, #06D6A0) !important; }
.ql-snow a { color: var(--deft-accent, #06D6A0) !important; }
.ql-editor h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.5rem; }
.ql-editor h2 { font-size: 1.25rem; font-weight: 600; margin-bottom: 0.5rem; }
.ql-editor h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.375rem; }
.ql-editor blockquote {
    border-left: 3px solid var(--deft-accent, #06D6A0);
    padding-left: 1rem;
    color: var(--deft-txt-2, #8A95A9);
}
.ql-editor pre.ql-syntax {
    background: rgba(0,0,0,0.3) !important;
    color: var(--deft-txt, #E8ECF1) !important;
    border-radius: 0.375rem;
    padding: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
}
.ql-editor img {
    max-width: 100%;
    border-radius: 0.5rem;
    margin: 0.5rem 0;
}

/* ── Section Panels ── */
.journal-section {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--journal-panel-bg, rgba(26,29,40,0.75));
    backdrop-filter: blur(var(--journal-panel-blur));
    border: 1px solid rgba(42, 46, 61, 0.6);
    border-radius: 0.625rem;
}
.journal-section-title {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--jday-section-color, var(--deft-txt-2, #8A95A9));
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ── BRAIN Activity Cards ── */
.brain-activity-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.brain-activity-card:last-child { border-bottom: none; }
.brain-activity-icon {
    width: 28px; height: 28px;
    border-radius: 0.375rem;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem;
    background: rgba(6,214,160,0.1);
    flex-shrink: 0;
}
.brain-activity-info { flex: 1; min-width: 0; }
.brain-activity-title {
    font-size: 0.75rem; font-weight: 600;
    color: var(--jday-body-color, var(--deft-txt, #E8ECF1));
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brain-activity-meta {
    font-size: 0.65rem;
    color: var(--jday-section-color, var(--deft-txt-2, #8A95A9));
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    display: flex; gap: 0.5rem;
}

/* ── Next Steps ── */
.next-step-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0;
}
.next-step-checkbox {
    width: 16px; height: 16px;
    border: 1.5px solid var(--jday-section-color, var(--deft-border, #2A2E3D));
    border-radius: 0.25rem;
    background: transparent;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s, border-color 0.15s;
    flex-shrink: 0;
    padding: 0;
}
.next-step-checkbox.checked {
    background: var(--jday-accent-color, var(--deft-accent, #06D6A0));
    border-color: var(--jday-accent-color, var(--deft-accent, #06D6A0));
}
.next-step-title {
    flex: 1;
    font-size: 0.75rem;
    color: var(--jday-body-color, var(--deft-txt, #E8ECF1));
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.next-step-title.completed {
    text-decoration: line-through;
    color: var(--jday-section-color, var(--deft-txt-3, #525E73));
}
.next-step-actions {
    display: flex;
    gap: 0.25rem;
}
.next-step-add {
    margin-top: 0.5rem;
    display: flex;
    gap: 0.375rem;
}
.next-step-input {
    flex: 1;
    padding: 0.375rem 0.625rem;
    font-size: 0.7rem;
    color: var(--jday-body-color, var(--deft-txt, #E8ECF1));
    background: rgba(17, 19, 26, 0.5);
    border: 1px solid var(--jday-section-color, var(--deft-border, #2A2E3D));
    border-radius: 0.375rem;
    outline: none;
}
.next-step-input:focus { border-color: var(--jday-accent-color, var(--deft-accent, #06D6A0)); }

/* ── Custom Sticker Picker Delete Button ── */
.sticker-picker-custom-card { position: relative; display: inline-block; }
.sticker-picker-custom-delete {
    position: absolute; top: -4px; right: -4px;
    width: 18px; height: 18px; border-radius: 50%;
    background: rgba(255,107,107,0.9); color: #fff;
    border: none; cursor: pointer;
    font-size: 0.7rem; font-weight: 700; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.15s;
    z-index: 2;
}
.sticker-picker-custom-card:hover .sticker-picker-custom-delete { opacity: 1; }
.sticker-picker-custom-delete:hover { background: #FF6B6B; transform: scale(1.15); }

/* ── Background Picker Delete Button ── */
.bg-picker-card { position: relative; }
.bg-picker-card-inner {
    display: flex; flex-direction: column; align-items: center;
    gap: 0.25rem; cursor: pointer; border: none;
    background: transparent; padding: 0; width: 100%;
}
.bg-picker-delete {
    position: absolute; top: -4px; right: -4px;
    width: 18px; height: 18px; border-radius: 50%;
    background: rgba(255,107,107,0.9); color: #fff;
    border: none; cursor: pointer;
    font-size: 0.7rem; font-weight: 700; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.15s;
    z-index: 2;
}
.bg-picker-card:hover .bg-picker-delete { opacity: 1; }
.bg-picker-delete:hover { background: #FF6B6B; transform: scale(1.15); }

/* ── Save Status Indicator ── */
.save-status {
    font-size: 0.6rem;
    font-weight: 500;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    letter-spacing: 0.02em;
}
.save-status-saved { color: var(--deft-success, #06D6A0); background: rgba(6,214,160,0.08); }
.save-status-unsaved { color: var(--deft-warning, #FFD93D); background: rgba(255,217,61,0.08); }
.save-status-saving { color: var(--deft-txt-3, #525E73); background: rgba(255,255,255,0.04); }

/* ── Mood Selector ── */
.mood-bar {
    display: flex;
    gap: 0.25rem;
}
.mood-btn {
    width: 28px; height: 28px;
    border: 1.5px solid transparent;
    border-radius: 0.375rem;
    background: transparent;
    cursor: pointer;
    font-size: 1rem;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.mood-btn:hover { background: rgba(255,255,255,0.06); transform: scale(1.15); }
.mood-btn.active {
    border-color: var(--deft-accent, #06D6A0);
    background: rgba(6,214,160,0.1);
    transform: scale(1.15);
}

/* ── Search View ── */
.search-input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    font-size: 0.8rem;
    color: var(--deft-txt, #E8ECF1);
    background: var(--deft-surface, #11131A);
    border: 1px solid var(--deft-border, #2A2E3D);
    border-radius: 0.625rem;
    outline: none;
    transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--deft-accent, #06D6A0); }
.search-result-card {
    padding: 0.75rem;
    border: 1px solid var(--deft-border, #2A2E3D);
    border-radius: 0.5rem;
    background: var(--deft-surface, #11131A);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    margin-bottom: 0.5rem;
}
.search-result-card:hover {
    background: var(--deft-surface-el, #1A1D28);
    border-color: rgba(6,214,160,0.3);
}

/* ── Version History ── */
.version-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.version-item:last-child { border-bottom: none; }
.version-badge {
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.1rem 0.375rem;
    border-radius: 999px;
    letter-spacing: 0.03em;
}
.version-badge-manual { color: var(--deft-accent, #06D6A0); background: rgba(6,214,160,0.1); }
.version-badge-autosave { color: var(--deft-txt-3, #525E73); background: rgba(255,255,255,0.04); }

/* ── Pulse Dot ── */
.pulse-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #06D6A0;
    animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.3); }
}

/* ── Responsive ── */
@media (max-width: 639px) {
    .daily-header { flex-direction: column; align-items: stretch; }
    .daily-date-nav { justify-content: center; }
    .daily-actions { justify-content: center; }
    .journal-tabs { overflow-x: auto; }
    .ql-editor { min-height: 200px; padding: 0.75rem; }
    .mood-bar { flex-wrap: wrap; justify-content: center; }
}

/* ── Favorite Star ── */
.fav-btn {
    background: none; border: none;
    cursor: pointer;
    font-size: 1rem;
    transition: transform 0.15s;
    padding: 0.25rem;
}
.fav-btn:hover { transform: scale(1.2); }

/* ── Empty States ── */
.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--jday-section-color, var(--deft-txt-2, #8A95A9));
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    font-size: 0.75rem;
}
.empty-state-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.4;
}

/* ── Title Input ── */
.journal-title-input {
    width: 100%;
    padding: 0.5rem 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--jday-heading-color, var(--deft-txt, #E8ECF1));
    text-shadow: 0 1px 3px rgba(0,0,0,0.4);
    background: transparent;
    border: none;
    outline: none;
    margin-bottom: 0.5rem;
    font-family: var(--deft-heading-font, 'Chakra Petch'), system-ui, sans-serif;
}
.journal-title-input::placeholder {
    color: var(--jday-section-color, var(--deft-txt-3, #525E73));
}

/* ── Word Count ── */
.word-count {
    font-size: 0.6rem;
    color: var(--jday-section-color, var(--deft-txt-2, #8A95A9));
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    font-family: 'JetBrains Mono', monospace;
}

/* ── Settings View ── */
.settings-section {
    margin-bottom: 1.5rem;
}
.settings-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--deft-txt-3, #525E73);
    margin-bottom: 0.5rem;
}

/* ── Print ── */
.print-only { display: none; }

@media print {
    @page {
        size: letter portrait;
        margin: 0.5in;
    }

    body > *:not(#printArea) { display: none !important; }
    #printArea, .print-only { display: block !important; }

    body {
        background: white !important;
        color: black !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    #printArea {
        font-family: Georgia, 'Times New Roman', serif;
        font-size: 11pt;
        line-height: 1.5;
        color: black;
        width: 100%;
        max-width: none;
    }
    #printArea h1 { font-size: 20pt; margin: 0 0 8pt 0; }
    #printArea h2 { font-size: 14pt; margin: 12pt 0 6pt 0; border-bottom: 1px solid #999; padding-bottom: 2pt; }
    #printArea h3 { font-size: 12pt; margin: 10pt 0 4pt 0; color: #333; }
    #printArea .print-page { page-break-after: always; }
    #printArea .print-page:last-child { page-break-after: auto; }
    #printArea img { max-width: 100%; height: auto; }
    #printArea ul, #printArea ol { margin: 6pt 0 6pt 18pt; }
    #printArea .print-meta { color: #555; font-size: 10pt; margin-bottom: 10pt; }
    #printArea .print-mood { display: inline-block; padding: 2pt 6pt; border: 1px solid #999; border-radius: 3pt; font-size: 10pt; }

    #printArea .print-calendar { width: 100%; border-collapse: collapse; margin-top: 8pt; }
    #printArea .print-calendar th { border: 1px solid #999; padding: 3pt; font-size: 9pt; background: #eee; }
    #printArea .print-calendar td { border: 1px solid #ccc; padding: 4pt; vertical-align: top; height: 64pt; font-size: 9pt; }
    #printArea .print-calendar td.empty { background: #f9f9f9; }
    #printArea .print-calendar .day-num { font-weight: bold; font-size: 10pt; }
    #printArea .print-calendar .day-mood { font-size: 14pt; }

    nav, .nav, .journal-nav, .journal-tabs, .toast-container, .modal, .modal-backdrop, .daily-actions .btn, .daily-actions .btn-icon { display: none !important; }
}
