/* DocFlow – Main Stylesheet */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #2563eb;
  --primary-light: #dbeafe;
  --success: #059669;
  --success-light: #d1fae5;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --sidebar-w: 240px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }

/* ── Layout ── */
.app-layout { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
.sidebar-logo { display: flex; align-items: center; gap: 10px; padding: 20px 16px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 16px; text-decoration: none; color: var(--text); }
.logo-icon { width: 32px; height: 32px; background: var(--primary); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 16px; color: white; }
.logo-icon.big { width: 48px; height: 48px; font-size: 24px; border-radius: 12px; }
.sidebar-nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500; transition: all .15s; }
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--primary); color: white; }
.sidebar-user { padding: 12px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-light); color: var(--primary); font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { color: var(--muted); font-size: 11px; }
.logout-btn { color: var(--muted); text-decoration: none; font-size: 18px; transition: color .15s; }
.logout-btn:hover { color: var(--danger); }
.main-content { flex: 1; overflow: auto; }
.content-inner { max-width: 1200px; margin: 0 auto; padding: 28px; }

/* ── Login ── */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: var(--surface); border-radius: 16px; padding: 40px; width: 100%; max-width: 400px; box-shadow: var(--shadow-md); }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { font-size: 24px; font-weight: 800; margin-top: 10px; }
.login-logo p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.btn-full { width: 100%; }
.login-hint { text-align: center; color: var(--muted); font-size: 12px; margin-top: 16px; }

