/* =====================================================================
   MyDrive — glassmorphic theme overlay (Phase 5).
   Tailwind via CDN handles 95% of styling. This file contains the few
   things Tailwind utilities can't express cleanly: backdrop-filter
   helpers, Material Symbols sizing, body gradient, drop overlay states,
   modal display fallbacks, toast animation, custom scrollbars.
   ===================================================================== */

body {
    background: radial-gradient(circle at top right, #1e293b, #0f172a 45%, #141313 80%);
    background-attachment: fixed;
    min-height: 100vh;
    /* Tell the browser to draw native form widgets (select popups, scrollbars,
       autofill, etc.) with a dark palette. Without this the <select> options
       popup paints with default white-on-black contrast against our dark UI. */
    color-scheme: dark;
}

/* Force dark backgrounds on every native <select> / <option>. Tailwind can
   style the closed-state of <select>, but the dropdown panel itself is
   browser-chrome — we have to colour it explicitly to match the theme. */
select {
    color-scheme: dark;
    background-color: #1f2937;   /* slate-800-ish */
    color: #e5e2e1;
}
select option {
    background-color: #1f2937;
    color: #e5e2e1;
}
select option:checked,
select option:hover {
    background-color: #3e90ff;
    color: #fff;
}

/* Hide the scrollbar on horizontally-scrollable navs (admin tabs, reaction
   bar, etc.) while keeping the scroll behavior. */
.no-scrollbar { scrollbar-width: none; -ms-overflow-style: none; }
.no-scrollbar::-webkit-scrollbar { display: none; }

/* On phones, iOS Safari auto-zooms when focusing a text input whose
   computed font-size is < 16px. Force 16px on small screens so the zoom
   doesn't fire when users tap into fields like comment boxes / chat. */
@media (max-width: 767px) {
    input[type="text"], input[type="email"], input[type="password"],
    input[type="search"], input[type="url"], input[type="number"],
    input[type="tel"], textarea, select {
        font-size: 16px !important;
    }
}

/* Brand wordmark — heavy geometric look, tight tracking, slight stretch.
   The text-fill is transparent so the gradient (set via background-clip:text)
   shows through; the drop-shadow gives the mark depth on dark surfaces. */
.brand-mark {
    font-family: 'Archivo Black', 'Manrope', system-ui, sans-serif;
    font-weight: 900;
    letter-spacing: -0.045em;
    text-transform: uppercase;
    line-height: 1;
    background: linear-gradient(135deg, #aac7ff 0%, #c2c1ff 50%, #3e90ff 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 8px rgba(62, 144, 255, 0.30))
            drop-shadow(0 1px 1px rgba(0, 0, 0, 0.45));
}
/* Collapsed sidebar — single-letter mark gets a punchier shadow. */
.sidebar-brand-mini.brand-mark {
    filter: drop-shadow(0 2px 10px rgba(62, 144, 255, 0.45))
            drop-shadow(0 1px 1px rgba(0, 0, 0, 0.55));
}

.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    user-select: none;
    line-height: 1;
}

/* HTML "hidden" attribute should always win, even against Tailwind utility
   classes like .grid / .flex / .block that set their own display. */
[hidden] { display: none !important; }

/* ----- Collapsible main sidebar ----- */

/* Brand "M" is hidden by default; the full name shows. Swap when collapsed. */
.sidebar-brand-mini { display: none; }

/* Smooth-shrink the sidebar + reflow main content + bottom bar on desktop. */
@media (min-width: 768px) {
    body.sidebar-collapsed #sidebar {
        width: 4.5rem;       /* icon rail */
    }
    body.sidebar-collapsed #sidebar .sidebar-label,
    body.sidebar-collapsed #sidebar .sidebar-brand,
    body.sidebar-collapsed #sidebar .sidebar-storage-block,
    body.sidebar-collapsed #sidebar .sidebar-primary-wrap .sidebar-label {
        display: none !important;
    }
    body.sidebar-collapsed #sidebar .sidebar-brand-mini { display: block; }

    /* Tighten padding of the surviving icon elements. */
    body.sidebar-collapsed #sidebar > .px-7,
    body.sidebar-collapsed #sidebar .sidebar-footer {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    body.sidebar-collapsed #sidebar .sidebar-link {
        padding-left: 0;
        padding-right: 0;
        justify-content: center;
    }
    body.sidebar-collapsed #sidebar .sidebar-primary-wrap a,
    body.sidebar-collapsed #sidebar .sidebar-primary-wrap button {
        padding: 0.75rem 0;
    }

    /* Main column + global player bar reflow to the new sidebar width.
       These selectors override the Tailwind utility classes md:ml-72 / md:left-72. */
    body.sidebar-collapsed main.md\:ml-72 { margin-left: 4.5rem; }
    body.sidebar-collapsed #bottom-bar.md\:left-72 { left: 4.5rem; }
    main.md\:ml-72,
    #bottom-bar.md\:left-72 { transition: margin-left 0.2s, left 0.2s; }
}

