/* ============================================================
   GGC FileHub — Red & Black Theme
   ============================================================ */

:root {
    --bg-black: #0c0c0e;
    --bg-panel: #17171b;
    --bg-panel-2: #1f1f24;
    --bg-hover: #262629;
    --border-color: #2c2c31;

    --red: #e0102b;
    --red-dark: #a30d20;
    --red-light: #ff2d47;
    --red-glow: rgba(224, 16, 43, 0.35);

    --text-primary: #f4f4f5;
    --text-secondary: #a6a6ad;
    --text-muted: #6b6b73;

    --success: #23c55e;
    --warning: #f5a524;
    --danger: #e0102b;
    --info: #3b82f6;

    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    --font: 'Segoe UI', system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;

    --sidebar-grad-start: #141416;
    --sidebar-grad-end: #0a0a0b;
}

/* Light theme override — activated via data-theme="light" on <html>, set by main.js */
:root[data-theme="light"] {
    --bg-black: #f2f2f5;
    --bg-panel: #ffffff;
    --bg-panel-2: #f4f4f6;
    --bg-hover: #ebebef;
    --border-color: #e0e0e5;

    --red-glow: rgba(224, 16, 43, 0.18);

    --text-primary: #18181b;
    --text-secondary: #55555d;
    --text-muted: #86868f;

    --shadow: 0 8px 24px rgba(20, 20, 30, 0.10);

    --sidebar-grad-start: #ffffff;
    --sidebar-grad-end: #f6f6f8;
}

* { box-sizing: border-box; }

:focus-visible {
    outline: 2px solid var(--red);
    outline-offset: 2px;
    border-radius: 3px;
}

::selection { background: var(--red); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-black); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--red-dark); }
* { scrollbar-color: var(--border-color) var(--bg-black); scrollbar-width: thin; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg-black);
    color: var(--text-primary);
    font-family: var(--font);
    min-height: 100vh;
}

a { color: var(--red-light); text-decoration: none; }
a:hover { color: var(--red); }

/* ---------------- Layout shell ---------------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--sidebar-grad-start) 0%, var(--sidebar-grad-end) 100%);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    transition: transform 0.25s ease, background 0.15s ease;
    z-index: 100;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 22px 20px;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}
.sidebar-brand i { color: var(--red); font-size: 1.3rem; }
.sidebar-brand-logo { height: 30px; width: auto; }

.sidebar-nav {
    flex: 1;
    padding: 14px 10px;
    overflow-y: auto;
}
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    margin-bottom: 4px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.92rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}
.sidebar-nav a i { width: 18px; text-align: center; color: var(--text-muted); transition: color 0.15s; }
.sidebar-nav a:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-nav a:hover i { color: var(--red-light); }
.sidebar-nav a.active {
    background: linear-gradient(90deg, var(--red-glow), transparent);
    color: var(--text-primary);
    border-left: 3px solid var(--red);
    padding-left: 11px;
}
.sidebar-nav a.active i { color: var(--red); }

.sidebar-section {
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 16px 14px 6px;
    font-weight: 600;
}

.sidebar-footer {
    padding: 14px 10px;
    border-top: 1px solid var(--border-color);
}
.logout-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.92rem;
    font-weight: 500;
}
.logout-link:hover { background: rgba(224, 16, 43, 0.12); color: var(--red-light); }

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 28px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-title { font-size: 1.2rem; font-weight: 700; margin: 0; flex: 1; color: var(--text-primary); }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.topbar-username { font-size: 0.9rem; color: var(--text-secondary); }
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
}

.content { padding: 28px; flex: 1; }

/* ---------------- Badges ---------------- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.badge-role-admin { background: rgba(224,16,43,0.18); color: var(--red-light); border: 1px solid var(--red-dark); }
.badge-role-uploader { background: rgba(245,165,36,0.15); color: var(--warning); border: 1px solid #7a5314; }
.badge-role-viewer { background: rgba(166,166,173,0.12); color: var(--text-secondary); border: 1px solid var(--border-color); }
.badge-status-active { background: rgba(35,197,94,0.15); color: var(--success); border: 1px solid #145c30; }
.badge-status-inactive { background: rgba(224,16,43,0.12); color: var(--red-light); border: 1px solid var(--red-dark); }
.badge-cat { background: var(--bg-panel-2); color: var(--text-secondary); border: 1px solid var(--border-color); }

/* ---------------- Alerts ---------------- */
.alert {
    padding: 13px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
}
.alert-success { background: rgba(35,197,94,0.1); border: 1px solid #145c30; color: #6be398; }
.alert-error { background: rgba(224,16,43,0.1); border: 1px solid var(--red-dark); color: var(--red-light); }

/* ---------------- Buttons ---------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}
.btn-primary {
    background: linear-gradient(135deg, var(--red) 0%, var(--red-dark) 100%);
    color: #fff;
    box-shadow: 0 4px 14px rgba(224,16,43,0.25);
}
.btn-primary:hover { filter: brightness(1.12); color: #fff; box-shadow: 0 6px 18px var(--red-glow); }
.btn-secondary { background: var(--bg-panel-2); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-secondary:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-outline { background: transparent; color: var(--red-light); border: 1px solid var(--red-dark); }
.btn-outline:hover { background: rgba(224,16,43,0.1); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: var(--red-dark); }
.btn-sm { padding: 6px 12px; font-size: 0.78rem; }
.btn-block { width: 100%; }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------------- Cards / Panels ---------------- */
.card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    flex-wrap: wrap;
    gap: 12px;
}
.card-title { font-size: 1.05rem; font-weight: 700; margin: 0; color: var(--text-primary); }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.stat-card:hover { transform: translateY(-2px); border-color: var(--red-dark); box-shadow: 0 10px 24px rgba(224,16,43,0.14); }
.stat-card .stat-icon {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 1.1rem;
    color: #fff;
    background: var(--red);
    box-shadow: 0 4px 14px rgba(224,16,43,0.35);
    margin-bottom: 12px;
}
.stat-icon-red { background: var(--red); box-shadow: 0 4px 14px rgba(224,16,43,0.35); }
.stat-icon-green { background: var(--success); box-shadow: 0 4px 14px rgba(35,197,94,0.35); }
.stat-icon-orange { background: var(--warning); box-shadow: 0 4px 14px rgba(245,165,36,0.35); }
.stat-icon-blue { background: var(--info); box-shadow: 0 4px 14px rgba(59,130,246,0.35); }
.stat-card .stat-value { font-size: 1.7rem; font-weight: 800; color: var(--text-primary); }
.stat-card .stat-label { font-size: 0.82rem; color: var(--text-secondary); margin-top: 2px; }

