/* iCube Development Secure File Sharing */

:root {
    --brand: #007bff;
    --brand-dark: #0056b3;
    --ink: #222;
    --text: #444;
    --muted: #6b6b6b;
    --faint: #8a8a8a;
    --line: #e4e4e4;
    --soft: #fafafa;
    --ok: #1f7a3a;
    --danger: #a12626;
    --ring: rgba(0, 123, 255, 0.15);
    --radius: 8px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body.icube-body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font: 14px/1.5 'Roboto', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
    color: var(--text);
    background: #dfe6ee url('bg.webp') center / cover no-repeat fixed;
}

/* TOP BAR: logo left, account links right, over the background */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px 24px;
    padding: 22px 6vw;
}

.logo-link {
    display: inline-block;
    line-height: 0;
}

.logo {
    height: 44px;
    width: auto;
}

.topnav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px;
    font-size: 13px;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 999px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.topnav a,
.topnav-btn,
.topnav-user {
    padding: 6px 12px;
    border-radius: 999px;
    color: var(--ink);
    text-decoration: none;
}

.topnav-user {
    font-weight: 700;
}

.topnav-btn {
    border: 0;
    background: none;
    font: inherit;
    cursor: pointer;
}

.topnav a:hover,
.topnav-btn:hover {
    background: #eef3fa;
    color: var(--brand);
}

/* THE CARD: floats on the left over the background */

.icube-main {
    position: relative;
    width: 400px;
    max-width: calc(100% - 24px);
    margin: 4vh 0 32px 6vw;
    padding: 26px 26px 24px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(20, 40, 70, 0.18);
}

/* Terms of Service: a card wide enough for comfortable reading */
.icube-main.reading-page {
    width: 780px;
}

.terms {
    font-size: 14px;
    line-height: 1.65;
    color: var(--text);
}

.terms h2 {
    margin: 26px 0 6px;
    font-size: 16px;
    color: var(--ink);
}

.terms p,
.terms ul {
    margin: 0 0 10px;
}

.terms ul {
    padding-left: 20px;
}

.terms li {
    margin-bottom: 4px;
}

.terms address {
    font-style: normal;
}

.terms a {
    color: var(--brand);
}

.upload-terms {
    margin: 10px 0 0;
    text-align: center;
    font-size: 12px;
    color: var(--faint);
}

.upload-terms a {
    color: var(--muted);
}

/* Site notice card, under the main card */
.news-card {
    width: 400px;
    max-width: calc(100% - 24px);
    margin: -14px 0 32px 6vw;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.94);
    border-radius: 12px;
    box-shadow: 0 8px 26px rgba(20, 40, 70, 0.12);
}

.news-title {
    margin: 0 0 4px;
    font-size: 15px;
    color: var(--ink);
}

.news-text {
    margin: 0;
    font-size: 13px;
    line-height: 1.55;
    color: var(--text);
}

.news-text a {
    color: var(--brand);
    overflow-wrap: anywhere;
}

.news-help {
    margin: -6px 0 12px;
}

textarea.form-input {
    resize: vertical;
    min-height: 90px;
    font: inherit;
}

/* Admin: a wider card, centered */
.icube-main.wide-page {
    width: 1040px;
    margin: 2vh auto 32px;
}

.intro {
    margin-bottom: 14px;
}

.page-title {
    margin: 0 0 4px;
    font-size: 22px;
    line-height: 1.2;
    color: var(--ink);
}

.page-subtitle {
    margin: 0;
    color: var(--muted);
}

/* Content blocks inside the card are plain (the card is the box) */
.upload-box {
    margin-top: 14px;
}

