/* ==========================================================================
   Flashnotes v2 — styling
   All colors live in CSS custom properties; the derived ones (--surface,
   --border, --muted) are recomputed by app.js whenever bg/text change.
   ========================================================================== */

:root {
    --bg: #1a1a1a;
    --text: #e8e0d0;
    --accent: #c8a96e;
    --surface: #262523;
    --border: #3a3835;
    --muted: #8d867a;
    --font: 'JetBrains Mono', monospace;
    --font-size: 15px;
    --line-height: 1.8;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

::selection { background: var(--accent); color: var(--bg); }

html, body {
    min-height: 100vh;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    transition: background-color 0.35s ease, color 0.35s ease;
}

/* Centered container, switchable to full width */
#app {
    width: 100%;
    max-width: 860px;
    margin: 0 auto;
    padding: 0 24px 32px;
    display: grid;
    align-content: start;          /* content always starts below the header */
    transition: max-width 0.4s ease;
}

#app.full-width {
    max-width: 100%;
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 0 16px;
    border-bottom: 1px solid var(--border);
    transition: border-color 0.35s ease, opacity 0.3s ease;
}

.logo {
    color: var(--accent);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.logo .version {
    color: var(--muted);
    font-size: 11px;
    font-weight: 400;
    margin-left: 4px;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.btn {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 14px;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.btn:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.btn-icon {
    padding: 6px 10px;
    font-size: 14px;
}

.btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    color: var(--muted);
    border-color: var(--border);
}

.btn:disabled:hover {
    color: var(--muted);
    border-color: var(--border);
}

.btn-danger:hover {
    color: #d16a6a;
    border-color: #d16a6a;
}

/* --------------------------------------------------------------------------
   Settings panel (collapsible)
   -------------------------------------------------------------------------- */

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

.settings-panel.open {
    max-height: 640px;
    opacity: 1;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 18px 28px;
    padding: 22px 4px;
    border-bottom: 1px solid var(--border);
    transition: border-color 0.35s ease;
}

.setting label {
    display: block;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.setting .live-value {
    color: var(--accent);
    text-transform: none;
    letter-spacing: 0;
}

.setting .control {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Color pickers */
input[type="color"] {
    width: 34px;
    height: 26px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: transparent;
    cursor: pointer;
}

/* Preset color dots */
.presets {
    display: flex;
    gap: 6px;
}

.preset-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid var(--border);
    cursor: pointer;
    padding: 0;
    transition: transform 0.15s ease, border-color 0.2s ease;
}

.preset-dot:hover {
    transform: scale(1.2);
    border-color: var(--accent);
}

/* Select */
select {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    width: 100%;
    max-width: 200px;
}

/* Range sliders */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    max-width: 200px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    cursor: pointer;
}

/* Custom toggle switch */
.switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 22px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch .slider {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 22px;
    transition: background-color 0.25s ease;
}

.switch .slider::before {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    top: 3px;
    background: var(--text);
    border-radius: 50%;
    transition: transform 0.25s ease, background-color 0.25s ease;
}

.switch input:checked + .slider {
    background: var(--accent);
}

.switch input:checked + .slider::before {
    transform: translateX(20px);
    background: var(--bg);
}

/* --------------------------------------------------------------------------
   Tab bar
   -------------------------------------------------------------------------- */

.tab-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 16px 0 12px;
    overflow-x: auto;
    scrollbar-width: none;         /* horizontally scrollable, no visible bar */
    transition: opacity 0.3s ease;
}

.tab-bar::-webkit-scrollbar { display: none; }

.tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--muted);
    font-size: 12px;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    flex-shrink: 0;
    transition: color 0.2s ease, border-color 0.2s ease,
                background-color 0.2s ease, opacity 0.2s ease;
}

.tab:hover { color: var(--text); border-color: var(--accent); }

.tab.active {
    color: var(--text);
    border-color: var(--accent);
    background: var(--surface);
}

/* Content indicator dot */
.tab .dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tab.has-content .dot { opacity: 1; }

/* Close button, visible on hover */
.tab .close {
    font-size: 13px;
    opacity: 0;
    padding: 0 1px;
    transition: opacity 0.2s ease, color 0.2s ease;
}

.tab:hover .close { opacity: 0.7; }
.tab .close:hover { opacity: 1; color: var(--accent); }

/* Drag & drop states */
.tab.dragging {
    opacity: 0.4;
    border-style: dashed;
}

.tab.drag-over {
    border-color: var(--accent);
    background: var(--surface);
}

/* New-note button */
.tab-add {
    border: 1px dashed var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font-family: inherit;
    font-size: 14px;
    line-height: 1;
    padding: 5px 12px;
    cursor: pointer;
    flex-shrink: 0;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.tab-add:hover {
    color: var(--accent);
    border-color: var(--accent);
}

/* --------------------------------------------------------------------------
   Editor
   -------------------------------------------------------------------------- */

#editor {
    width: 100%;
    min-height: 60vh;
    background: transparent;
    color: var(--text);
    border: none;
    outline: none;
    resize: none;
    font-family: var(--font);
    font-size: var(--font-size);
    line-height: var(--line-height);
    caret-color: var(--accent);
    padding: 8px 0;
    transition: color 0.35s ease, min-height 0.3s ease;
}

#editor::placeholder {
    color: var(--muted);
    opacity: 0.7;
}

/* --------------------------------------------------------------------------
   Status bar
   -------------------------------------------------------------------------- */

.status-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 0;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 11px;
    transition: border-color 0.35s ease, opacity 0.3s ease;
}

.status-bar .sep { opacity: 0.5; }

.save-indicator {
    margin-left: auto;
    color: var(--accent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.save-indicator.flash { opacity: 1; }

/* --------------------------------------------------------------------------
   Focus mode: only the editor remains
   -------------------------------------------------------------------------- */

body.focus-mode .app-header,
body.focus-mode .settings-panel,
body.focus-mode .tab-bar,
body.focus-mode .status-bar {
    opacity: 0;
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-width: 0;
    overflow: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, max-height 0.35s ease, padding 0.35s ease;
}

.app-header,
.tab-bar,
.status-bar {
    max-height: 90px;              /* transition anchor for focus mode */
}

body.focus-mode #editor {
    min-height: 90vh;
}

/* --------------------------------------------------------------------------
   Toasts
   -------------------------------------------------------------------------- */

.toast-container {
    position: fixed;
    right: 20px;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 100;
}

.toast {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 6px;
    padding: 10px 16px;
    font-size: 12px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* --------------------------------------------------------------------------
   Narrow screens
   -------------------------------------------------------------------------- */

@media (max-width: 560px) {
    #app { padding: 0 14px 24px; }

    .app-header {
        flex-wrap: wrap;
        gap: 10px;
        max-height: 140px;
    }

    .settings-grid { grid-template-columns: 1fr; }
}
