/* alielmi.com file portal — matches the main site's palette. */

/* Theming is three-state: no [data-theme] means "follow the system", and an
   explicit [data-theme] from the header toggle overrides it in either
   direction. The system rule is therefore fenced off with :not([data-theme=
   "light"]) so a user on a dark machine can still force light. */
:root {
    color-scheme: light;

    --brand-blue-1: #0189f5;
    --brand-blue-2: #045aa8;
    --brand-blue-3: #083f82;
    --brand-cream: #fff9e8;
    --brand-yellow: #ffd84d;

    --bg: #ffffff;
    --bg-subtle: #f4f7fb;
    --text: #14213a;
    --text-muted: #55617d;
    --border: #d8e0ec;
    --accent: #1d4ed8;
    --accent-subtle: #e8effc;
    --danger: #b42318;

    --font-sans: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    --radius: 8px;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;

        --bg: #0d1424;
        --bg-subtle: #131c30;
        --text: #e5ecf8;
        --text-muted: #97a4bd;
        --border: #26324e;
        --accent: #7aa5ff;
        --accent-subtle: #17233d;
        --danger: #ff9c92;
    }
}

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

    --bg: #0d1424;
    --bg-subtle: #131c30;
    --text: #e5ecf8;
    --text-muted: #97a4bd;
    --border: #26324e;
    --accent: #7aa5ff;
    --accent-subtle: #17233d;
    --danger: #ff9c92;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
}

/* ---- top bar ---- */
.bar {
    background: linear-gradient(155deg, var(--brand-blue-1) 0%, var(--brand-blue-2) 52%, var(--brand-blue-3) 100%);
}

.bar-inner {
    max-width: 80%;
    margin: 0 auto;
    padding: 0.85rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    flex-wrap: wrap;
}

.brand {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--brand-cream);
    text-decoration: none;
}

.brand .dot { color: var(--brand-yellow); }

.bar-tag {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255, 253, 242, 0.78);
}

.bar-nav {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
}

.bar-nav a { color: var(--brand-cream); text-decoration: none; }
.bar-nav a:hover { text-decoration: underline; }
.who { color: rgba(255, 253, 242, 0.8); }

/* ---- language switch ---- */
.lang-switch {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    font-size: 0.82rem;
}

.lang-opt {
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius);
    color: rgba(255, 253, 242, 0.75);
    text-decoration: none;
    white-space: nowrap;
}

.lang-opt:hover {
    background: rgba(255, 253, 242, 0.16);
    color: var(--brand-cream);
    text-decoration: none;
}

/* The current language reads as a label, not something else to click. */
.lang-opt.is-active {
    color: var(--brand-cream);
    background: rgba(255, 253, 242, 0.18);
    font-weight: 650;
}

.lang-opt:focus-visible {
    outline: 2px solid var(--brand-yellow);
    outline-offset: 2px;
}

/* ---- service switcher ---- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.switcher { position: relative; }

/* The trigger is a <summary>. `display: grid` plus list-style removes the
   default disclosure triangle in every engine. */
.switcher-btn {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    list-style: none;
    border: 1px solid rgba(255, 253, 242, 0.28);
    border-radius: var(--radius);
    background: rgba(255, 253, 242, 0.1);
    color: var(--brand-cream);
    cursor: pointer;
}

.switcher-btn::-webkit-details-marker { display: none; }
.switcher-btn::marker { content: ''; }

.switcher-btn:hover { background: rgba(255, 253, 242, 0.2); }

.switcher-btn:focus-visible,
.switcher-item:focus-visible {
    outline: 2px solid var(--brand-yellow);
    outline-offset: 2px;
}

.app-icon { width: 19px; height: 19px; }

.switcher-menu {
    position: absolute;
    top: calc(100% + 0.55rem);
    left: 0;
    z-index: 40;
    width: min(20rem, calc(100vw - 2.5rem));
    padding: 0.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 12px 32px rgba(8, 24, 56, 0.22);
}