.wide-page .upload-box + .upload-box {
    margin-top: 22px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

.section-title {
    margin: 0 0 12px;
    font-size: 16px;
    color: var(--ink);
}

.message {
    margin: 0;
}

.icube-footer {
    margin-top: auto;
    padding: 24px 6vw 96px;   /* lifted so it clears the blue bar in the background on common screens */
    font-size: 12px;
    color: var(--muted);
    line-height: 1.5;
}

.footer-text {
    display: inline-block;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 6px;
}

.icube-footer a,
.auth-footnote a,
.auth-links a {
    color: var(--brand);
}

/* BUTTONS */

.btn {
    display: inline-block;
    padding: 11px 16px;
    border: 0;
    border-radius: 8px;
    font: inherit;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

.btn-primary {
    width: 100%;
    color: #fff;
    background: var(--brand);
}

.btn-primary:hover {
    background: var(--brand-dark);
}

.btn-large {
    padding: 14px 16px;
    font-size: 15px;
    border-radius: 999px;
}

.btn-small {
    width: auto;
    padding: 7px 14px;
    font-size: 13px;
}

.btn-link {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    font-size: 13px;
    color: var(--brand);
    text-decoration: underline;
    cursor: pointer;
}

.btn-link-danger {
    color: var(--danger);
}

.btn:focus-visible,
.btn-link:focus-visible,
.file-remove-btn:focus-visible,
.password-toggle-btn:focus-visible,
.logo-link:focus-visible,
.option-check input:focus-visible,
#fileInput:focus-visible + .add-first {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

/* FORMS */

.auth-form {
    margin-top: 4px;
}

.form-group {
    margin-bottom: 14px;
}

.form-label {
    display: block;
    margin-bottom: 5px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
}

.form-hint {
    font-size: 12px;
    color: var(--muted);
}

.form-hint-inline {
    font-weight: 400;
    color: var(--faint);
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d3d9e0;
    border-radius: 8px;
    font: inherit;
    color: var(--ink);
    background: #fff;
}

.form-input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--ring);
}

.form-error {
    margin: 0 0 12px;
    font-size: 13px;
    color: var(--danger);
}

.upload-box > .form-error:last-child {
    margin: 12px 0 0;
}

.notice {
    margin: 0 0 12px;
    padding: 10px 12px;
    font-size: 13px;
    border-radius: 6px;
}

.notice-success {
    color: var(--ok);
    background: #f0faf2;
    border: 1px solid #cbe9d2;
}


.password-field-wrap {
    position: relative;
}

.password-field-wrap .form-input {
    padding-right: 56px;
}

.password-toggle-btn {
    position: absolute;
    top: 50%;
    right: 4px;
    transform: translateY(-50%);
    padding: 6px 8px;
    border: 0;
    background: none;
    font-size: 12px;
    font-weight: 700;
    color: var(--brand);
    cursor: pointer;
}

.code-input {
    font-size: 22px;
    letter-spacing: 0.3em;
    text-align: center;
}

.btn-link:disabled {
    color: var(--faint);
    text-decoration: none;
    cursor: default;
}

/* UPLOAD PAGE */

/* Before any files: one big "add" target */
.add-first {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 28px 10px 24px;
    text-align: center;
    border-radius: 12px;
    cursor: pointer;
}

.add-first:hover .add-circle {
    background: var(--brand-dark);
    transform: scale(1.05);
}

.add-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    margin-bottom: 10px;
    font-size: 40px;
    font-weight: 300;
    line-height: 1;
    color: #fff;
    background: var(--brand);
    border-radius: 50%;
    box-shadow: 0 6px 18px rgba(0, 123, 255, 0.35);
    transition: transform 0.15s, background 0.15s;
}

.add-circle-small {
    width: 28px;
    height: 28px;
    margin: 0;
    font-size: 20px;
    box-shadow: none;
}

.add-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--ink);
}

.add-hint {
    color: var(--muted);
}

.add-limit {
    margin-top: 6px;
    font-size: 12px;
    color: var(--faint);
}

/* After files are chosen */
.chosen-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

.add-more {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    color: var(--ink);
    cursor: pointer;
}

.add-more:hover {
    color: var(--brand);
}

.chosen-summary {
    font-size: 12px;
    color: var(--muted);
}

.file-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.file-list-scroll {
    max-height: 210px;
    overflow-y: auto;
}

.file-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid #f0f0f0;
}

.file-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--ink);
}

.file-size {
    flex: none;
    font-size: 12px;
    color: var(--faint);
    white-space: nowrap;
}

.file-remove-btn {
    flex: none;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    font-size: 18px;
    line-height: 1;
    color: var(--faint);
    cursor: pointer;
}

.file-remove-btn:hover {
    color: var(--danger);
    background: #fbe7e7;
}

/* Native checkbox rows: consistent alignment and spacing across all forms.
   Do not apply to the upload-option toggle switches. */
