/* ============================================
   FileShare — CSS
   ============================================ */

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

:root {
    --c-bg: #f5f5f7;
    --c-surface: #fff;
    --c-text: #1d1d1f;
    --c-text2: #6e6e73;
    --c-primary: #0071e3;
    --c-primary-hover: #0062cc;
    --c-danger: #e34040;
    --c-success: #30b566;
    --c-warn: #f5a623;
    --c-border: #d2d2d7;
    --radius: 10px;
    --shadow: 0 1px 4px rgba(0,0,0,.08);
}

html { font-size: 15px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--c-bg);
    color: var(--c-text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 1rem; }

/* --- Header --- */
.header {
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    padding: .75rem 0;
    position: sticky; top: 0; z-index: 100;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem; }
.logo { font-weight: 700; font-size: 1.2rem; color: var(--c-text); }
.logo:hover { text-decoration: none; }
.nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.nav a { font-size: .9rem; }
.nav-email { font-size: .8rem; color: var(--c-text2); }
.inline-form { display: inline; }

/* Hamburger button */
.hamburger {
    display: none; background: none; border: none; cursor: pointer;
    width: 36px; height: 36px; padding: 6px;
    flex-direction: column; justify-content: center; gap: 5px;
}
.hamburger span {
    display: block; height: 2px; background: var(--c-text);
    border-radius: 2px; transition: all .2s;
}
.hamburger.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 640px) {
    .hamburger { display: flex; }
    .nav {
        display: none; flex-direction: column; align-items: stretch;
        width: 100%; gap: 0; padding-top: .5rem;
    }
    .nav.open { display: flex; }
    .nav a {
        padding: .6rem 0; border-top: 1px solid var(--c-border);
        font-size: .9rem;
    }
    .nav .nav-email {
        padding: .6rem 0; border-top: 1px solid var(--c-border);
    }
    .nav .inline-form {
        padding: .6rem 0; border-top: 1px solid var(--c-border);
        display: block;
    }
    .main { padding: 1rem .75rem; }
}

/* --- Footer --- */
.footer { margin-top: auto; padding: 1.5rem 0; text-align: center; font-size: .8rem; color: var(--c-text2); }

/* --- Main --- */
.main { padding: 2rem 1rem; flex: 1; }

/* --- Card --- */
.card {
    background: var(--c-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    overflow-x: auto;
    max-width: 100%;
}
@media (max-width: 640px) {
    .card { padding: 1rem .75rem; }
}
.card h2 { margin-bottom: 1rem; font-size: 1.3rem; }

/* --- Button --- */
.btn {
    display: inline-block; padding: .55rem 1.2rem;
    border-radius: 8px; border: none; cursor: pointer;
    font-size: .9rem; font-weight: 600;
    text-align: center; transition: background .15s;
}
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-hover); text-decoration: none; }
.btn-danger { background: var(--c-danger); color: #fff; }
.btn-success { background: var(--c-success); color: #fff; }
.btn-warn { background: var(--c-warn); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--c-border); color: var(--c-text); }
.btn-outline:hover { background: var(--c-bg); text-decoration: none; }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; }

/* --- Form --- */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: .3rem; font-size: .9rem; }
.form-control {
    width: 100%; padding: .55rem .75rem;
    border: 1px solid var(--c-border); border-radius: 8px;
    font-size: .9rem; background: var(--c-surface);
}
.form-control:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(0,113,227,.15); }
select.form-control { appearance: auto; }