/* Browsers hide closed <details> content with content-visibility, which still
   paints this panel's own background and border. Take it out of flow instead. */
.switcher:not([open]) .switcher-menu { display: none; }

.switcher-heading {
    margin: 0.25rem 0.5rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.switcher-item {
    display: flex;
    gap: 0.7rem;
    align-items: flex-start;
    padding: 0.6rem;
    border-radius: var(--radius);
    color: var(--text);
    text-decoration: none;
}

.switcher-item:hover { background: var(--bg-subtle); }
.switcher-item.is-current { background: var(--accent-subtle); }

.switcher-item-icon {
    display: grid;
    place-items: center;
    flex: none;
    width: 34px;
    height: 34px;
    border-radius: var(--radius);
    background: var(--accent-subtle);
    color: var(--accent);
}

.switcher-item-text { display: flex; flex-direction: column; }
.switcher-item-name { font-weight: 600; line-height: 1.3; }

.switcher-item-blurb {
    font-size: 0.82rem;
    line-height: 1.35;
    color: var(--text-muted);
}

/* ---- account menu ---- */
/* Same <details> machinery as the service switcher, and deliberately the same
   visual language, so the two menus read as siblings. */
.account { position: relative; }

.account-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    height: 34px;
    padding: 0 0.6rem;
    max-width: 14rem;
    list-style: none;
    border: 1px solid rgba(255, 253, 242, 0.28);
    border-radius: var(--radius);
    background: rgba(255, 253, 242, 0.1);
    color: var(--brand-cream);
    font-size: 0.9rem;
    cursor: pointer;
}

.account-btn::-webkit-details-marker { display: none; }
.account-btn::marker { content: ''; }

.account-btn:hover { background: rgba(255, 253, 242, 0.2); }

.account-btn:focus-visible {
    outline: 2px solid var(--brand-yellow);
    outline-offset: 2px;
}

/* A long display name must not push the chevron off the bar. */
.account-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-chevron {
    flex: none;
    width: 14px;
    height: 14px;
    transition: transform 0.15s ease;
}

.account[open] .account-chevron { transform: rotate(180deg); }

/* Anchored to the right because this sits at the end of the bar; left-aligning
   it would hang off the edge of the viewport. */
.account-menu {
    position: absolute;
    top: calc(100% + 0.55rem);
    right: 0;
    left: auto;
    z-index: 40;
    width: min(14rem, calc(100vw - 2.5rem));
    padding: 0.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 12px 32px rgba(8, 24, 56, 0.22);
}

/* Same reason as the switcher: a closed <details> still paints this panel's
   own background and border, so it has to leave the flow entirely. */
.account:not([open]) .account-menu { display: none; }

.account-item { padding: 0.45rem 0.6rem; }

/* `.bar-nav a` paints links cream for the blue bar, which would be invisible
   on the menu's own background — win it back for anything inside the panel. */
.bar-nav .switcher-item { color: var(--text); }
.bar-nav .switcher-item:hover { text-decoration: none; }

/* ---- theme toggle ---- */
.theme-btn {
    display: grid;
    place-items: center;
    flex: none;
    width: 34px;
    height: 34px;
    /* cancel the global `button { margin-top: 1.25rem }`, which would otherwise
       drop this out of line with the rest of the bar */
    margin: 0;
    padding: 0;
    border: 1px solid rgba(255, 253, 242, 0.28);
    border-radius: var(--radius);
    background: rgba(255, 253, 242, 0.1);
    color: var(--brand-cream);
    cursor: pointer;
}

.theme-btn:hover { background: rgba(255, 253, 242, 0.2); }

.theme-btn:focus-visible {
    outline: 2px solid var(--brand-yellow);
    outline-offset: 2px;
}

/* Show the icon for the theme you would switch *to*: a moon while light, a sun
   while dark. Driven by the same three-state selectors as the palette so the
   icon can never disagree with the colours on screen. */
