/*
 * theme.css - Shared colour-scheme tokens for every Balata single-page app.
 *
 * There are two schemes:
 *
 *   - Dark  (default): the bare :root block below. A touch lighter than the
 *                      apps' original #17181B so it is easier on the eyes.
 *   - Light (opt-in) : :root[data-theme="light"]. A warm beige, never a
 *                      white background.
 *
 * The scheme is chosen with the toggle button wired up by theme.js and is
 * remembered in localStorage (key "balata-theme", shared by all apps on this
 * origin). A tiny inline script in each app's <head> applies the saved choice
 * before first paint so there is no flash.
 *
 * Every app styles its components through these variables. The names match the
 * ones the apps already used as literals, plus a few additions:
 *
 *   --text-faint   third text level (done items, disabled, placeholders)
 *   --link         anchor colour (only a few apps use <a>)
 *   --ok           "success" green for the sync indicators
 *   --warn         "working offline / changes pending" gold for the sync indicators
 *   --busy         "sending / retrieving data" blue for the sync indicators
 *   --shadow       drop-shadow colour, lighter in the light scheme
 *
 * For hover / pressed tints, prefer  color-mix(in srgb, var(--text) N%, transparent)
 * over a fixed rgba(): because --text flips between near-white and near-black,
 * the same declaration gives a light overlay on dark and a dark overlay on light.
 *
 * Accent and danger are deliberately NOT the same hue in both schemes: on the
 * beige light background the bright green (#16A085) and pink-red (#F14668) drop
 * below a readable contrast when used as text/icons, so the light scheme uses a
 * deeper green and a deeper red.
 */

:root
{
    color-scheme: dark;

    --bg:          #1E1F23;
    --card:        #25272B;
    --card2:       #2F3034;
    --line:        rgba(255, 255, 255, 0.10);

    --text:        #E7E7E9;
    --text-dim:    #93959F;
    --text-faint:  #6B6E77;

    --accent:      #16A085;
    --on-accent:   #0D0F17;
    --danger:      #F14668;

    --link:        #5B9DF9;
    --ok:          #7BA88F;
    --warn:        #E0A21E;
    --busy:        #2179CF;
    --shadow:      rgba(0, 0, 0, 0.35);
}

:root[data-theme="light"]
{
    color-scheme: light;

    --bg:          #D8D0C0;
    --card:        #E0D9CB;
    --card2:       #F2ECDF;
    --line:        #735C2E;

    --text:        #242732;
    --text-dim:    #484C5B;
    --text-faint:  #5E6472;

    --accent:      #0A6151;
    --on-accent:   #F9F9FB;
    --danger:      #8E1F33;

    --link:        #1A4F9E;
    --ok:          #2E6B4E;
    --warn:        #8A5A0B;
    --busy:        #1C5FA6;
    --shadow:      rgba(0, 0, 0, 0.14);
}

/* ---------------------------------------------------------------------------
 * Shared components. Every app pasted its own copy of these; this is the one
 * copy. Layout that varies per app (a margin, a flex context) stays in that
 * app's <style>; only the parts that were byte-identical live here.
 */

/* Header sync dot. Red at rest ("not synced" is the safe starting state); the
 * app toggles .synced / .busy / .offline as the network state changes.
 * (calc / text / write / drive never set .offline - harmless, the rule just
 * never matches.) */
.sync-indicator          { flex: 0 0 auto; display: flex; align-items: center; justify-content: center;
                           color: var(--danger); transition: color 0.15s ease; }
.sync-indicator.synced   { color: var(--ok); }
.sync-indicator.busy     { color: var(--busy); }   /* a GET/PUT is in flight - sending / retrieving data */
.sync-indicator.offline  { color: var(--warn); }   /* working offline / changes queued - safe in the local cache */

/* Bottom-centre transient toast (calendar, contact). The page needs a
 * <div id="toast" class="toast"></div>; add .show to reveal it. contact adds
 * its own .toast.actionable / .toast-undo on top of this. */
.toast                   { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
                           background: var(--card2); color: var(--text); border: 1px solid var(--line);
                           border-radius: 8px; padding: 10px 16px; font-size: 0.9rem; z-index: 200;
                           max-width: 90vw; text-align: center;
                           opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.toast.show              { opacity: 1; }

/* Dialog action row - the one nube style (reference: Calendar -> "Ir a mes").
 * A right-aligned line of round, icon-only buttons. Mark up the buttons with
 * `data-act` and shared/ui.js fills in the class + SVG. Roles: btn-secondary
 * (close, X), btn-primary (apply/save, check), btn-danger (destructive, trash),
 * btn-ghost (tertiary, e.g. help). .sheet-actions-left pins a button (delete)
 * to the far left. */
.sheet-actions           { display: flex; align-items: center; justify-content: flex-end;
                           gap: 8px; margin-top: 18px; }
.sheet-actions-left      { margin-right: auto; }

.btn                     { display: flex; align-items: center; justify-content: center;
                           width: 44px; height: 44px; flex: 0 0 auto;
                           border: none; border-radius: 50%; padding: 0; cursor: pointer;
                           font-family: inherit; background: var(--card2); color: var(--text);
                           transition: filter 0.12s ease, background-color 0.12s ease; }
.btn svg                 { width: 20px; height: 20px; display: block; }
.btn:hover               { filter: brightness(1.13); }        /* background a touch brighter */
.btn:active              { filter: brightness(0.92); }
.btn:disabled            { opacity: 0.5; cursor: not-allowed; filter: none; }

.btn-primary             { background: var(--accent); color: var(--on-accent); border: none; }
.btn-secondary           { background: var(--card2); color: var(--text);
                           border: 1px solid var(--line); }
.btn-danger              { background: transparent; color: var(--danger);
                           border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-danger:hover        { background: color-mix(in srgb, var(--danger) 14%, transparent); }
.btn-ghost               { background: transparent; color: var(--text-dim);
                           border: 1px solid var(--line); }
.btn-ghost:hover         { background: color-mix(in srgb, var(--text) 9%, transparent); color: var(--text); }

/* Top-right corner close - used when a dialog's ONLY action is "close" (a
 * bottom .sheet-actions row is for dialogs that also have an Apply/Save/…).
 * NubeUI.applySheetButtons() moves a lone close button here and pins its
 * position inline. Just the round-button look here; apps that still carry
 * their own .sheet-close in a flex header keep that local copy. */
.sheet-close             { display: flex; align-items: center; justify-content: center;
                           width: 32px; height: 32px; flex: 0 0 auto; padding: 0; z-index: 1;
                           border: none; border-radius: 50%; cursor: pointer;
                           background: transparent; color: var(--text-dim);
                           transition: background-color 0.12s ease, color 0.12s ease; }
.sheet-close svg         { width: 18px; height: 18px; display: block; }
.sheet-close:hover       { background: color-mix(in srgb, var(--text) 9%, transparent); color: var(--text); }
