/* ---------------------------------------------------------------------- */
/* Naran Uploads — base design system                                     */
/* ---------------------------------------------------------------------- */

:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --border: #e3e5ea;
    --text: #171a21;
    --text-muted: #6b7280;
    --primary: #2f5fed;
    --primary-dark: #2347c2;
    --primary-soft: #eaf0ff;
    --danger: #dc2626;
    --danger-soft: #fdecec;
    --success: #16a34a;
    --success-soft: #eafaf0;
    --radius-sm: 8px;
    --radius: 14px;
    --radius-lg: 20px;
    --shadow: 0 1px 2px rgba(20, 24, 38, 0.06), 0 8px 24px rgba(20, 24, 38, 0.05);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0 0 .5rem; font-weight: 650; letter-spacing: -0.01em; }

img { max-width: 100%; display: block; }

button { font-family: inherit; }

/* ---- Top navigation ---- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.brand {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
}
.brand:hover { text-decoration: none; }

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topbar-username {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.page {
    max-width: 1180px;
    margin: 0 auto;
    padding: 1rem 1rem 3rem;
}

/* ---- Buttons ---- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
    white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; }

.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { border-color: var(--primary); text-decoration: none; }

.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--bg); text-decoration: none; }

.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; text-decoration: none; }

.btn-sm { padding: 0.4rem 0.7rem; font-size: 0.8rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---- Forms ---- */

.field { margin-bottom: 0.9rem; }
.field label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.35rem; color: var(--text); }

input[type="text"], input[type="password"], input[type="search"], select, textarea {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 0.92rem;
    font-family: inherit;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

/* ---- Alerts ---- */

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-info { background: var(--primary-soft); color: var(--primary-dark); }
.alert-success { background: var(--success-soft); color: var(--success); }

/* ---- Panels / cards ---- */

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.1rem;
    margin-bottom: 1.25rem;
}

.panel-title { font-size: 1rem; margin-bottom: 0.9rem; }

.panel-subheader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    flex-wrap: wrap;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty-state.hidden { display: none; }

/* ---- Auth page ---- */

.auth-page {
    min-height: calc(100vh - 4rem);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 2rem 1.75rem;
}

.auth-header { text-align: center; margin-bottom: 1.5rem; }
.auth-mark {
    width: 44px; height: 44px; margin: 0 auto 0.75rem;
    background: var(--primary); color: #fff;
    border-radius: 12px; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.2rem;
}
.auth-header h1 { font-size: 1.2rem; margin-bottom: 0.15rem; }
.auth-header p { color: var(--text-muted); font-size: 0.85rem; margin: 0; }

.auth-tab-input { display: none; }

.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 3px;
    margin-bottom: 1.25rem;
}
.auth-tab {
    text-align: center;
    padding: 0.5rem;
    border-radius: 6px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
}
#tab-login:checked ~ .auth-tabs label[for="tab-login"],
#tab-signup:checked ~ .auth-tabs label[for="tab-signup"] {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 1px 2px rgba(20,24,38,0.08);
}

.auth-panel { display: none; }
#tab-login:checked ~ .auth-panel-login { display: block; }
#tab-signup:checked ~ .auth-panel-signup { display: block; }

/* ---- Upload panel ---- */

.dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    text-align: center;
    padding: 2rem 1rem;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone.dragover { border-color: var(--primary); background: var(--primary-soft); }
.dropzone-text { margin: 0 0 1rem; color: var(--text-muted); font-size: 0.9rem; }
.dropzone-actions { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; }
.dropzone-hint { margin: 1rem 0 0; font-size: 0.78rem; color: var(--text-muted); }

.selected-summary {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    padding: 0.6rem 0.85rem;
    background: var(--bg);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}
.selected-summary.hidden { display: none; }
#selected-count { font-weight: 600; }
#selected-size { color: var(--text-muted); }

.upload-progress { margin-top: 1rem; display: flex; align-items: center; gap: 0.75rem; }
.upload-progress.hidden { display: none; }
.progress-bar { flex: 1; height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: var(--primary); transition: width 0.2s ease; }

.upload-results { list-style: none; margin: 1rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.upload-results li {
    display: flex; justify-content: space-between; gap: 0.75rem;
    padding: 0.5rem 0.7rem; border-radius: var(--radius-sm); font-size: 0.83rem;
}
.upload-results li.ok { background: var(--success-soft); color: var(--success); }
.upload-results li.fail { background: var(--danger-soft); color: var(--danger); }

/* ---- Gallery toolbar & grid ---- */

.gallery-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 1.1rem;
}
.search-input { flex: 1 1 200px; min-width: 0; }
.select { flex: 0 0 auto; width: auto; }