.option-check {
    display: grid;
    grid-template-columns: 16px minmax(0, 1fr);
    align-items: start;
    column-gap: 10px;
    margin: 0;
    width: 100%;
    min-height: 24px;
    font-size: 13px;
    line-height: 20px;
    color: var(--text);
    cursor: pointer;
}

.option-check input[type="checkbox"] {
    appearance: auto;
    display: block;
    width: 16px;
    height: 16px;
    min-width: 16px;
    margin: 2px 0 0;
    padding: 0;
    accent-color: var(--brand);
    cursor: pointer;
}

.option-check span {
    display: block;
    min-width: 0;
    overflow-wrap: anywhere;
}

.option-check a { color: var(--brand); }

/* Space checkboxes like other form fields, regardless of form layout. */
.checkbox-field { margin: 0 0 14px; }
.checkbox-field .option-check { margin: 0; }

/* Options with on/off switches */
.option-list {
    margin: 6px 0 18px;
}

.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
    color: var(--ink);
    cursor: pointer;
}

.switch {
    appearance: none;
    flex: none;
    position: relative;
    width: 40px;
    height: 22px;
    margin: 0;
    background: #cfd6de;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s;
}

.switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: transform 0.15s;
}

.switch:checked {
    background: var(--brand);
}

.switch:checked::after {
    transform: translateX(18px);
}

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

.option-body {
    padding: 10px 0 12px;
    border-bottom: 1px solid #f0f0f0;
}

.option-body .form-hint {
    margin-top: 6px;
}

.option-note {
    padding-top: 12px;
    font-size: 12px;
    color: var(--muted);
}

/* Uploading and done states */
.state-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 8px 0 4px;
}

.ring {
    position: relative;
    width: 170px;
    height: 170px;
    margin-bottom: 14px;
}

.ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.ring-track,
.ring-bar {
    fill: none;
    stroke-width: 9;
}

.ring-track {
    stroke: #e8edf3;
}

.ring-bar {
    stroke: var(--brand);
    stroke-linecap: round;
    stroke-dasharray: 326.73;   /* 2 * pi * 52 */
    stroke-dashoffset: 326.73;
    transition: stroke-dashoffset 0.3s;
}

.ring-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    font-weight: 700;
    color: var(--ink);
}

.state-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--ink);
}

.state-text {
    margin: 4px 0 16px;
    color: var(--muted);
    white-space: pre-line;
}

.done-circle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 76px;
    height: 76px;
    margin: 8px 0 14px;
    background: #22a55a;
    border-radius: 50%;
    box-shadow: 0 6px 18px rgba(34, 165, 90, 0.35);
}

.done-circle svg {
    width: 40px;
    height: 40px;
    fill: none;
    stroke: #fff;
    stroke-width: 2.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.result-link {
    margin-bottom: 10px;
    text-align: center;
}

.result-info {
    margin-top: 10px;
}

#result .btn-link {
    margin-top: 14px;
}

.card-error {
    margin: 14px 0 0;
}

/* Full-window overlay while dragging files over the page */
.drop-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 86, 179, 0.82);
    pointer-events: none;
}

.drop-overlay-inner {
    padding: 40px 60px;
    font-size: 26px;
    font-weight: 700;
    color: #fff;
    border: 3px dashed rgba(255, 255, 255, 0.8);
    border-radius: 18px;
}

/* Download page list */
.upload-box > .file-list .file-list-item {
    padding: 11px 0;
}

.upload-box > .file-list .file-name {
    white-space: normal;
    overflow-wrap: anywhere;
}

/* ACCOUNTS */

.inline-form {
    display: inline;
    margin: 0;
}

.auth-footnote {
    margin: 14px 0 0;
    text-align: center;
}

.auth-links {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    font-size: 13px;
}

/* ADMIN */

.admin-create-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 14px;
}

.admin-create-form .form-group:nth-of-type(3),
.admin-create-form .checkbox-field,
.admin-submit {
    grid-column: 1 / -1;
}

.admin-submit {
    margin-top: 12px;
}

.secret-box {
    margin-bottom: 4px;
    padding: 12px 14px;
    font-size: 13px;
    line-height: 1.6;
    background: #fffbea;
    border: 1px solid #f1e2a4;
    border-radius: 6px;
}

.secret-box code {
    font: 700 14px ui-monospace, Consolas, monospace;
    color: var(--ink);
    user-select: all;
}

