/* =============================================================================
   WF MIS — app.css
   Industrial, clean, high-contrast UI
   ============================================================================= */

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

:root {
    --bg:           #f4f5f7;
    --surface:      #ffffff;
    --sidebar-bg:   #1a1f2e;
    --sidebar-text: #a8b2c8;
    --sidebar-hover:#2d3448;
    --sidebar-active:#3b82f6;
    --topbar-bg:    #ffffff;
    --topbar-border:#e2e8f0;
    --text-primary: #1e293b;
    --text-secondary:#64748b;
    --text-muted:   #94a3b8;
    --border:       #e2e8f0;
    --accent:       #3b82f6;
    --accent-dark:  #2563eb;
    --success:      #10b981;
    --warning:      #f59e0b;
    --danger:       #ef4444;
    --info:         #06b6d4;
    --radius:       6px;
    --radius-lg:    10px;
    --shadow:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:    0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
    --sidebar-w:    220px;
    --topbar-h:     56px;
    --font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono:    'JetBrains Mono', 'Fira Code', monospace;
}

html { font-size: 15px; }
body { font-family: var(--font); background: var(--bg); color: var(--text-primary);
       line-height: 1.5; }
a    { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Layout ---------------------------------------------------------------- */
.app-layout    { display: flex; min-height: calc(100vh - var(--topbar-h)); padding-top: var(--topbar-h); }
.sidebar       { width: var(--sidebar-w); background: var(--sidebar-bg);
                 position: fixed; top: var(--topbar-h); left: 0; bottom: 0;
                 overflow-y: auto; z-index: 100; transition: transform .2s; }
.main-content  { margin-left: var(--sidebar-w); padding: 24px 28px;
                 flex: 1; min-width: 0; }

/* --- Top bar --------------------------------------------------------------- */
.topbar        { position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
                 background: var(--topbar-bg); border-bottom: 1px solid var(--topbar-border);
                 display: flex; align-items: center; justify-content: space-between;
                 padding: 0 20px; z-index: 200; }
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-brand  { display: flex; align-items: center; gap: 8px; font-weight: 600;
                 color: var(--text-primary); font-size: 15px; text-decoration: none; }
.logo-mark     { background: var(--accent); color: #fff; padding: 3px 7px;
                 border-radius: 4px; font-size: 12px; font-weight: 700; letter-spacing: .05em; }
.sidebar-toggle { background: none; border: none; cursor: pointer; padding: 6px;
                  display: flex; flex-direction: column; gap: 5px; }
.sidebar-toggle span { display: block; width: 20px; height: 2px; background: var(--text-secondary); border-radius: 2px; }

/* --- User menu ------------------------------------------------------------- */
.user-menu     { position: relative; }
.user-menu-btn { background: none; border: 1px solid var(--border); border-radius: var(--radius);
                 padding: 5px 10px; cursor: pointer; display: flex; align-items: center; gap: 8px;
                 font-size: 13px; color: var(--text-primary); }
.avatar        { width: 26px; height: 26px; border-radius: 50%; background: var(--accent);
                 color: #fff; display: flex; align-items: center; justify-content: center;
                 font-size: 12px; font-weight: 700; }
.chevron       { font-size: 10px; color: var(--text-muted); }
.user-dropdown { display: none; position: absolute; right: 0; top: calc(100% + 6px);
                 background: var(--surface); border: 1px solid var(--border);
                 border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
                 min-width: 160px; z-index: 300; overflow: hidden; }
.user-dropdown.open { display: block; }
.user-dropdown a    { display: block; padding: 9px 14px; font-size: 13px;
                      color: var(--text-primary); transition: background .15s; }
.user-dropdown a:hover { background: var(--bg); text-decoration: none; }
.user-dropdown hr   { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

/* --- Sidebar nav ----------------------------------------------------------- */
.nav-list      { list-style: none; padding: 12px 0; }
.nav-section   { font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
                 color: #4a5568; padding: 16px 16px 4px; }
.nav-item a    { display: flex; align-items: center; gap: 10px; padding: 9px 16px;
                 color: var(--sidebar-text); font-size: 13.5px; transition: background .15s, color .15s;
                 text-decoration: none; }
.nav-item a:hover    { background: var(--sidebar-hover); color: #fff; }
.nav-item.active > a { background: rgba(59,130,246,.15); color: #93c5fd;
                       border-left: 3px solid var(--sidebar-active); }
.nav-icon      { width: 18px; text-align: center; font-size: 14px; }
.sidebar-footer{ padding: 16px; font-size: 11px; color: #4a5568; border-top: 1px solid #2d3448; }
.sidebar-footer a { color: #4a5568; }

/* --- Flash messages -------------------------------------------------------- */
.flash         { padding: 11px 16px; font-size: 13.5px; display: flex;
                 align-items: center; justify-content: space-between;
                 border-left: 4px solid; margin-bottom: 0; }
.flash button  { background: none; border: none; cursor: pointer; font-size: 16px;
                 line-height: 1; color: inherit; opacity: .7; padding: 0 4px; }
.flash-success { background: #f0fdf4; border-color: var(--success); color: #166534; }
.flash-error   { background: #fef2f2; border-color: var(--danger);  color: #991b1b; }
.flash-info    { background: #f0f9ff; border-color: var(--info);    color: #0c4a6e; }

/* --- Cards ----------------------------------------------------------------- */
.card          { background: var(--surface); border: 1px solid var(--border);
                 border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.card-header   { padding: 16px 20px 14px; border-bottom: 1px solid var(--border);
                 display: flex; align-items: center; justify-content: space-between; }
.card-title    { font-size: 15px; font-weight: 600; color: var(--text-primary); margin: 0; }
.card-body     { padding: 20px; }

/* --- Page header ----------------------------------------------------------- */
.page-header   { display: flex; align-items: center; justify-content: space-between;
                 margin-bottom: 20px; }
.page-title    { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.page-sub      { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.page-actions  { display: flex; gap: 8px; align-items: center; }
.breadcrumb    { font-size: 12px; color: var(--text-muted); margin-bottom: 16px; }
.breadcrumb a  { color: var(--text-secondary); }
.breadcrumb span { margin: 0 5px; }

/* --- Buttons --------------------------------------------------------------- */
.btn           { display: inline-flex; align-items: center; gap: 6px;
                 padding: 7px 14px; border-radius: var(--radius); font-size: 13.5px;
                 font-weight: 500; cursor: pointer; border: 1px solid transparent;
                 transition: background .15s, border-color .15s, color .15s;
                 text-decoration: none; white-space: nowrap; }
.btn:hover     { text-decoration: none; }
.btn-primary   { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-outline   { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-outline:hover { background: #eff6ff; }
.btn-danger    { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; }
.btn-secondary { background: var(--bg); color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover { background: #e9ecef; }
.btn-sm        { padding: 4px 10px; font-size: 12px; }
.btn-full      { width: 100%; justify-content: center; }
.btn-success   { background: var(--success); color: #fff; border-color: var(--success); }

/* --- Forms ----------------------------------------------------------------- */
.form-group    { margin-bottom: 16px; }
.form-row      { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3    { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
label          { display: block; font-size: 13px; font-weight: 500;
                 color: var(--text-secondary); margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=search], select, textarea {
    width: 100%; padding: 8px 11px; font-size: 14px; font-family: var(--font);
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface); color: var(--text-primary);
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
textarea       { resize: vertical; min-height: 90px; }
.form-hint     { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-section  { font-size: 12px; font-weight: 700; text-transform: uppercase;
                 letter-spacing: .07em; color: var(--text-muted);
                 margin: 24px 0 12px; padding-bottom: 6px;
                 border-bottom: 1px solid var(--border); }

/* --- Tables ---------------------------------------------------------------- */
.table-wrap    { overflow-x: auto; }
table          { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th       { padding: 10px 14px; background: var(--bg); font-weight: 600;
                 font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
                 color: var(--text-secondary); text-align: left;
                 border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody td       { padding: 10px 14px; border-bottom: 1px solid var(--border);
                 color: var(--text-primary); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }
.table-actions { display: flex; gap: 6px; }
td.right, th.right { text-align: right; }
td.mono        { font-family: var(--font-mono); font-size: 12.5px; }

/* --- Badges / Status ------------------------------------------------------- */
.badge         { display: inline-block; padding: 2px 9px; border-radius: 20px;
                 font-size: 11px; font-weight: 600; letter-spacing: .02em;
                 white-space: nowrap; }
.badge-blue    { background: #dbeafe; color: #1e40af; }
.badge-green   { background: #d1fae5; color: #065f46; }
.badge-yellow  { background: #fef3c7; color: #92400e; }
.badge-red     { background: #fee2e2; color: #991b1b; }
.badge-gray    { background: #f1f5f9; color: #475569; }
.badge-purple  { background: #ede9fe; color: #5b21b6; }
.badge-teal    { background: #ccfbf1; color: #134e4a; }

/* Job status badges */
.status-new          { @extend .badge; background:#f0f9ff; color:#0369a1; }
.status-approved     { background:#d1fae5; color:#065f46; }
.status-printing     { background:#dbeafe; color:#1e40af; }
.status-complete     { background:#f0fdf4; color:#166534; }
.status-on_hold      { background:#fef3c7; color:#92400e; }
.status-cancelled    { background:#fee2e2; color:#991b1b; }

/* --- Stats grid ------------------------------------------------------------ */
.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-lg); padding: 18px 20px; }
.stat-label    { font-size: 12px; font-weight: 600; text-transform: uppercase;
                 letter-spacing: .06em; color: var(--text-secondary); margin-bottom: 8px; }
.stat-value    { font-size: 26px; font-weight: 700; color: var(--text-primary); line-height: 1; }
.stat-sub      { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.stat-accent   { border-left: 3px solid var(--accent); }
.stat-success  { border-left: 3px solid var(--success); }
.stat-warning  { border-left: 3px solid var(--warning); }
.stat-danger   { border-left: 3px solid var(--danger); }

/* --- Alerts ---------------------------------------------------------------- */
.alert         { padding: 12px 16px; border-radius: var(--radius);
                 font-size: 13.5px; margin-bottom: 16px; }
.alert-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: #f0f9ff; color: #0c4a6e; border: 1px solid #bae6fd; }

/* --- Filters / Search bar -------------------------------------------------- */
.filters       { display: flex; gap: 10px; align-items: center;
                 margin-bottom: 16px; flex-wrap: wrap; }
.filters input[type=search], .filters select {
    width: auto; min-width: 160px; }
.filter-label  { font-size: 13px; color: var(--text-secondary); }

/* --- Pagination ------------------------------------------------------------ */
.pagination    { display: flex; gap: 4px; align-items: center;
                 justify-content: center; margin-top: 20px; }
.pagination a, .pagination span {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: var(--radius);
    font-size: 13px; border: 1px solid var(--border); color: var(--text-primary); }
.pagination a:hover { background: var(--bg); text-decoration: none; }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }

/* --- Login page ------------------------------------------------------------ */
.login-body    { background: var(--sidebar-bg); display: flex;
                 align-items: center; justify-content: center; min-height: 100vh; }
.login-wrap    { width: 100%; max-width: 400px; padding: 20px; }
.login-logo    { text-align: center; margin-bottom: 24px;
                 display: flex; align-items: center; justify-content: center; gap: 10px; }
.login-logo .logo-mark { font-size: 18px; padding: 6px 12px; }
.login-logo .logo-text { color: #fff; font-size: 22px; font-weight: 700; }
.login-card    { background: var(--surface); border-radius: var(--radius-lg);
                 padding: 32px; box-shadow: var(--shadow-md); }
.login-card h1 { font-size: 20px; margin-bottom: 20px; }
.login-footer  { text-align: center; font-size: 12px; color: #4a5568; margin-top: 20px; }

/* --- Misc ------------------------------------------------------------------ */
.empty-state   { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state h3 { font-size: 16px; margin-bottom: 8px; color: var(--text-secondary); }
.divider       { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.text-muted    { color: var(--text-muted); }
.text-right    { text-align: right; }
.text-center   { text-align: center; }
.mt-4          { margin-top: 16px; }
.mb-4          { margin-bottom: 16px; }
.flex          { display: flex; }
.gap-2         { gap: 8px; }
.items-center  { align-items: center; }
.justify-between { justify-content: space-between; }
code           { font-family: var(--font-mono); font-size: 12px;
                 background: var(--bg); padding: 2px 5px; border-radius: 3px; }

/* --- Responsive ------------------------------------------------------------ */
@media (max-width: 768px) {
    .sidebar       { transform: translateX(-100%); }
    .sidebar.open  { transform: translateX(0); }
    .main-content  { margin-left: 0; padding: 16px; }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .stats-grid    { grid-template-columns: 1fr 1fr; }
}