.theme-btn .icon-sun { display: none; }
.theme-btn .icon-moon { display: block; }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-btn .icon-sun { display: block; }
    :root:not([data-theme="light"]) .theme-btn .icon-moon { display: none; }
}

:root[data-theme="dark"] .theme-btn .icon-sun { display: block; }
:root[data-theme="dark"] .theme-btn .icon-moon { display: none; }

/* ---- layout ---- */
main {
    max-width: 80%;
    margin: 0 auto;
    padding: 1.75rem 1.25rem 3rem;
}

.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    background: var(--bg);
}

.card-narrow { max-width: 420px; margin-left: auto; margin-right: auto; }

h1 { font-size: 1.5rem; margin: 0 0 0.75rem; }
h2 { font-size: 1.15rem; margin: 0 0 1rem; }
.muted { color: var(--text-muted); font-size: 0.9rem; }
.req { color: var(--danger); }

/* ---- forms ---- */
label {
    display: block;
    margin: 1rem 0 0.3rem;
    font-size: 0.9rem;
    font-weight: 600;
}

input[type=text],
input[type=search],
input[type=password],
input[type=email],
input[type=file],
textarea {
    width: 100%;
    padding: 0.55rem 0.7rem;
    font: inherit;
    font-size: 0.95rem;
    color: var(--text);
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: 6px;
}

textarea { resize: vertical; }

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 1rem 0 0.3rem;
    font-weight: 400;
    font-size: 0.9rem;
}

.checkbox-row input[type=checkbox] {
    width: auto;
    margin: 0;
}

.public-link {
    margin-top: 0.4rem;
    display: flex;
    align-items: stretch;
    gap: 0.4rem;
    max-width: 420px;
}

.public-link input[type=text] {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.35rem 0.55rem;
    font-size: 0.78rem;
    line-height: 1.6;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: var(--accent);
    background: var(--accent-subtle);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
}

.copy-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    /* cancel the global `button { margin-top: 1.25rem }`, which otherwise
       pushes this button below the link box */
    margin: 0;
    /* padding/border/font must match .public-link input so the two line up */
    padding: 0.35rem 0.6rem;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.6;
    color: var(--accent);
    background: var(--accent-subtle);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

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

.copy-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.copy-btn.copied,
.copy-btn.copied:hover {
    color: var(--accent);
    background: var(--accent-subtle);
    border-color: var(--accent);
}

/* Icon swap is driven purely by the .copied class — SVG elements don't
   reliably honour the `hidden` attribute the way HTML elements do. */
.copy-btn .icon-check { display: none; }
.copy-btn.copied .icon-check { display: inline-block; }
.copy-btn.copied .icon-copy { display: none; }

@media (max-width: 640px) {
    .copy-btn .copy-label { display: none; }
}

.badge {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0.1rem 0.5rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--accent);
    background: var(--accent-subtle);
    border-radius: 999px;
}