/* ── Page Header ── */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-size: 22px; font-weight: 700; }
.subtitle { color: var(--muted); font-size: 13px; margin-top: 3px; }
.back-btn-wrap { display: flex; align-items: flex-start; gap: 12px; }
.title-with-badges { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ── Cards ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 20px; }
.card-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-header h2 { font-size: 15px; font-weight: 600; }
.form-card { max-width: 680px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.form-section { padding: 24px; }
.form-section-title { font-size: 15px; font-weight: 600; margin-bottom: 20px; }

/* ── Stats ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; display: flex; align-items: center; gap: 16px; box-shadow: var(--shadow); }
.stat-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.amber { background: var(--warning-light); color: var(--warning); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── Dashboard Grid ── */
.dashboard-grid { display: grid; grid-template-columns: 1fr 300px; gap: 20px; }
.dashboard-col { display: flex; flex-direction: column; gap: 20px; }
.dashboard-side { display: flex; flex-direction: column; gap: 20px; }
.cat-list { padding: 8px 20px 16px; }
.cat-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.cat-row:last-child { border: none; }
.cat-count { background: var(--bg); border-radius: 12px; padding: 2px 10px; font-weight: 600; font-size: 12px; }

/* ── Doc List ── */
.doc-list { padding: 8px; }
.doc-list-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; text-decoration: none; color: var(--text); transition: background .15s; }
.doc-list-item:hover { background: var(--bg); }
.cat-icon { width: 36px; height: 36px; border-radius: 8px; background: var(--primary-light); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.cat-icon.sm { width: 32px; height: 32px; font-size: 16px; }
.doc-meta { flex: 1; min-width: 0; }
.doc-title { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-sub { color: var(--muted); font-size: 11px; margin-top: 2px; }
.empty-msg { text-align: center; color: var(--muted); padding: 20px; font-size: 13px; }
.link-sm { font-size: 12px; color: var(--primary); text-decoration: none; }
.link-sm:hover { text-decoration: underline; }

/* ── Table ── */
.table { width: 100%; border-collapse: collapse; }
.table th { padding: 10px 16px; text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; background: var(--bg); border-bottom: 1px solid var(--border); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table-row { cursor: pointer; transition: background .15s; }
.table-row:hover { background: var(--bg); }
.doc-title-cell { font-weight: 500; font-size: 13px; }
.doc-desc-cell { color: var(--muted); font-size: 12px; margin-top: 2px; }
.empty-cell { text-align: center; color: var(--muted); padding: 40px; }
.text-muted { color: var(--muted); }

/* ── Filters ── */
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }

/* ── Forms ── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--border); }
label { font-size: 13px; font-weight: 500; }
.required { color: var(--danger); }
.input { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; font-size: 14px; width: 100%; color: var(--text); outline: none; transition: border-color .15s; font-family: inherit; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.textarea { resize: vertical; min-height: 80px; }
select.input { cursor: pointer; }

/* ── Dropzone ── */
.dropzone { position: relative; border: 2px dashed var(--border); border-radius: 10px; cursor: pointer; transition: border-color .15s, background .15s; margin-bottom: 20px; }
.dropzone:hover { border-color: var(--primary); background: #f8fbff; }
.dropzone-inner { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px; gap: 6px; pointer-events: none; }
.dropzone-icon { font-size: 32px; color: var(--muted); }
.dropzone-text { font-weight: 500; color: var(--text); }
.dropzone-hint { font-size: 12px; color: var(--muted); }
.file-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px; font-size: 13px; font-weight: 500; border: none; cursor: pointer; text-decoration: none; transition: all .15s; font-family: inherit; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e2e8f0; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #047857; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-amber { background: var(--warning-light); color: var(--warning); }
.badge-green { background: var(--success-light); color: var(--success); }
.badge-red { background: var(--danger-light); color: var(--danger); }
.badge-slate { background: #f1f5f9; color: #64748b; }
.badge-blue { background: var(--primary-light); color: var(--primary); }
.badge-orange { background: #fff7ed; color: #c2410c; }

/* ── Alerts ── */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.alert-error { background: var(--danger-light); color: var(--danger); border: 1px solid #fca5a5; }
.alert-success { background: var(--success-light); color: var(--success); border: 1px solid #6ee7b7; }

/* ── Detail Page ── */
.detail-grid { display: grid; grid-template-columns: 1fr 300px; gap: 20px; }
.detail-main { display: flex; flex-direction: column; gap: 20px; }
.detail-sidebar { display: flex; flex-direction: column; gap: 16px; }
.detail-rows { padding: 8px 20px 16px; display: flex; flex-direction: column; gap: 12px; }
.detail-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; font-size: 13px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.detail-row:last-child { border: none; }
.detail-label { color: var(--muted); font-size: 12px; min-width: 90px; }
.tag-wrap { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { background: var(--bg); padding: 2px 8px; border-radius: 12px; font-size: 11px; }

/* ── Action Banners ── */
.action-banner { padding: 16px 20px; border-radius: var(--radius); margin-bottom: 0; }
.action-banner p { font-size: 13px; margin-bottom: 10px; }
.action-banner.amber { background: #fffbeb; border: 1px solid #fde68a; }
.action-banner.blue { background: #eff6ff; border: 1px solid #bfdbfe; }
.action-banner.red { background: var(--danger-light); border: 1px solid #fca5a5; }
.action-btns { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Timeline ── */
.timeline { padding: 20px; display: flex; flex-direction: column; gap: 0; }
.timeline-item { display: flex; gap: 12px; padding-bottom: 20px; position: relative; }
.timeline-item:not(:last-child)::after { content:''; position: absolute; left: 15px; top: 32px; bottom: 0; width: 1px; background: var(--border); }
.timeline-icon { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; background: var(--bg); }
.submitted-icon { background: #dbeafe; color: #1d4ed8; }
.approved-icon { background: var(--success-light); color: var(--success); }
.rejected-icon { background: var(--danger-light); color: var(--danger); }
.archived-icon { background: #f1f5f9; color: #64748b; }
.comment-icon { background: #f3e8ff; color: #7c3aed; }
.timeline-action { font-size: 13px; font-weight: 600; text-transform: capitalize; }
.timeline-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.timeline-comment { font-size: 13px; margin-top: 6px; background: var(--bg); padding: 8px 12px; border-radius: 8px; }
.comment-form { padding: 16px 20px; border-top: 1px solid var(--border); }

/* ── Modal ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: var(--surface); border-radius: 12px; padding: 28px; width: 100%; max-width: 480px; box-shadow: var(--shadow-md); }
.modal-header { margin-bottom: 20px; }
.modal-header h2 { font-size: 17px; font-weight: 700; }

/* ── Approval Steps ── */
.approval-steps { display: flex; align-items: flex-start; gap: 0; margin-top: 12px; }
.approval-step { display: flex; flex-direction: column; align-items: center; flex: 1; position: relative; }
.approval-step:not(:last-child)::after { content:''; position: absolute; top: 10px; left: 50%; width: 100%; height: 2px; background: var(--border); z-index: 0; }
.approval-step.done::after { background: var(--success); }
.approval-step.active::after { background: var(--warning); }
.step-dot { width: 20px; height: 20px; border-radius: 50%; background: var(--border); z-index: 1; border: 3px solid var(--surface); }
.approval-step.done .step-dot { background: var(--success); }
.approval-step.active .step-dot { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-light); }
.step-label { font-size: 10px; color: var(--muted); margin-top: 5px; text-align: center; max-width: 64px; line-height: 1.2; }
.approval-step.done .step-label { color: var(--success); font-weight: 600; }
.approval-step.active .step-label { color: var(--warning); font-weight: 700; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .dashboard-grid, .detail-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .content-inner { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