.result-label {
    display: block;
    margin-bottom: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.table-scroll {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.admin-table th {
    padding: 0 8px 6px 0;
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    border-bottom: 1px solid var(--line);
}

.admin-table th,
.admin-table td {
    white-space: nowrap; /* never break emails or dates; .table-scroll scrolls instead */
}

.admin-table td {
    padding: 9px 12px 9px 0;
    border-bottom: 1px solid #eee;
}

.admin-table tr:last-child td {
    border-bottom: 0;
}

.cell-actions {
    text-align: right;
    white-space: nowrap;
}

.cell-actions .btn-link {
    margin-left: 8px;
    font-size: 12px;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    border-radius: 999px;
}

.badge-on   { color: var(--ok);  background: #e6f6ea; }
.badge-warn { color: #7a5600;    background: #fff4d6; }
.badge-off  { color: var(--muted); background: #eee; }

.nowrap {
    white-space: nowrap;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* SMALL SCREENS: card centered, full width */

@media (max-width: 720px) {
    body.icube-body {
        background-attachment: scroll; /* iOS ignores fixed backgrounds */
    }

    .topbar {
        padding: 16px;
    }

    .logo {
        height: 34px;
    }

    .icube-main,
    .icube-main.wide-page {
        width: auto;
        margin: 8px 12px 24px;
        padding: 22px 18px;
    }

    .admin-create-form {
        grid-template-columns: 1fr;
    }

    .icube-footer {
        padding: 20px 16px 72px;
    }

    .news-card {
        width: auto;
        margin: -10px 12px 24px;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}

/* Account settings and email template editor */
.settings-divider { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }
.email-template-editor textarea { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .9rem; line-height: 1.5; }
.email-editor-actions { display: flex; gap: .7rem; flex-wrap: wrap; align-items: center; }
.email-editor-status { font-size: .875rem; font-weight: 600; color: var(--muted); }
.email-template-preview { margin-top: 1.3rem; padding: 1rem; border: 1px solid var(--line); border-radius: .5rem; }
.email-template-title { margin: 0 0 1rem; font-size: 1.05rem; }
.email-template-preview pre { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; margin: .7rem 0 0; }
.email-template-preview p { overflow-wrap: anywhere; }
@media (max-width: 520px) { .email-editor-actions .btn { flex: 1 1 auto; } }
.email-editor-actions .btn-primary { width: auto; }
.email-editor-actions .btn-secondary { color: var(--text, #202a35); background: transparent; border: 1px solid var(--line); }
.email-editor-actions .btn-secondary:hover { background: rgba(127,127,127,.1); }

/* Compact administration layout */
.admin-nav { display:flex; flex-wrap:wrap; gap:8px; margin:0 0 20px; border-bottom:1px solid var(--line); padding-bottom:10px; }
.admin-nav-link { padding:9px 13px; border-radius:7px; color:var(--muted); text-decoration:none; font-weight:600; }
.admin-nav-link:hover,.admin-nav-link:focus-visible { background:#f0f5fa; color:#123c65; }
.admin-nav-link.active { background:#e5f0fa; color:#075b98; }
.admin-metrics { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px; margin:0 0 16px; }
.admin-metric { padding:16px; background:#f5f8fb; border:1px solid var(--line); border-radius:9px; min-width:0; }
.admin-metric span { display:block; font-size:12px; color:var(--muted); }
.admin-metric strong { display:block; font-size:22px; margin-top:6px; overflow-wrap:anywhere; }
.admin-disk-info { display:flex; justify-content:space-between; gap:12px; flex-wrap:wrap; font-size:14px; }
.admin-progress { width:100%; height:14px; margin-top:12px; accent-color:#1776ad; }
.admin-status-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; }
.admin-status-grid p { margin:6px 0 0; color:var(--muted); font-size:13px; }
.admin-new-account summary { cursor:pointer; }
.admin-new-account form { margin-top:15px; }
.admin-filter { max-width:370px; margin:8px 0 15px; }
.admin-table tr[hidden] { display:none; }
@media(max-width:720px) { .admin-metrics { grid-template-columns:repeat(2,minmax(0,1fr)); } .admin-status-grid { grid-template-columns:1fr; } .admin-nav-link { flex:1 0 auto; text-align:center; } }

/* Maintenance view shares the standard card sizing but is centered. */
.icube-main.maintenance-page { margin: 8vh auto 32px; }
