/* ───────────────────────────────────────────────────────────
   Asset Hoster – Stylesheet
   ─────────────────────────────────────────────────────────── */

/* Reset & base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #f5f6f8;
    color: #222;
    line-height: 1.6;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navbar ─────────────────────────────────────────────── */

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #1e293b;
    color: #fff;
    padding: 0.6rem 1.5rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.nav-brand {
    font-weight: 700;
    font-size: 1.15rem;
    color: #fff;
}
.nav-brand:hover { text-decoration: none; }
.nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.nav-links a { color: #cbd5e1; }
.nav-links a:hover { color: #fff; }

/* Search bar in nav */
.search-form {
    display: flex;
    gap: 0.3rem;
}
.search-form input {
    padding: 0.3rem 0.5rem;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    width: 180px;
}
.search-form button {
    padding: 0.3rem 0.7rem;
    border: none;
    border-radius: 4px;
    background: #3b82f6;
    color: #fff;
    cursor: pointer;
    font-size: 0.9rem;
}
.search-form button:hover { background: #2563eb; }

/* ── Container ──────────────────────────────────────────── */

.container {
    max-width: 1100px;
    margin: 1.5rem auto;
    padding: 0 1rem;
}

/* ── Flash messages ─────────────────────────────────────── */

.flash {
    padding: 0.7rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}
.flash-success { background: #d1fae5; color: #065f46; }
.flash-danger  { background: #fee2e2; color: #991b1b; }
.flash-warning { background: #fef3c7; color: #92400e; }
.flash-info    { background: #dbeafe; color: #1e40af; }

/* ── Headings ───────────────────────────────────────────── */

h1 {
    font-size: 1.4rem;
    margin-bottom: 1rem;
    word-break: break-all;
}

/* ── Tables ─────────────────────────────────────────────── */

.file-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.file-table th, .file-table td {
    padding: 0.55rem 0.8rem;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}
.file-table th {
    background: #f1f5f9;
    font-weight: 600;
    font-size: 0.9rem;
    color: #475569;
}
.size-col { white-space: nowrap; width: 90px; }
.action-cell {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    align-items: center;
}

/* ── Buttons ────────────────────────────────────────────── */

.btn {
    display: inline-block;
    padding: 0.45rem 0.9rem;
    border: none;
    border-radius: 5px;
    background: #2563eb;
    color: #fff;
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: none;
}
.btn:hover { background: #1d4ed8; text-decoration: none; }

.btn-sm { padding: 0.25rem 0.55rem; font-size: 0.8rem; }

.btn-secondary { background: #64748b; }
.btn-secondary:hover { background: #475569; }

.btn-danger { background: #dc2626; }
.btn-danger:hover { background: #b91c1c; }

/* ── Admin action panels ────────────────────────────────── */

.admin-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.action-panel {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    padding: 0.6rem 1rem;
}
.action-panel summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    user-select: none;
}
.action-panel form {
    margin-top: 0.5rem;
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    align-items: center;
}
.action-panel input[type="text"],
.action-panel input[type="file"] {
    padding: 0.35rem 0.5rem;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 0.9rem;
}

/* ── Inline forms ───────────────────────────────────────── */

.inline-form {
    display: inline-flex;
    gap: 0.3rem;
    align-items: center;
}
.input-sm {
    padding: 0.2rem 0.4rem;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 0.8rem;
    width: 120px;
}

/* ── Login box ──────────────────────────────────────────── */

.login-box {
    max-width: 360px;
    margin: 3rem auto;
    background: #fff;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.login-box h1 { text-align: center; margin-bottom: 1.2rem; }
.login-box label {
    display: block;
    margin-bottom: 0.3rem;
    font-weight: 600;
    font-size: 0.9rem;
}
.login-box input {
    width: 100%;
    padding: 0.5rem;
    margin-bottom: 1rem;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    font-size: 0.95rem;
}
.login-box .btn { width: 100%; text-align: center; }

/* ── Editor ─────────────────────────────────────────────── */

#editor {
    width: 100%;
    font-family: "Cascadia Code", "Fira Code", "Consolas", monospace;
    font-size: 0.9rem;
    padding: 0.7rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    resize: vertical;
    tab-size: 4;
    line-height: 1.5;
    background: #fafafa;
}
.editor-actions {
    margin-top: 0.6rem;
    display: flex;
    gap: 0.5rem;
}

/* ── Image thumbnails ───────────────────────────────────── */

.preview-row td { padding-top: 0; }
.thumb {
    max-width: 200px;
    max-height: 150px;
    border-radius: 4px;
    border: 1px solid #e5e7eb;
}

/* ── Misc ───────────────────────────────────────────────── */

.empty-msg {
    color: #64748b;
    font-style: italic;
}

/* ── Users Panel ────────────────────────────────────────── */

.users-panel { max-width: 1400px; margin-left: auto; margin-right: auto; }
.users-panel h1 { margin-bottom: 4px; }
.users-panel .subtitle { color: #64748b; margin-bottom: 20px; }

.card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}
.card h2 { margin-top: 0; margin-bottom: 16px; font-size: 1.1rem; }

/* Add user — compact inline bar */
.add-user-bar { padding: 14px 20px; }
.add-user-inline {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.add-user-inline .input-id {
    width: 200px;
    padding: 7px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: monospace;
}
.add-user-inline .input-name {
    width: 140px;
    padding: 7px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.85rem;
}
.add-user-inline .input-id:focus,
.add-user-inline .input-name:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}
.perm-check {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85rem;
    color: #475569;
    cursor: pointer;
    white-space: nowrap;
}

/* User list as card rows */
.user-list { display: flex; flex-direction: column; }
.user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    transition: background 0.15s;
    border-bottom: 1px solid #e5e7eb;
}
.user-row:last-child { border-bottom: none; }
.user-row:hover { background: #f8fafc; }
.user-identity {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}
.user-info { min-width: 0; }
.user-name {
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
}
.user-meta {
    font-size: 0.78rem;
    color: #94a3b8;
    margin-top: 2px;
}
.user-meta .sep { margin: 0 4px; }
.user-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    white-space: nowrap;
}
.user-actions form { margin: 0; display: inline-flex; }

/* Blacklisted user row */
.row-blacklisted { background: #fef2f2 !important; }
.row-blacklisted .user-name { color: #991b1b; }
.row-blacklisted .user-meta { color: #b91c1c; opacity: 0.7; }

.avatar-img { border-radius: 50%; }
.avatar-placeholder { width: 40px; height: 40px; border-radius: 50%; background: #e5e7eb; display: flex; align-items: center; justify-content: center; font-size: 0.85rem; color: #94a3b8; flex-shrink: 0; }

.mono { font-family: monospace; font-size: 0.82rem; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 0.72rem; font-weight: 600; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-purple { background: #f3e8ff; color: #6b21a8; }

.btn-small { padding: 5px 10px; font-size: 0.78rem; }
.btn-secondary { background: #f1f5f9; color: #334155; border: 1px solid #cbd5e1; border-radius: 4px; cursor: pointer; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; border-radius: 4px; cursor: pointer; }
.btn-danger:hover { background: #fecaca; }
.btn-danger-outline { background: transparent; color: #991b1b; border: 1px solid #fecaca; border-radius: 4px; cursor: pointer; }
.btn-danger-outline:hover { background: #fee2e2; }
.btn-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; border-radius: 4px; cursor: pointer; }
.btn-warning:hover { background: #fde68a; }
.btn-purple { background: #f3e8ff; color: #6b21a8; border: 1px solid #e9d5ff; border-radius: 4px; cursor: pointer; }
.btn-purple:hover { background: #e9d5ff; }
.btn-primary { background: #3b82f6; color: #fff; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; font-weight: 600; }
.btn-primary:hover { background: #2563eb; }

.empty-state { color: #94a3b8; font-style: italic; }

/* ── Users two-column layout ───────────────────────────── */

.users-columns {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}
.users-left {
    flex: 1 1 0;
    min-width: 0;
}
.users-right {
    flex: 0 0 420px;
    min-width: 0;
    position: sticky;
    top: 20px;
}

/* Activity log */
.activity-card { position: relative; }
.activity-search {
    margin-bottom: 12px;
}
.activity-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.85rem;
    background: #f9fafb;
}
.activity-search input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}
.activity-scroll {
    max-height: 620px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
}
.activity-scroll::-webkit-scrollbar { width: 6px; }
.activity-scroll::-webkit-scrollbar-track { background: #f1f5f9; }
.activity-scroll::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 3px; }
.activity-scroll::-webkit-scrollbar-thumb:hover { background: #64748b; }
.log-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.log-table th { text-align: left; padding: 6px 8px; background: #f8fafc; border-bottom: 2px solid #e5e7eb; position: sticky; top: 0; z-index: 1; }
.log-table td { padding: 5px 8px; border-bottom: 1px solid #f1f5f9; }
.log-table tr:hover { background: #f8fafc; }
.nowrap { white-space: nowrap; }
.details-cell { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 1024px) {
    .users-columns { flex-direction: column; }
    .users-right { flex: auto; width: 100%; position: static; }
    .add-user-inline { flex-direction: column; align-items: stretch; }
    .add-user-inline .input-id,
    .add-user-inline .input-name { width: 100%; }
}

/* ── Releases Panel ─────────────────────────────────────── */

.releases-panel { max-width: 900px; margin-left: auto; margin-right: auto; }
.releases-panel h1 { margin-bottom: 4px; }
.releases-panel .subtitle { color: #64748b; margin-bottom: 20px; }

.release-upload-card { margin-bottom: 16px; }

.release-upload-form .release-form-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.release-field label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 4px;
    color: #334155;
}
.release-input {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    width: 160px;
}
.release-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}
.release-input-wide { width: 220px; }
.hint-optional { font-weight: 400; font-size: 0.78rem; color: #94a3b8; }
.release-field-files { flex: 1; min-width: 200px; }
.release-field-btn { padding-bottom: 2px; }
.release-field-notes { width: 100%; }
.release-field-mandatory { width: 100%; margin-top: 4px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.9rem; color: #334155; }
.checkbox-label input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: #dc2626; }
.checkbox-label .hint-optional { color: #94a3b8; font-size: 0.8rem; }
.release-textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    resize: vertical;
}
.release-textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

/* API info */
.api-info-card { margin-bottom: 16px; }
.api-info-card h2 { font-size: 0.95rem; margin-bottom: 10px; }
.api-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.api-table td {
    padding: 6px 10px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: top;
}
.api-table td:first-child {
    white-space: nowrap;
    color: #2563eb;
    width: 1%;
}

/* Release list */
.release-list { display: flex; flex-direction: column; }
.release-row {
    padding: 16px;
    border-bottom: 1px solid #e5e7eb;
}
.release-row:last-child { border-bottom: none; }
.release-latest { background: #f0fdf4; }
.release-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 4px;
}
.release-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.release-version {
    font-weight: 700;
    font-size: 1.05rem;
    color: #1e293b;
}
.release-date {
    font-size: 0.78rem;
    color: #94a3b8;
}
.release-actions form { display: inline-flex; }
.release-notes {
    margin: 8px 0;
    padding: 8px 12px;
    background: #f8fafc;
    border-left: 3px solid #3b82f6;
    border-radius: 0 4px 4px 0;
    font-size: 0.88rem;
    color: #334155;
    white-space: pre-wrap;
}
.release-files {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
}
.release-file {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.88rem;
}
.release-file a {
    font-weight: 500;
}
.release-file-meta {
    font-size: 0.78rem;
    color: #94a3b8;
}

.upload-hint {
    font-size: 0.88rem;
    color: #64748b;
    margin-bottom: 14px;
    line-height: 1.5;
}
.upload-hint code {
    background: #f1f5f9;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.82rem;
}
.release-zip-info {
    margin: 8px 0 4px;
    font-size: 0.9rem;
}
.release-file-details {
    margin-top: 6px;
}
.release-file-details summary {
    cursor: pointer;
    font-size: 0.85rem;
    color: #64748b;
    user-select: none;
}
.release-file-details summary:hover {
    color: #334155;
}

@media (max-width: 640px) {
    .release-upload-form .release-form-row {
        flex-direction: column;
        align-items: stretch;
    }
    .release-input { width: 100%; }
}

/* ── Admins Panel ───────────────────────────────────────── */

.admins-panel { max-width: 800px; margin-left: auto; margin-right: auto; }
.admins-panel h1 { margin-bottom: 4px; }
.admins-panel .subtitle { color: #64748b; margin-bottom: 20px; }

.add-admin-bar { padding: 16px 20px; margin-bottom: 16px; }
.add-admin-bar h2 { margin-bottom: 10px; font-size: 1rem; }
.add-admin-form {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.admin-input {
    padding: 7px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.85rem;
    width: 180px;
}
.admin-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.admin-list { display: flex; flex-direction: column; }
.admin-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border-bottom: 1px solid #e5e7eb;
    gap: 12px;
}
.admin-row:last-child { border-bottom: none; }
.admin-row:hover { background: #f8fafc; }
.admin-identity {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.admin-name { font-weight: 600; font-size: 0.95rem; }
.admin-meta { font-size: 0.78rem; color: #94a3b8; }
.admin-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.admin-actions form { display: inline-flex; align-items: center; gap: 4px; }
/* ── SQL Reference Upload (Staff page) ──────────────────── */

.sql-upload-section { margin-top: 20px; }
.sql-hint {
    font-size: 0.88rem;
    color: #64748b;
    margin-bottom: 14px;
    line-height: 1.5;
}
.sql-hint code {
    background: #f1f5f9;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.82rem;
}
.sql-upload-form { margin-top: 8px; }
.sql-form-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.sql-field label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 4px;
    color: #334155;
}
.sql-input {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    width: 220px;
    font-family: monospace;
}
.sql-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}
.sql-field-file { flex: 1; min-width: 200px; }
.sql-file-input {
    font-size: 0.88rem;
    padding: 6px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    width: 100%;
    background: #f9fafb;
}
.sql-field-btn { padding-bottom: 2px; }

/* Reference list */
.sql-ref-list { margin-top: 4px; }
.sql-ref-group-header {
    padding: 10px 12px 4px;
    font-weight: 700;
    font-size: 0.9rem;
    color: #1e293b;
    border-top: 2px solid #e5e7eb;
}
.sql-ref-group-header:first-child { border-top: none; }
.sql-ref-row {
    padding: 8px 12px 8px 24px;
    border-bottom: 1px solid #f1f5f9;
}
.sql-ref-row:last-child { border-bottom: none; }
.sql-ref-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}
.sql-ref-filename {
    font-weight: 600;
    font-size: 0.9rem;
    color: #2563eb;
}
.sql-ref-meta {
    font-size: 0.78rem;
    color: #94a3b8;
}
.sql-ref-preview {
    font-size: 0.82rem;
    color: #64748b;
    white-space: pre-wrap;
    font-family: monospace;
    background: #f8fafc;
    padding: 6px 10px;
    border-radius: 4px;
    max-height: 80px;
    overflow: hidden;
}
.sql-ref-clear {
    padding: 8px 12px;
    text-align: right;
}

@media (max-width: 640px) {
    .sql-form-row { flex-direction: column; align-items: stretch; }
    .sql-input { width: 100%; }
}