/* ----- Collapsible inner Notes sidebar ----- */
@media (min-width: 1024px) {
    body.notes-sidebar-collapsed .grid.lg\:grid-cols-\[260px_1fr\] {
        grid-template-columns: 4rem 1fr !important;
    }
    body.notes-sidebar-collapsed .notes-inner-sidebar .notes-inner-label,
    body.notes-sidebar-collapsed .notes-inner-sidebar kbd,
    body.notes-sidebar-collapsed .notes-inner-sidebar .notes-inner-folders-head > div > .text-sm {
        display: none !important;
    }
    body.notes-sidebar-collapsed .notes-inner-sidebar {
        padding-left: 0.25rem;
        padding-right: 0.25rem;
    }
    body.notes-sidebar-collapsed .notes-inner-sidebar > button,
    body.notes-sidebar-collapsed .notes-inner-sidebar > a {
        padding-left: 0;
        padding-right: 0;
        justify-content: center;
    }
    body.notes-sidebar-collapsed .notes-inner-sidebar .folder-link {
        justify-content: center;
        padding-left: 0; padding-right: 0;
    }
    body.notes-sidebar-collapsed .notes-inner-sidebar .notes-inner-folders-head {
        justify-content: center;
        padding: 0;
    }
}

/* ----- Notes dashboard ----- */

