/* OnlineFiles - stylesheet */

:root {
    --color-bg: #f4f6f8;
    --color-surface: #ffffff;
    --color-border: #e1e5ea;
    --color-text: #1f2937;
    --color-text-muted: #6b7280;
    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-danger: #dc2626;
    --color-danger-dark: #b91c1c;
    --color-success-bg: #ecfdf5;
    --color-success-text: #065f46;
    --color-error-bg: #fef2f2;
    --color-error-text: #991b1b;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
}

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

/* ---------- Top bar ---------- */

.topbar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    gap: 12px;
    flex-wrap: wrap;
}

.brand {
    font-weight: 800;
    letter-spacing: 0.06em;
    font-size: 1.15rem;
    color: var(--color-text);
}
.brand:hover { text-decoration: none; }

.topbar-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    min-height: 40px;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; background: #f9fafb; }

.btn-primary {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}
.btn-primary:hover { background: var(--color-primary-dark); }

.btn-ghost { background: transparent; }

.btn-danger { color: var(--color-danger); }
.btn-danger:hover { background: var(--color-error-bg); border-color: var(--color-danger); }

.btn-block { width: 100%; }

.btn-icon {
    padding: 8px 12px;
    min-height: 36px;
    font-size: 0.85rem;
}

/* ---------- Layout ---------- */

.app-main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px;
}

.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.92rem;
}
.flash-success { background: var(--color-success-bg); color: var(--color-success-text); }
.flash-error { background: var(--color-error-bg); color: var(--color-error-text); }

.toolbar-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
}

/* ---------- Category filter row ---------- */

.filter-row {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.filter-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-field label {
    font-size: 0.76rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text-muted);
}

.filter-field select {
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    font-size: 0.9rem;
    min-width: 170px;
    background: var(--color-surface);
    color: var(--color-text);
}

.filter-field select:disabled {
    color: var(--color-text-muted);
    background: var(--color-bg);
}

/* ---------- Category tags in the file table ---------- */

.tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    background: #eff6ff;
    color: var(--color-primary-dark);
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

.tag-muted {
    background: var(--color-bg);
    color: var(--color-text-muted);
    font-weight: 500;
}

.breadcrumb {
    font-size: 0.95rem;
    color: var(--color-text-muted);
}
.breadcrumb a { color: var(--color-text-muted); }
.crumb-current { color: var(--color-text); font-weight: 600; }
.crumb-sep { margin: 0 6px; }

/* ---------- File table ---------- */

.file-table-wrap {
    background: var(--color-surface);
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    overflow-x: auto;
    box-shadow: var(--shadow);
}

.file-table { width: 100%; border-collapse: collapse; min-width: 560px; }

.file-table th {
    text-align: left;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
}

.file-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
    font-size: 0.92rem;
}

.file-table tr:last-child td { border-bottom: none; }

.col-actions { white-space: nowrap; text-align: right; }
.col-size, .col-date, .col-type, .col-category { color: var(--color-text-muted); white-space: nowrap; }

.item-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--color-text);
}
.item-link:hover { text-decoration: none; }

.item-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 340px;
}

.icon { font-size: 1.3rem; line-height: 1; flex-shrink: 0; }

.thumb {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    background: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.inline-form { display: inline-block; }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--color-text-muted);
    background: var(--color-surface);
    border-radius: var(--radius);
    border: 1px dashed var(--color-border);
}
.empty-hint { font-size: 0.88rem; }

/* ---------- Panels / modals ---------- */

.panel-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
}
.panel-overlay[hidden] { display: none; }

.panel {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 24px;
    width: 100%;
    max-width: 460px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}
.panel-small { max-width: 360px; }

.panel h2 { margin-top: 0; }
.panel-hint { color: var(--color-text-muted); font-size: 0.88rem; margin-top: -8px; }
.edit-filename { color: var(--color-text); word-break: break-word; }

.panel label {
    display: block;
    font-weight: 600;
    font-size: 0.88rem;
    margin: 14px 0 6px;
}

.panel input[type="text"],
.panel input[type="email"],
.panel input[type="password"],
.panel textarea {
    width: 100%;
    padding: 11px 12px;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    font-size: 1rem;
}

.panel-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* ---------- Dropzone ---------- */

.dropzone {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius);
    padding: 28px 16px;
    text-align: center;
    margin-top: 10px;
}
.dropzone.dragover { border-color: var(--color-primary); background: #eff6ff; }
.dropzone p { margin: 6px 0; color: var(--color-text-muted); }
.dropzone-or { font-size: 0.8rem; }
.dropzone .btn { margin: 4px 6px; }

.selected-files {
    list-style: none;
    padding: 0;
    margin: 14px 0 0;
    max-height: 140px;
    overflow-y: auto;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}
.selected-files li { padding: 4px 0; border-bottom: 1px solid var(--color-border); }

/* ---------- Login page ---------- */

.login-body {
    background: var(--color-bg);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.login-wrap { width: 100%; max-width: 400px; padding: 20px; }
.login-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px 28px;
}
.login-brand { text-align: center; letter-spacing: 0.06em; margin-bottom: 2px; }
.login-subtitle { text-align: center; color: var(--color-text-muted); margin-top: 0; margin-bottom: 20px; font-size: 0.9rem; }
.login-card label { display: block; font-weight: 600; font-size: 0.88rem; margin: 14px 0 6px; }
.login-card input {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    font-size: 1rem;
}
.login-card .btn { margin-top: 20px; }

/* ---------- Viewer (PDF) ---------- */

.viewer-body { margin: 0; height: 100vh; display: flex; flex-direction: column; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
.viewer-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    flex-wrap: wrap;
}
.viewer-filename { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; text-align: center; }
.pdf-frame-wrap { flex: 1; }
.pdf-frame { width: 100%; height: 100%; border: none; }

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
    .item-name { max-width: 150px; }
    .file-table th.col-size,
    .file-table td.col-size { display: none; }
    .topbar-actions .btn { padding: 9px 12px; font-size: 0.85rem; }
    .col-actions { text-align: left; }
    .filter-row { flex-direction: column; align-items: stretch; }
    .filter-field select { min-width: 0; width: 100%; }
}

@media (max-width: 520px) {
    /* Category hides before Size (already hidden at 640px) on very
       narrow screens, keeping name and actions visible. */
    .file-table th.col-category,
    .file-table td.col-category { display: none; }
}
