/* ── Bootstrap Overrides & Brand Colors ─────────── */
:root {
    --bs-primary: #14342b;
    --bs-primary-rgb: 20, 52, 43;
    --bs-link-color: #14342b;
    --bs-link-hover-color: #265748;
    --bs-body-font-family: "Verdana", "Tahoma", "Segoe UI", sans-serif;
    --bs-body-font-size: 0.9375rem;
    --bs-body-color: #1f241f;
    --bs-body-bg: #f5f0e7;

    /* Internal aliases */
    --accent: #14342b;
    --accent-soft: #265748;
    --muted: #5f6c63;
}

.btn-primary {
    --bs-btn-bg: #14342b;
    --bs-btn-border-color: #14342b;
    --bs-btn-hover-bg: #1b4a3c;
    --bs-btn-hover-border-color: #1b4a3c;
    --bs-btn-active-bg: #265748;
    --bs-btn-color: #f7f3eb;
    --bs-btn-hover-color: #f7f3eb;
    --bs-btn-active-color: #f7f3eb;
    box-shadow: 0 8px 20px rgba(20, 52, 43, 0.22);
}

.btn-outline-secondary {
    --bs-btn-color: #14342b;
    --bs-btn-border-color: rgba(20, 52, 43, 0.25);
    --bs-btn-hover-bg: rgba(20, 52, 43, 0.08);
    --bs-btn-hover-border-color: rgba(20, 52, 43, 0.35);
    --bs-btn-hover-color: #14342b;
    --bs-btn-active-bg: rgba(20, 52, 43, 0.12);
    --bs-btn-active-color: #14342b;
    background: rgba(20, 52, 43, 0.06);
}

.btn-outline-danger {
    --bs-btn-color: #8a1f11;
    --bs-btn-border-color: rgba(138, 31, 17, 0.3);
    --bs-btn-hover-bg: rgba(138, 31, 17, 0.08);
    --bs-btn-hover-color: #8a1f11;
    --bs-btn-hover-border-color: rgba(138, 31, 17, 0.4);
}

/* ── Tab Buttons (auth + editor) ─────────────────── */
.auth-tab,
.editor-tab {
    border-radius: 999px;
    border: 1px solid rgba(20, 52, 43, 0.22);
    background: rgba(20, 52, 43, 0.06);
    color: var(--accent);
    font-weight: 600;
    padding: 0.45rem 1rem;
    transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
    line-height: 1.4;
    white-space: nowrap;
}

.auth-tab:hover:not(.active),
.editor-tab:hover:not(.active) {
    background: rgba(20, 52, 43, 0.12);
    color: var(--accent);
    border-color: rgba(20, 52, 43, 0.35);
}

.auth-tab.active,
.editor-tab.active {
    background: var(--accent);
    color: #f7f3eb;
    border-color: var(--accent);
}

.form-control:focus,
.form-select:focus {
    border-color: rgba(20, 52, 43, 0.35);
    box-shadow: 0 0 0 0.25rem rgba(20, 52, 43, 0.12);
}

.form-check-input:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}

.form-check-input:focus {
    box-shadow: 0 0 0 0.25rem rgba(20, 52, 43, 0.2);
    border-color: rgba(20, 52, 43, 0.5);
}

.badge.bg-secondary {
    background-color: rgba(20, 52, 43, 0.15) !important;
    color: var(--accent) !important;
}

/* ── Global ─────────────────────────────────────── */
* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    position: relative;
    overflow-x: hidden;
    background:
        radial-gradient(circle at top left, rgba(203, 161, 95, 0.28), transparent 30%),
        radial-gradient(circle at bottom right, rgba(38, 87, 72, 0.18), transparent 26%),
        linear-gradient(135deg, #f5f0e7 0%, #ece7da 48%, #f7f4ed 100%);
}

/* ── Background Shapes ──────────────────────────── */
.background-shape {
    position: fixed;
    z-index: 0;
    border-radius: 999px;
    filter: blur(30px);
    opacity: 0.55;
}

.background-shape-left {
    top: -120px;
    left: -60px;
    width: 280px;
    height: 280px;
    background: rgba(194, 145, 79, 0.34);
}

.background-shape-right {
    right: -70px;
    bottom: 10%;
    width: 320px;
    height: 320px;
    background: rgba(38, 87, 72, 0.18);
}

/* ── Auth Screen ────────────────────────────────── */
.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    position: relative;
    z-index: 2;
}

.auth-card {
    width: min(520px, 100%);
    backdrop-filter: blur(14px);
    background: rgba(255, 251, 245, 0.92) !important;
    border-radius: 1.5rem !important;
    border: 1px solid rgba(20, 52, 43, 0.14) !important;
}

.auth-status {
    min-height: 20px;
}

/* ── App Shell ──────────────────────────────────── */
.app-shell {
    position: relative;
    z-index: 1;
}

.sidebar-panel,
.editor-panel {
    backdrop-filter: blur(14px);
    background: rgba(255, 251, 245, 0.88) !important;
    border: 1px solid rgba(20, 52, 43, 0.12) !important;
    border-radius: 1.5rem !important;
    box-shadow: 0 20px 50px rgba(34, 32, 24, 0.10) !important;
}