/* ---------------- Forms ---------------- */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 7px; color: var(--text-secondary); }
.form-control {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-panel-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.92rem;
    font-family: var(--font);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus {
    outline: none;
    border-color: var(--red);
    box-shadow: 0 0 0 3px var(--red-glow);
}
textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control { cursor: pointer; }
.form-hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 5px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }

.input-with-actions { display: flex; gap: 8px; }
.input-with-actions .form-control { flex: 1; min-width: 0; }
.input-with-actions .btn { flex-shrink: 0; }

.input-file-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 36px 20px;
    text-align: center;
    background: var(--bg-panel-2);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.input-file-wrap:hover, .input-file-wrap.dragover { border-color: var(--red); background: rgba(224,16,43,0.06); }
.input-file-wrap i { font-size: 2rem; color: var(--red-light); margin-bottom: 10px; }
.input-file-wrap input[type=file] { display: none; }

/* ---------------- Tables ---------------- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.data-table th {
    text-align: left;
    padding: 12px 14px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
}
.data-table td { padding: 13px 14px; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
.data-table tr:hover td { background: var(--bg-hover); }
.data-table tr:last-child td { border-bottom: none; }

/* ---------------- File grid ---------------- */
.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px;
}
.file-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.file-card-active { border-color: var(--red); }
.file-card:hover { transform: translateY(-3px); border-color: var(--success); box-shadow: 0 10px 26px rgba(35,197,94,0.15); }
.file-card-top { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.file-icon {
    width: 46px; height: 46px;
    border-radius: var(--radius-sm);
    background: rgba(224,16,43,0.12);
    display: flex; align-items: center; justify-content: center;
    color: var(--red-light);
    font-size: 1.3rem;
    flex-shrink: 0;
}
.file-name { font-weight: 700; color: var(--text-primary); font-size: 0.95rem; overflow-wrap: anywhere; }
.file-meta { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.file-desc { font-size: 0.82rem; color: var(--text-secondary); margin: 10px 0; min-height: 20px; }
.file-meta-footer { margin-top: auto; padding-top: 10px; }
.file-card-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* ---------------- Auth pages ---------------- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background:
        radial-gradient(circle at 15% 20%, rgba(224,16,43,0.18), transparent 40%),
        radial-gradient(circle at 85% 80%, rgba(224,16,43,0.12), transparent 45%),
        var(--bg-black);
}
.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 36px 32px;
    box-shadow: var(--shadow);
}
.auth-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 26px;
    text-align: center;
}
.auth-brand i { font-size: 2.4rem; color: var(--red); }
.auth-brand-logo { height: 64px; width: auto; }
.auth-brand h1 { font-size: 1.3rem; margin: 0; color: var(--text-primary); }
.auth-brand p { margin: 0; color: var(--text-muted); font-size: 0.85rem; }