/* --- Alert --- */
.alert {
    padding: .75rem 1rem; border-radius: 8px; word-break: break-all;
    margin-bottom: 1rem; font-size: .9rem;
}
.alert-success { background: #e8f5e9; color: #2e7d32; }
.alert-error { background: #fdecea; color: #c62828; }
.alert-warn { background: #fff8e1; color: #e65100; border: 1px solid #ffe0b2; }

/* --- Table --- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .6rem .75rem; text-align: left; border-bottom: 1px solid var(--c-border); }
th { font-weight: 600; background: var(--c-bg); }
tr:hover { background: #fafafa; }

/* --- Badge --- */
.badge {
    display: inline-block; padding: .15rem .55rem;
    border-radius: 20px; font-size: .75rem; font-weight: 600;
}
.badge-pending  { background: #fff3e0; color: #e65100; }
.badge-approved { background: #e8f5e9; color: #2e7d32; }
.badge-suspended { background: #fdecea; color: #c62828; }
.badge-clean    { background: #e8f5e9; color: #2e7d32; }
.badge-rejected { background: #fdecea; color: #c62828; }
.badge-active   { background: #e3f2fd; color: #1565c0; }
.badge-revoked  { background: #f3e5f5; color: #7b1fa2; }
.badge-expired  { background: #eceff1; color: #546e7a; }

/* --- Upload UI --- */
.dropzone {
    border: 2px dashed var(--c-border); border-radius: var(--radius);
    padding: 3rem 1rem; text-align: center; cursor: pointer;
    transition: border-color .2s, background .2s;
}
.dropzone.dragover { border-color: var(--c-primary); background: rgba(0,113,227,.04); }
.dropzone p { color: var(--c-text2); font-size: .95rem; }

.file-queue { margin-top: 1.5rem; }
.file-item {
    display: flex; align-items: center; gap: .5rem;
    padding: .75rem; background: var(--c-bg); border-radius: 8px;
    margin-bottom: .5rem; flex-wrap: wrap; min-width: 0;
}
.file-item .name { flex: 1 1 0; min-width: 0; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .size { font-size: .8rem; color: var(--c-text2); flex-shrink: 0; text-align: right; }
.file-item .progress-bar {
    width: 100px; flex-shrink: 0; height: 6px; background: var(--c-border); border-radius: 3px; overflow: hidden;
}
.file-item .progress-bar .fill { height: 100%; background: var(--c-primary); transition: width .2s; }
.file-item .status { font-size: .8rem; flex-shrink: 0; text-align: right; }
.file-item .status.done { color: var(--c-success); }
.file-item .status.error { color: var(--c-danger); }

@media (max-width: 600px) {
    .file-item { gap: .4rem; padding: .5rem; }
    .file-item .name { flex-basis: 100%; font-size: .8rem; }
    .file-item .size { font-size: .7rem; }
    .file-item .progress-bar { flex: 1 1 auto; width: auto; min-width: 60px; }
    .file-item .status { font-size: .75rem; }
}

/* --- Viewer --- */
.viewer-page {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #0a0a0a; color: #f0f0f0; min-height: 100vh;
}
.viewer-header {
    padding: 1rem 1.5rem; border-bottom: 1px solid #333;
    display: flex; align-items: center; justify-content: space-between;
}
.viewer-header h1 { font-size: 1.1rem; font-weight: 600; }
.viewer-body { padding: 1.5rem; }

.viewer-warn {
    background: #3d2c00; border: 1px solid #e6a817;
    padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1.5rem;
    font-size: .9rem; color: #ffd54f;
}

/* Section title (viewer) */
.section-title { margin: 1.5rem 0 1rem; font-size: .95rem; }

/* Select toolbar */
.select-toolbar {
    display: flex; align-items: center; gap: 1rem;
    padding: .6rem 1rem; background: #1a1a1a; border-radius: 8px;
    margin-bottom: 1rem; position: sticky; top: 0; z-index: 50;
}
.select-all-label {
    display: flex; align-items: center; gap: .5rem;
    font-size: .85rem; color: #ccc; cursor: pointer;
}
.select-all-label input[type="checkbox"] {
    width: 18px; height: 18px; accent-color: var(--c-primary);
    font-size: 16px;
}
.select-count { font-size: .8rem; color: var(--c-primary); }

/* Circle check (common) */
.circle-check {
    display: block; width: 24px; height: 24px; border-radius: 50%;
    border: 2px solid rgba(255,255,255,.6); background: rgba(0,0,0,.3);
    position: relative; transition: all .15s;
    flex-shrink: 0;
}
.circle-check::after {
    content: ''; position: absolute; top: 4px; left: 7px;
    width: 6px; height: 10px;
    border: solid #fff; border-width: 0 2px 2px 0;
    transform: rotate(45deg); opacity: 0; transition: opacity .15s;
}
input.file-cb:checked + .circle-check {
    background: var(--c-primary); border-color: var(--c-primary);
}
input.file-cb:checked + .circle-check::after { opacity: 1; }
input.file-cb { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }

/* File checkbox (videos, other files) */
.file-select-check {
    display: flex; align-items: center; cursor: pointer; flex-shrink: 0;
}

/* Video checkbox */
.video-check {
    position: absolute; top: .5rem; right: .5rem; z-index: 5;
    cursor: pointer;
}

/* Gallery checkbox */
.gallery-check {
    position: absolute; top: .5rem; right: .5rem; z-index: 5;
    cursor: pointer;
}

/* Download floating bar */
.dl-bar {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: #1a1a1a; border-top: 1px solid #333;
    padding: .75rem 1.5rem;
    display: flex; align-items: center; justify-content: space-between;
    z-index: 100;
    padding-bottom: calc(.75rem + env(safe-area-inset-bottom, 0px));
}
.dl-bar span { font-size: .85rem; color: #ccc; }

/* Gallery grid */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .75rem; }
.gallery-item {
    background: #1a1a1a; border-radius: 8px; overflow: hidden; cursor: pointer;
    position: relative; aspect-ratio: 1;
}
.gallery-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-item .overlay {
    position: absolute; bottom: 0; left: 0; right: 0;
    padding: .5rem; background: linear-gradient(transparent, rgba(0,0,0,.8));
    font-size: .75rem;
}

/* Lightbox */
.lightbox {
    position: fixed; inset: 0; background: rgba(0,0,0,.97); z-index: 1000;
    display: none; align-items: center; justify-content: center;
    flex-direction: column;
}
.lightbox.active { display: flex; }
.lightbox img { max-width: 92vw; max-height: 80vh; object-fit: contain; }
.lightbox-close {
    position: absolute; top: .75rem; right: 1rem;
    font-size: 2rem; color: #fff; cursor: pointer; background: none; border: none;
    width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
    z-index: 1010;
}
.lightbox-nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    font-size: 2.5rem; color: #fff; cursor: pointer; background: none; border: none;
    width: 48px; height: 80px; display: flex; align-items: center; justify-content: center;
    z-index: 1010;
}
.lightbox-prev { left: 0; }
.lightbox-next { right: 0; }
.lightbox-caption {
    position: absolute; bottom: 3rem; left: 0; right: 0;
    text-align: center; font-size: .8rem; color: #aaa;
    padding: .5rem 1rem;
}
.lightbox-actions {
    position: absolute; top: .75rem; left: 1rem;
    display: flex; gap: .4rem; z-index: 1010;
}
.lightbox-action-btn {
    padding: .4rem .8rem; border-radius: 6px;
    background: rgba(255,255,255,.15); color: #fff; font-size: .8rem; font-weight: 600;
    text-decoration: none; backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.lightbox-action-btn:hover { background: rgba(255,255,255,.25); text-decoration: none; }

/* Video player */
.video-container { margin-bottom: 1.5rem; position: relative; }
.video-container video {
    width: 100%; max-height: 70vh; background: #000; border-radius: 8px;
    display: block;
}
.video-title { margin-bottom: .5rem; font-size: .95rem; }
.video-controls { display: flex; gap: .4rem; margin-top: .5rem; flex-wrap: wrap; align-items: center; }
.video-controls button,
.video-controls a {
    padding: .4rem .7rem; border-radius: 6px; border: 1px solid #555;
    background: #222; color: #eee; cursor: pointer; font-size: .8rem;
    min-height: 36px; display: inline-flex; align-items: center;
}
.video-controls button.active { background: var(--c-primary); border-color: var(--c-primary); }

/* File list (non-previewable) */
.file-list { list-style: none; }
.file-list li {
    display: flex; align-items: center; gap: .75rem;
    padding: .75rem; background: #1a1a1a; border-radius: 8px; margin-bottom: .5rem;
}
.file-list .icon { font-size: 1.5rem; }
.file-list .info { flex: 1; min-width: 0; }
.file-list .info .fname { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list .info .fmeta { font-size: .75rem; color: #888; }

/* --- Viewer mobile --- */
@media (max-width: 600px) {
    .viewer-header { padding: .75rem 1rem; }
    .viewer-header h1 { font-size: .95rem; }
    .viewer-body { padding: .75rem; }
    .gallery { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .5rem; }
    .gallery-item .overlay { font-size: .65rem; padding: .3rem; }
    .lightbox img { max-width: 100vw; max-height: 85vh; }
    .lightbox-nav { font-size: 2rem; width: 40px; height: 60px; }
    .lightbox-close { font-size: 1.8rem; top: .5rem; right: .5rem; }
    .lightbox-caption { bottom: 2rem; font-size: .75rem; }
    .lightbox-actions { top: .5rem; left: .5rem; }
    .video-container video { border-radius: 4px; max-height: 50vh; }
    .video-controls { gap: .3rem; }
    .video-controls button,
    .video-controls a { padding: .35rem .5rem; font-size: .75rem; min-height: 32px; }
    .file-list li { padding: .6rem; gap: .5rem; }
    .file-list .info .fname { font-size: .8rem; }
    .dl-bar { padding: .6rem 1rem; }
    .select-toolbar { padding: .5rem .75rem; }
}

/* Unlock page */
.unlock-box {
    max-width: 400px; margin: 15vh auto; padding: 2rem;
    background: #1a1a1a; border-radius: var(--radius);
}
.unlock-box h2 { margin-bottom: 1rem; font-size: 1.2rem; }
.unlock-box .form-control { background: #222; color: #eee; border-color: #444; }
.unlock-box .form-control:focus { border-color: var(--c-primary); }

/* Grid */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

/* Token display */
.token-display {
    padding: .5rem .75rem; background: var(--c-bg); border-radius: 6px;
    font-family: monospace; font-size: .85rem; word-break: break-all;
    border: 1px solid var(--c-border); margin: .5rem 0;
}

/* Misc */
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-muted { color: var(--c-text2); }
.text-sm { font-size: .85rem; }
.text-center { text-align: center; }

/* --- Link action buttons --- */
.link-actions {
    display: flex; gap: .4rem; margin-top: .4rem;
}
.link-actions .btn-copy,
.link-actions .btn-open {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .35rem .7rem; border-radius: 6px;
    font-size: .78rem; font-weight: 600; cursor: pointer;
    text-decoration: none; border: 1px solid var(--c-border);
    transition: background .15s, border-color .15s;
}
.link-actions .btn-copy {
    background: var(--c-primary); color: #fff; border-color: var(--c-primary);
}
.link-actions .btn-copy:hover { background: var(--c-primary-hover); text-decoration: none; }
.link-actions .btn-open {
    background: var(--c-surface); color: var(--c-text);
}
.link-actions .btn-open:hover { background: var(--c-bg); text-decoration: none; }