/* ── Eyebrow ────────────────────────────────────── */
.eyebrow {
    margin: 0 0 8px;
    color: var(--accent-soft);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

/* ── User Bar ───────────────────────────────────── */
.user-bar {
    background: rgba(255, 253, 249, 0.6);
    border-color: rgba(20, 52, 43, 0.12) !important;
}

/* ── Note Cards ─────────────────────────────────── */
.note-card {
    background: rgba(255, 250, 241, 0.95) !important;
    border: 1px solid rgba(20, 52, 43, 0.08) !important;
    border-radius: 1.25rem !important;
    transition: transform 160ms ease, box-shadow 160ms ease;
    color: var(--bs-body-color);
}

.note-card:hover {
    transform: translateY(-1px);
    background: rgba(255, 250, 241, 1) !important;
    color: var(--bs-body-color);
}

.note-card.active {
    outline: 2px solid rgba(20, 52, 43, 0.3);
    color: var(--bs-body-color);
}

.note-card.is-sensitive,
.history-card.is-sensitive {
    border-color: rgba(20, 52, 43, 0.32) !important;
    box-shadow: inset 4px 0 0 rgba(20, 52, 43, 0.45) !important;
}

.note-card-title {
    font-size: 1rem;
    font-weight: 700;
}

.note-card-reminder-badge {
    background-color: rgba(180, 120, 0, 0.15) !important;
    color: rgba(140, 90, 0, 1) !important;
    border: 1px solid rgba(180, 120, 0, 0.25);
}

/* ── Note & History Preview ─────────────────────── */
.note-card-preview,
.history-content {
    display: -webkit-box;
    line-clamp: 4;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.note-card-preview a,
.history-content a {
    color: var(--accent-soft);
    text-decoration-thickness: 1px;
    overflow-wrap: anywhere;
    word-break: break-all;
}

/* ── Notes List ─────────────────────────────────── */
.notes-list {
    min-height: 40px;
}

/* ── History ─────────────────────────────────────── */
.history-list {
    overflow: auto;
    max-height: 50vh;
}

.history-card {
    background: rgba(255, 250, 241, 0.9) !important;
    border: 1px solid rgba(20, 52, 43, 0.08) !important;
    border-radius: 1.25rem !important;
}

.history-title {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.history-diff-added,
.history-diff-removed {
    border-radius: 4px;
    padding: 0 2px;
}

.history-diff-added {
    background: rgba(45, 160, 67, 0.2);
}

.history-diff-removed {
    background: rgba(206, 53, 44, 0.2);
    text-decoration: line-through;
}

/* ── Sensitive Toggle ───────────────────────────── */
.sensitive-toggle {
    background: rgba(255, 253, 249, 0.88);
    border-color: rgba(20, 52, 43, 0.16) !important;
    color: var(--accent-soft);
    cursor: pointer;
}

/* ── Editor Tab Badge ───────────────────────────── */
.editor-tab-badge {
    border-radius: 999px;
}

.editor-tab.active .editor-tab-badge {
    background: rgba(255, 250, 241, 0.25);
    color: #f7f3eb;
}

.editor-tab:not(.active) .editor-tab-badge {
    background: rgba(20, 52, 43, 0.14);
    color: var(--accent);
}

/* ── Empty State ─────────────────────────────────── */
.empty-state {
    padding: 16px;
    border: 1px dashed rgba(20, 52, 43, 0.18);
    border-radius: 1rem;
    color: var(--muted);
    text-align: center;
    background: rgba(255, 250, 241, 0.5);
    font-size: 0.88rem;
}

/* ── Reminder Panel ─────────────────────────────── */
.reminder-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.reminder-status {
    min-height: 18px;
}

.reminder-status.reminder-active {
    color: var(--accent-soft) !important;
    font-weight: 600;
}

/* ── Files & Images ─────────────────────────────── */
.files-list {
    min-height: 80px;
    max-height: 250px;
    overflow: auto;
}

.images-grid {
    max-height: 280px;
    overflow: auto;
}

.image-thumb-button {
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    background: transparent;
    display: block;
    width: 100%;
}

.image-thumb-button img {
    width: 100%;
    height: 105px;
    object-fit: cover;
    border-radius: 0.5rem;
    display: block;
}

/* ── Lightbox ─────────────────────────────────────── */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(17, 25, 21, 0.84);
    z-index: 20;
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr) 56px;
    align-items: center;
    gap: 10px;
    padding: 24px;
}

.lightbox[hidden] {
    display: none;
}

.lightbox img {
    width: 100%;
    max-height: 82vh;
    object-fit: contain;
    border-radius: 14px;
}

.lightbox-nav,
.lightbox-close {
    background: rgba(255, 250, 241, 0.9) !important;
    color: var(--accent) !important;
    border-radius: 999px !important;
    width: 42px;
    height: 42px;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.lightbox-close {
    position: absolute;
    top: 12px;
    right: 14px;
}

.lightbox-caption {
    grid-column: 1 / -1;
    text-align: center;
    color: #f8f3ea;
    font-size: 0.9rem;
}

/* ── Animations ──────────────────────────────────── */
@media (prefers-reduced-motion: no-preference) {
    .sidebar-panel,
    .editor-panel {
        animation: reveal 420ms ease both;
    }

    .editor-panel {
        animation-delay: 90ms;
    }
}

@keyframes reveal {
    from {
        opacity: 0;
        transform: translateY(14px);
    }

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