/* Note cards (Syncscribe-style colored pastel tiles, dark text inside). */
.note-card {
    flex: 0 0 240px;
    height: 280px;
    border-radius: 18px;
    padding: 18px 18px 14px;
    color: #1a1a1a;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    position: relative;
    box-shadow: 0 10px 30px -10px rgba(0,0,0,0.45), 0 1px 0 rgba(255,255,255,0.6) inset;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.note-card:hover { transform: translateY(-2px); box-shadow: 0 18px 40px -10px rgba(0,0,0,0.55), 0 1px 0 rgba(255,255,255,0.6) inset; }
.note-card__head    { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.note-card__title   { font-weight: 800; font-size: 9px; line-height: 1.2; }
.note-card__time    { font-size: 11px; color: rgba(0,0,0,0.55); letter-spacing: 0.02em; }
.note-card__body    {
    flex: 1; overflow: hidden;
    font-size: 13px; line-height: 1.5;
    color: rgba(0,0,0,0.78);
    white-space: pre-line; word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 6;
    -webkit-box-orient: vertical;
}
.note-card__edit {
    position: absolute;
    right: 14px; bottom: 14px;
    width: 36px; height: 36px;
    border-radius: 999px;
    background: rgba(0,0,0,0.85);
    color: #d3f26d;
    display: grid; place-items: center;
    font-size: 18px;
    box-shadow: 0 6px 18px -2px rgba(0,0,0,0.4);
    border: 2px solid #d3f26d;
}
.note-card--default { background: linear-gradient(180deg, #FFFFFF 0%, #F2F2F2 100%); }
.note-card--purple  { background: linear-gradient(180deg, #E3D8FF 0%, #CFC0F7 100%); }
.note-card--peach   { background: linear-gradient(180deg, #FFE3D1 0%, #F8CDB1 100%); }
.note-card--lime    { background: linear-gradient(180deg, #EEF8C5 0%, #DAEFA1 100%); }
.note-card--orange  { background: linear-gradient(180deg, #FFD7B2 0%, #F9B985 100%); }
.note-card--pink    { background: linear-gradient(180deg, #FFD3E2 0%, #F8B5CB 100%); }
.note-card--mint    { background: linear-gradient(180deg, #CFEFE4 0%, #ADE2CF 100%); }
.note-card--sky     { background: linear-gradient(180deg, #CFE5FB 0%, #A5CDF6 100%); }
.note-card--pinned::after {
    content: "";
    position: absolute; top: 12px; left: 12px;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: rgba(0,0,0,0.55);
}

/* Folder tile (orange, like the reference). */
.note-folder-card {
    flex: 0 0 160px;
    cursor: pointer;
    text-align: center;
    transition: transform 0.15s ease;
}
.note-folder-card:hover { transform: translateY(-2px); }
.note-folder-card__tile {
    position: relative;
    aspect-ratio: 1 / 1;
    width: 100%;
    border-radius: 22px;
    background: linear-gradient(180deg, #FCB570 0%, #F19842 100%);
    box-shadow: 0 14px 26px -8px rgba(231,127,40,0.55), 0 1px 0 rgba(255,255,255,0.6) inset;
    display: grid; place-items: center;
    color: #fff;
    font-weight: 900;
    font-size: 28px;
    letter-spacing: 0.05em;
    overflow: hidden;
}
.note-folder-card__tile::before {
    content: "";
    position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 50%; height: 14px;
    border-radius: 0 0 8px 8px;
    background: linear-gradient(180deg, #FFC78A 0%, #F2A451 100%);
}
.note-folder-card__name { margin-top: 12px; color: #fff; font-weight: 600; font-size: 14px; }
.note-folder-card__count { color: rgba(255,255,255,0.55); font-size: 11px; margin-top: 2px; }

/* Inner-sidebar folder list */
.folder-link {
    color: rgb(203 213 225);
    border: 1px solid transparent;
}
.folder-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.folder-link--active {
    background: rgba(255,255,255,0.08);
    color: #fff;
    border-color: rgba(255,255,255,0.10);
    font-weight: 600;
}

/* Rail navigation arrows (note + folder carousels). */
.rail-nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    z-index: 5;
    width: 36px; height: 36px;
    border-radius: 999px;
    background: rgba(255,255,255,0.92);
    color: #1a1a1a;
    display: grid; place-items: center;
    box-shadow: 0 8px 20px -4px rgba(0,0,0,0.4);
    cursor: pointer;
    transition: transform 0.15s;
}
.rail-nav:hover { transform: translateY(-50%) scale(1.05); }
.rail-nav--left  { left: -10px; }
.rail-nav--right { right: -10px; }

/* Note editor modal (light-themed inside, regardless of note color). */
.note-editor-light  { background: #fff;            color: #1a1a1a; }
.note-editor-light .border-current\/20 { border-color: rgba(0,0,0,0.18); }
.note-editor-light input::placeholder,
.note-editor-light textarea::placeholder { color: rgba(0,0,0,0.40); }

/* Rich-text editor surface */
.note-body-editor {
    font-size: 15px; line-height: 1.6;
}
.note-body-editor:empty::before {
    content: attr(data-placeholder);
    opacity: 0.40;
    pointer-events: none;
}
.note-body-editor h1, .note-body-editor h2, .note-body-editor h3,
.note-body-editor h4, .note-body-editor h5, .note-body-editor h6 {
    font-weight: 700; margin: 0.8em 0 0.4em;
}
.note-body-editor h1 { font-size: 1.8em; }
.note-body-editor h2 { font-size: 1.45em; }
.note-body-editor h3 { font-size: 1.2em; }
.note-body-editor p   { margin: 0.5em 0; }
.note-body-editor ul, .note-body-editor ol { padding-left: 1.5em; margin: 0.5em 0; }
.note-body-editor ul  { list-style: disc; }
.note-body-editor ol  { list-style: decimal; }
.note-body-editor li  { margin: 0.2em 0; }
.note-body-editor blockquote {
    border-left: 4px solid rgba(0,0,0,0.18);
    padding-left: 1em; margin: 0.6em 0;
    color: rgba(0,0,0,0.7); font-style: italic;
}
.note-body-editor pre {
    background: rgba(0,0,0,0.08); padding: 12px 14px;
    border-radius: 8px; overflow-x: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.92em;
}
.note-body-editor code {
    background: rgba(0,0,0,0.08); padding: 1px 6px;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.92em;
}
.note-body-editor pre code { background: transparent; padding: 0; }
.note-body-editor a    { color: #1d4ed8; text-decoration: underline; }
.note-body-editor table {
    border-collapse: collapse;
    margin: 0.8em 0;
    max-width: 100%;
}
.note-body-editor td, .note-body-editor th {
    border: 1px solid rgba(0,0,0,0.20);
    padding: 6px 10px;
}
.note-body-editor th   { background: rgba(0,0,0,0.05); font-weight: 700; }
.note-body-editor img  { max-width: 100%; height: auto; border-radius: 6px; }
.note-body-editor video { max-width: 100%; height: auto; border-radius: 8px; background: #000; display: block; margin: 0.6em 0; }
.note-body-editor audio { width: 100%; margin: 0.5em 0; }
.note-body-editor hr   { border: 0; border-top: 1px solid rgba(0,0,0,0.15); margin: 1em 0; }

/* Toolbar buttons (inside the light-themed editor) */
.toolbar-btn {
    display: inline-grid; place-items: center;
    width: 30px; height: 30px;
    border-radius: 6px;
    color: rgba(0,0,0,0.65);
    transition: background 0.15s, color 0.15s;
    cursor: pointer;
}
.toolbar-btn:hover            { background: rgba(0,0,0,0.08); color: #000; }
.toolbar-btn.toolbar-btn--on  { background: rgba(0,0,0,0.10); color: #000; }

/* Color picker swatches */
.color-swatch {
    width: 28px; height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.1s;
}
.color-swatch:hover { transform: scale(1.1); }
.color-swatch--selected { border-color: rgba(0,0,0,0.6); }

.color-default { background: linear-gradient(180deg, #FFFFFF 0%, #F2F2F2 100%); }
.color-purple  { background: linear-gradient(180deg, #E3D8FF 0%, #CFC0F7 100%); }
.color-peach   { background: linear-gradient(180deg, #FFE3D1 0%, #F8CDB1 100%); }
.color-lime    { background: linear-gradient(180deg, #EEF8C5 0%, #DAEFA1 100%); }
.color-orange  { background: linear-gradient(180deg, #FFD7B2 0%, #F9B985 100%); }
.color-pink    { background: linear-gradient(180deg, #FFD3E2 0%, #F8B5CB 100%); }
.color-mint    { background: linear-gradient(180deg, #CFEFE4 0%, #ADE2CF 100%); }
.color-sky     { background: linear-gradient(180deg, #CFE5FB 0%, #A5CDF6 100%); }
.icon-fill { font-variation-settings: 'FILL' 1; }

/* Glassmorphic card. Headline component. */
.glass-card {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.10);
    box-shadow: 0 40px 40px -10px rgba(0, 0, 0, 0.40);
    transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.glass-card:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.20);
}
.rim-light { border-top-color: rgba(255, 255, 255, 0.18); }

.glass-pane {
    background: rgba(15, 23, 42, 0.60);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

/* Hide scrollbar chrome but keep scrolling. */
.scroll-pretty::-webkit-scrollbar { width: 8px; height: 8px; }
.scroll-pretty::-webkit-scrollbar-track { background: transparent; }
.scroll-pretty::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.10);
    border-radius: 999px;
}
.scroll-pretty::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.20); }

/* Make hidden default for these popovers regardless of CSS specificity wars. */
.modal-backdrop, .ctx-menu, .upload-tray, .drop-overlay { display: none; }
.modal-backdrop:not([hidden]) { display: flex; }
.ctx-menu:not([hidden])       { display: block; }
.upload-tray:not([hidden])    { display: block; }
.drop-overlay.is-active       { display: flex; }

/* Toast slide-in. */
.toast {
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.18s, transform 0.18s;
}
.toast.toast--in { opacity: 1; transform: translateX(0); }

/* Drop overlay. Dimmed full-screen target while dragging files. */
.drop-overlay {
    position: fixed; inset: 0;
    align-items: center; justify-content: center;
    background: rgba(62,144,255,0.10);
    border: 3px dashed #3e90ff;
    z-index: 50;
    pointer-events: none;
}
.drop-overlay.is-active { pointer-events: auto; }

/* Upload progress fill colour states. */
.upload-row__fill          { background: linear-gradient(90deg, #aac7ff, #3e90ff); }
.upload-row--ok  .upload-row__fill { background: #42e355; }
.upload-row--err .upload-row__fill { background: #ffb4ab; }

/* Sidebar nav active link uses a left rail in primary tone. */
.sidebar-link[data-active="true"] {
    background: rgba(170, 199, 255, 0.08);
    color: #aac7ff;
    border-right: 2px solid #3e90ff;
    font-weight: 700;
}
.sidebar-link[data-active="true"] .material-symbols-outlined {
    font-variation-settings: 'FILL' 1;
    color: #aac7ff;
}

/* Auth pages (login/register) — center the card on the gradient. */
.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

/* ----- Lightbox (photos page) ----- */
.lightbox {
    position: fixed; inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}
.lightbox[hidden] { display: none; }
.lightbox:not([hidden]) {
    display: grid;
    grid-template-rows: 1fr auto;
    place-items: center;
}
.lightbox__stage {
    grid-row: 1;
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    padding: 32px;
}
.lightbox__stage img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.lightbox__caption {
    grid-row: 2;
    color: #c0c6d6;
    font-size: 13px;
    padding: 0 24px 4px;
    max-width: 90vw;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.lightbox__actions {
    grid-row: 2;
    margin-bottom: 18px;
    display: flex; gap: 8px;
    align-self: end;
}
.lightbox__btn {
    position: absolute;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(12px);
    color: #fff;
    border-radius: 999px;
    width: 48px; height: 48px;
    display: grid; place-items: center;
    cursor: pointer;
    transition: background 0.15s;
    z-index: 1;
}
.lightbox__btn:hover { background: rgba(255, 255, 255, 0.16); }
.lightbox__btn--close { top: 16px; right: 16px; }
.lightbox__btn--prev  { top: 50%; left: 16px;  transform: translateY(-50%); }
.lightbox__btn--next  { top: 50%; right: 16px; transform: translateY(-50%); }