.toggle-inline { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--text-muted); white-space: nowrap; }

.view-toggle { display: flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.view-btn { border: none; background: var(--surface); padding: 0.5rem 0.7rem; cursor: pointer; color: var(--text-muted); }
.view-btn.active { background: var(--primary-soft); color: var(--primary); }

.selection-bar {
    display: flex; align-items: center; gap: 0.6rem;
    background: var(--primary-soft); border-radius: var(--radius-sm);
    padding: 0.55rem 0.8rem; margin-bottom: 0.9rem; font-size: 0.85rem; color: var(--primary-dark);
}
.selection-bar.hidden { display: none; }
#selection-count { font-weight: 600; margin-right: auto; }

.file-card.selectable { position: relative; }
.file-card-select {
    position: absolute; top: 0.4rem; left: 0.4rem; z-index: 2;
    width: 20px; height: 20px; accent-color: var(--primary);
    display: none;
}
.gallery-page.selecting .file-card-select { display: block; }
.gallery-page.selecting .file-card-thumb { position: relative; }
.file-card.selected { outline: 2px solid var(--primary); outline-offset: -2px; }

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.85rem;
}
.gallery-grid.list-view { grid-template-columns: 1fr; }

.file-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    content-visibility: auto;
    contain-intrinsic-size: 280px 340px;
    flex-direction: column;
}
.file-card-thumb {
    aspect-ratio: 1 / 1;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
}
.file-card-thumb img, .file-card-thumb video { width: 100%; height: 100%; object-fit: cover; }
.file-card-thumb .file-icon-lg { color: var(--text-muted); }

.video-thumb-wrap { position: relative; width: 100%; height: 100%; }
.video-thumb-wrap img, .video-thumb-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-play-badge {
    position: absolute;
    left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    width: 42px; height: 42px;
    border-radius: 50%;
    background: rgba(15, 18, 28, 0.62);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    pointer-events: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.file-card-body { padding: 0.6rem 0.7rem 0.75rem; display: flex; flex-direction: column; gap: 0.2rem; flex: 1; }
.file-card-name { font-size: 0.83rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card-meta { font-size: 0.74rem; color: var(--text-muted); display: flex; justify-content: space-between; gap: 0.4rem; }
.file-card-foot { margin-top: 0.4rem; display: flex; justify-content: space-between; align-items: center; gap: 0.4rem; }

.gallery-grid.list-view .file-card { flex-direction: row; align-items: center; }
.gallery-grid.list-view .file-card-thumb { width: 64px; height: 64px; aspect-ratio: unset; flex-shrink: 0; }
.gallery-grid.list-view .file-card-body { flex-direction: row; align-items: center; justify-content: space-between; padding: 0.6rem 0.9rem; }
.gallery-grid.list-view .file-card-meta { flex-direction: column; align-items: flex-end; }

.uploader-group { margin-bottom: 1.5rem; }
.uploader-group-title { font-size: 0.85rem; font-weight: 700; color: var(--text-muted); margin-bottom: 0.6rem; text-transform: uppercase; letter-spacing: 0.03em; }

/* ---- Lightbox ---- */

.lightbox {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(10, 12, 20, 0.9);
    display: flex; align-items: center; justify-content: center;
    padding: 1.5rem;
}
.lightbox.hidden { display: none; }
.lightbox-body { max-width: 92vw; max-height: 88vh; display: flex; align-items: center; justify-content: center; }
.lightbox-body img, .lightbox-body video { max-width: 92vw; max-height: 88vh; border-radius: 8px; }
.lightbox-body audio { width: min(92vw, 420px); }
.lightbox-close {
    position: absolute; top: 1rem; right: 1.2rem;
    background: rgba(255,255,255,0.12); color: #fff; border: none;
    width: 36px; height: 36px; border-radius: 50%; font-size: 1rem; cursor: pointer;
}

/* ---- Toasts ---- */

.toast-root {
    position: fixed;
    bottom: 1rem; right: 1rem; left: 1rem;
    z-index: 200;
    display: flex; flex-direction: column; align-items: flex-end; gap: 0.5rem;
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    background: var(--text); color: #fff;
    padding: 0.65rem 1rem; border-radius: var(--radius-sm);
    font-size: 0.85rem; box-shadow: var(--shadow);
    max-width: 360px;
    animation: toast-in 0.2s ease;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.muted { color: var(--text-muted); }
.hidden { display: none !important; }

/* ---- Responsive ---- */

@media (min-width: 640px) {
    .page { padding: 1.5rem 1.5rem 3rem; }
    .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}

@media (min-width: 900px) {
    .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
}
