/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #f5f6f8;
    --card: #ffffff;
    --border: #e2e5ea;
    --text: #1a1a2e;
    --text-secondary: #6b7280;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --success: #16a34a;
    --approved-bg: #f0fdf4;
    --approved-border: #86efac;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* ---------- Flash messages ---------- */
.flash-container { position: fixed; top: 16px; right: 16px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.flash {
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow);
    animation: slideIn .3s ease;
}
.flash-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.flash-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---------- Layout helpers ---------- */
.page-center {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: 40px;
    width: 100%;
}

.upload-card { max-width: 480px; }
.login-card  { max-width: 400px; }

.card h1 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 4px;
}
.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 24px;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all .15s ease;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--text); color: #fff; }
.btn-secondary:hover { opacity: .85; }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- Form elements ---------- */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-secondary);
}
.form-group input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color .15s;
}
.form-group input:focus { border-color: var(--primary); }

/* ---------- Drop zone ---------- */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 24px;
    text-align: center;
    cursor: pointer;
    transition: all .2s ease;
    margin-bottom: 16px;
    position: relative;
}
.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--primary);
    background: #eff6ff;
}
.drop-zone-icon { color: var(--text-secondary); margin-bottom: 12px; }
.drop-zone-text { font-size: 14px; color: var(--text-secondary); }
.drop-zone-text .link { color: var(--primary); font-weight: 500; }
.drop-zone-hint { font-size: 12px; color: #9ca3af; margin-top: 4px; }
.drop-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}
.file-name {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    min-height: 20px;
}

/* ---------- Admin page ---------- */
.admin-page { max-width: 900px; margin: 0 auto; padding: 32px 24px; }
.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 12px;
}
.admin-header h1 { font-size: 22px; font-weight: 600; }
.header-actions { display: flex; gap: 8px; align-items: center; }

/* ---------- Empty state ---------- */
.empty-state {
    text-align: center;
    padding: 80px 24px;
    color: var(--text-secondary);
}
.empty-state svg { margin-bottom: 16px; opacity: .4; }
.empty-state p { font-size: 15px; }

/* ---------- File list ---------- */
.file-list { display: flex; flex-direction: column; gap: 12px; }

.file-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: var(--shadow);
    transition: border-color .2s;
}
.file-card.approved {
    background: var(--approved-bg);
    border-color: var(--approved-border);
}

.file-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}
.file-icon { flex-shrink: 0; }
.file-name-text {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 340px;
}
.file-date { font-size: 12px; color: var(--text-secondary); }

.file-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.inline-form { display: inline; }

/* Icon buttons */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
}
.btn-icon:hover { background: var(--bg); color: var(--text); }
.btn-icon-danger:hover { background: #fef2f2; color: var(--danger); border-color: #fecaca; }

/* ---------- Checkbox custom ---------- */
.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    padding: 5px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--card);
    transition: all .15s;
    user-select: none;
}
.checkbox-label:hover { background: var(--bg); }
.checkbox-label input { display: none; }
.checkmark {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-radius: 4px;
    transition: all .15s;
    position: relative;
}
.checkbox-label input:checked ~ .checkmark {
    background: var(--success);
    border-color: var(--success);
}
.checkbox-label input:checked ~ .checkmark::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.checkbox-label input:checked ~ .check-text { color: var(--success); }

/* ---------- Notes ---------- */
.file-card-bottom { margin-top: 12px; }
.notes-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    resize: vertical;
    min-height: 36px;
    outline: none;
    transition: border-color .15s;
    background: transparent;
}
.notes-input:focus { border-color: var(--primary); }

/* ---------- Viewer pages ---------- */
.viewer-page { max-width: 960px; margin: 0 auto; padding: 32px 24px; }
.viewer-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}
.viewer-header h2 { font-size: 18px; font-weight: 500; }
.viewer-body {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow);
    overflow: auto;
}
.text-viewer {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", monospace;
    font-size: 13px;
    line-height: 1.6;
}
.docx-viewer {
    font-size: 15px;
    line-height: 1.7;
}
.docx-viewer p { margin-bottom: 12px; }
.docx-viewer table { border-collapse: collapse; width: 100%; margin: 16px 0; }
.docx-viewer td, .docx-viewer th { border: 1px solid var(--border); padding: 8px 12px; }

.viewer-image { display: flex; justify-content: center; }
.viewer-image img { max-width: 100%; height: auto; border-radius: 6px; }

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
    .card { padding: 28px 20px; }
    .admin-header { flex-direction: column; align-items: flex-start; }
    .file-card-top { flex-direction: column; align-items: flex-start; }
    .file-actions { width: 100%; justify-content: flex-end; }
    .file-name-text { max-width: 200px; }
}