/* ---- upload dropzone ---- */
.dropzone {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 1.75rem 1rem;
    font-weight: 400;
    text-align: center;
    cursor: pointer;
    background: var(--bg-subtle);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.dropzone:hover,
.dropzone.dragover {
    background: var(--accent-subtle);
    border-color: var(--accent);
}

.dropzone input[type=file] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.dropzone-text {
    font-size: 0.9rem;
    color: var(--text-muted);
}

button {
    margin-top: 1.25rem;
    padding: 0.55rem 1.15rem;
    font: inherit;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

button:hover { filter: brightness(1.08); }

/* ---- search ---- */
.search { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 1.25rem; }
.search input { margin: 0; }
.search button { margin: 0; white-space: nowrap; }
.search .clear { font-size: 0.9rem; color: var(--text-muted); }

/* ---- table ---- */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }

th, td {
    text-align: left;
    padding: 0.65rem 0.7rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

th { background: var(--bg-subtle); font-weight: 650; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.filename, .desc { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.15rem; }

.desc-clamp {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    cursor: pointer;
}
.desc-clamp.is-expanded {
    display: block;
    -webkit-line-clamp: unset;
}
.desc-toggle {
    display: inline-block;
    margin-top: 0.1rem;
    font-size: 0.78rem;
    color: var(--accent);
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
}

.actions { display: flex; flex-direction: column; gap: 0.35rem; align-items: stretch; min-width: 92px; }
.actions .btn { text-align: center; }
.inline { display: inline; }
.inline .btn { width: 100%; }

.inline-email { display: flex; gap: 0.4rem; align-items: center; }
.inline-email input[type=email] {
    width: auto;
    min-width: 180px;
    padding: 0.3rem 0.5rem;
    font-size: 0.85rem;
}
.inline-email .btn { flex: none; }

.btn {
    display: inline-block;
    margin: 0;
    padding: 0.35rem 0.7rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border: none;
    border-radius: 6px;
    text-decoration: none;
    cursor: pointer;
}

.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-secondary { background: var(--bg-subtle); color: var(--text); border: 1px solid var(--border); }

/* ---- modal ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(10, 15, 28, 0.55);
    z-index: 100;
}

.modal-overlay[hidden] { display: none; }

.modal-box {
    width: 100%;
    max-width: 420px;
    padding: 1.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.modal-message { margin: 0 0 1.25rem; font-size: 0.98rem; line-height: 1.5; }

.modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
}

.modal-actions .btn { padding: 0.5rem 1rem; font-size: 0.9rem; }

/* ---- upload progress ---- */
#uploadCancelBtn { margin-left: 0.6rem; }

.upload-progress-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 1rem;
}

.progress-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
    height: 1.4rem;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0;
    background: var(--accent);
    transition: width 0.15s ease;
}

.progress-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
}

.progress-cancel-btn {
    flex: none;
    width: 1.6rem;
    height: 1.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    font-size: 1.1rem;
    line-height: 1;
    font-weight: 700;
    color: var(--danger);
    background: transparent;
    border: 1px solid var(--danger);
    border-radius: 50%;
    cursor: pointer;
}

.progress-cancel-btn:hover { background: var(--danger); color: #fff; }

/* ---- flash ---- */
.flash {
    padding: 0.7rem 0.9rem;
    border-radius: 6px;
    font-size: 0.92rem;
    margin: 0 0 1rem;
}

.flash-success { background: #e7f6ec; color: #14532d; }
.flash-error   { background: #fdeceb; color: #7f1d1d; }
.flash-notice  { background: var(--accent-subtle); color: var(--accent); }

/* The flash colours are literals rather than variables, so they need the same
   three-state treatment as the palette above. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .flash-success { background: #10301c; color: #a7e8bd; }
    :root:not([data-theme="light"]) .flash-error   { background: #3a1614; color: #ffb4ab; }
}

:root[data-theme="dark"] .flash-success { background: #10301c; color: #a7e8bd; }
:root[data-theme="dark"] .flash-error   { background: #3a1614; color: #ffb4ab; }

/* ---- footer ---- */
.foot {
    max-width: 80%;
    margin: 0 auto;
    padding: 1rem 1.25rem 3rem;
    font-size: 0.9rem;
}

.foot a { color: var(--accent); }

@media (max-width: 640px) {
    /* The bar wraps, so the nav drops onto its own row. Keep it hard against
       the right so the account panel — which is right-anchored — still opens
       inside the viewport, and let the name shrink before anything overflows. */
    .bar-nav {
        width: 100%;
        margin-left: 0;
        justify-content: flex-end;
        gap: 0.6rem;
    }

    .account-btn { max-width: calc(100vw - 7rem); }
}

/* Any element using [hidden] must actually disappear, regardless of what
   display value its own class sets (inline-block on .btn, flex on rows,
   etc.) — those otherwise win over the UA stylesheet's [hidden] rule by
   specificity/source order. One global override instead of chasing this
   per-selector every time a new hidden-toggled element is added. */
[hidden] { display: none !important; }