/* ---------------- Public download page ---------------- */
.public-page {
    min-height: 100vh;
    background: var(--bg-black);
    padding: 40px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.download-card {
    max-width: 460px;
    width: 100%;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 34px;
    text-align: center;
    box-shadow: var(--shadow);
}
.download-icon {
    width: 76px; height: 76px;
    margin: 0 auto 18px;
    border-radius: 18px;
    background: rgba(224,16,43,0.14);
    display: flex; align-items: center; justify-content: center;
    font-size: 2.1rem; color: var(--red-light);
}
.qr-box {
    background: #fff;
    padding: 14px;
    border-radius: var(--radius);
    display: inline-block;
    margin: 18px 0;
}
.qr-box img { display: block; width: 180px; height: 180px; }
.share-link-box {
    display: flex;
    gap: 8px;
    background: var(--bg-panel-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    align-items: center;
    margin-top: 10px;
}
.share-link-box input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.8rem;
    outline: none;
}

.share-buttons { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.share-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-panel-2);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.15s;
}
.share-btn:active { transform: scale(0.94); }
.share-btn-whatsapp:hover { background: #25d366; color: #fff; border-color: #25d366; }
.share-btn-viber:hover { background: #7360f2; color: #fff; border-color: #7360f2; }
.share-btn-messenger:hover { background: #00b2ff; color: #fff; border-color: #00b2ff; }
.share-btn-telegram:hover { background: #229ed9; color: #fff; border-color: #229ed9; }
.share-btn-email:hover { background: var(--red); color: #fff; border-color: var(--red); }
.share-btn-more:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--red-dark); }

/* ---------------- Misc ---------------- */
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state i {
    width: 72px;
    height: 72px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 1.8rem;
    margin-bottom: 16px;
    color: var(--red-light);
    background: rgba(224,16,43,0.10);
}

.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}
.search-bar .form-control { max-width: 320px; }

.avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--bg-panel-2);
    border: 1px solid var(--border-color);
    display: flex; align-items: center; justify-content: center;
    color: var(--red-light);
    font-weight: 700;
    font-size: 0.85rem;
    overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.accordion {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    overflow: hidden;
}
.accordion:last-child { margin-bottom: 0; }
.accordion summary {
    list-style: none;
    cursor: pointer;
    padding: 13px 16px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    background: var(--bg-panel-2);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.15s;
}
.accordion summary::-webkit-details-marker { display: none; }
.accordion summary i:first-child { color: var(--red-light); width: 18px; text-align: center; }
.accordion summary::after {
    content: '\f078';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: transform 0.15s;
}
.accordion[open] summary::after { transform: rotate(180deg); }
.accordion summary:hover { background: var(--bg-hover); }
.accordion-body {
    padding: 16px 18px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}
.accordion-body ol { margin: 0; padding-left: 20px; }
.accordion-body li { margin-bottom: 6px; }
.accordion-body li:last-child { margin-bottom: 0; }
.accordion-body p { margin: 0; }

.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.65);
    align-items: center; justify-content: center;
    z-index: 200;
    padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 26px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow);
}

/* ---------------- Theme toggle ---------------- */
.theme-toggle {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-panel-2);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.theme-toggle:hover { background: var(--bg-hover); color: var(--red-light); border-color: var(--red-dark); }
.theme-toggle-fixed { position: fixed; top: 18px; right: 18px; z-index: 60; }

@media (max-width: 880px) {
    .sidebar { position: fixed; transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: block; }
    .content { padding: 18px; }
    .topbar { padding: 14px 18px; }
}
