/* ============================================================
   Alfa LMS – app.css
   ============================================================ */

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

:root {
    --primary:     #1a3c6e;
    --primary-lt:  #2456a4;
    --accent:      #e8a020;
    --success:     #27ae60;
    --danger:      #c0392b;
    --warning:     #e67e22;
    --info:        #2980b9;
    --text:        #1a1a2e;
    --text-muted:  #6b7280;
    --bg:          #f4f6fb;
    --bg2:         #eef0f5;
    --border:      #d1d5db;
    --white:       #ffffff;
    --sidebar-w:   220px;
    --navbar-h:    56px;
    --radius:      8px;
    --shadow:      0 1px 4px rgba(0,0,0,.10);
}

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

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

/* ---- Navbar ---------------------------------------------- */
.navbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    height: var(--navbar-h);
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.navbar-brand { display: flex; align-items: center; gap: .6rem; font-size: 1rem; font-weight: 700; color: #fff; }
.navbar-logo  { font-size: 1.2rem; color: var(--accent); }
.navbar-right { display: flex; align-items: center; gap: 1rem; }
.navbar-user  { font-size: .85rem; color: #c8d6ec; display: flex; align-items: center; gap: .4rem; }

/* ---- Layout ---------------------------------------------- */
.layout {
    display: flex;
    min-height: 100vh;
    padding-top: var(--navbar-h);
}

/* ---- Sidebar --------------------------------------------- */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: #0f2548;
    min-height: calc(100vh - var(--navbar-h));
    position: sticky;
    top: var(--navbar-h);
    overflow-y: auto;
}
.sidebar-nav { padding: 1rem 0; }
.nav-item {
    display: block;
    padding: .6rem 1.25rem;
    color: #a8bcd6;
    font-size: .875rem;
    text-decoration: none;
    transition: background .15s, color .15s;
}
.nav-item:hover, .nav-item.active {
    background: rgba(255,255,255,.08);
    color: #fff;
    text-decoration: none;
}
.nav-divider { border-top: 1px solid rgba(255,255,255,.08); margin: .5rem 0; }

/* ---- Main content --------------------------------------- */
.main-content {
    flex: 1;
    padding: 1.5rem;
    min-width: 0;
}

/* ---- Page header ---------------------------------------- */
.page-header { margin-bottom: 1.25rem; }
.page-title  { font-size: 1.4rem; font-weight: 600; color: var(--primary); }

/* ---- Cards ---------------------------------------------- */
.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
    overflow: hidden;
}
.card-header {
    padding: .875rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fafbfc;
}
.card-header h2, .card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
}
.card-footer {
    background: #fafbfc;
    border-top: 1px solid var(--border);
}

/* ---- Stats grid ---------------------------------------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.stat-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1rem;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--border);
    min-width: 0;
    overflow: hidden;
}
.stat-card.stat-warning { border-left-color: var(--warning); }
.stat-card.stat-success { border-left-color: var(--success); }
.stat-card.stat-info    { border-left-color: var(--info); }
.stat-card.stat-danger  { border-left-color: var(--danger); }
.stat-card.stat-primary { border-left-color: var(--primary); }
.stat-number { font-size: 1.6rem; font-weight: 700; color: var(--primary); word-break: break-word; overflow-wrap: anywhere; line-height: 1.2; }
.stat-label  { font-size: .8rem; color: var(--text-muted); margin-top: .3rem; }
.stat-link   { font-size: .78rem; color: var(--primary-lt); display: inline-block; margin-top: .4rem; }

/* ---- Tables -------------------------------------------- */
.table-responsive { overflow-x: auto; }
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}
.table thead th {
    background: #f0f3f9;
    color: var(--primary);
    font-weight: 600;
    padding: .6rem .875rem;
    text-align: left;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.table tbody td {
    padding: .6rem .875rem;
    border-bottom: 1px solid #eef0f5;
    vertical-align: middle;
}
.table tbody tr:hover td { background: #f7f9ff; }
.table tbody tr:last-child td { border-bottom: none; }
.row-muted td { opacity: .55; }
.row-danger td { background: #fef2f2; }

/* ---- Badges -------------------------------------------- */
.badge {
    display: inline-block;
    padding: .2em .6em;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
    line-height: 1;
}
.badge-success   { background: #d1fae5; color: #065f46; }
.badge-danger    { background: #fee2e2; color: #991b1b; }
.badge-warning   { background: #fef3c7; color: #92400e; }
.badge-info      { background: #dbeafe; color: #1e40af; }
.badge-primary   { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: #f3f4f6; color: #374151; }

/* ---- Buttons ------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .45rem 1rem;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: opacity .15s, background .15s;
    white-space: nowrap;
    line-height: 1.4;
}
.btn:hover { opacity: .88; text-decoration: none; }
.btn-primary  { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-success  { background: var(--success); color: #fff; border-color: var(--success); }
.btn-danger   { background: var(--danger);  color: #fff; border-color: var(--danger); }
.btn-warning  { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-outline  { background: transparent; color: var(--primary); border-color: var(--border); }
.btn-outline:hover { background: var(--bg2); }
.navbar .btn-outline { color: #fff; border-color: rgba(255,255,255,.4); }
.navbar .btn-outline:hover { background: rgba(255,255,255,.12); }
.btn-sm  { padding: .3rem .7rem; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; }

/* ---- Forms --------------------------------------------- */
.form-group  { margin-bottom: 1rem; }
.form-row    { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 180px; }
.form-group label { display: block; font-weight: 500; margin-bottom: .35rem; font-size: .875rem; }
.form-control {
    width: 100%;
    padding: .5rem .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .875rem;
    font-family: inherit;
    background: var(--white);
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary-lt);
    box-shadow: 0 0 0 3px rgba(36,86,164,.15);
}
textarea.form-control { resize: vertical; }
.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: .25rem; }
.form-actions { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.form-section { padding: 1.25rem; border-bottom: 1px solid var(--bg2); }
.form-section:last-of-type { border-bottom: none; }
.form-section-title { font-size: .95rem; font-weight: 600; color: var(--primary); margin-bottom: 1rem; }
.checkbox-group { display: flex; flex-direction: column; gap: .6rem; }
.checkbox-label { display: flex; align-items: center; gap: .5rem; cursor: pointer; font-size: .875rem; }
.checkbox-label input { width: 16px; height: 16px; }

/* ---- Alerts -------------------------------------------- */
.alert {
    padding: .75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: .875rem;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .5rem;
}
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-error,
.alert-danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.alert-close   { background: none; border: none; cursor: pointer; font-size: 1rem; line-height: 1; color: inherit; flex-shrink: 0; }

/* ---- Filter bar ---------------------------------------- */
.filter-bar  { display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1rem; }
.filter-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-end; flex: 1; }
.filter-form .form-control { width: auto; flex: 1; min-width: 140px; }

/* ---- Modals -------------------------------------------- */
.modal-overlay {
    position: fixed; inset: 0; z-index: 500;
    background: rgba(0,0,0,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-box {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0,0,0,.2);
    width: 100%; max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; font-weight: 600; color: var(--primary); }
.modal-close { background: none; border: none; font-size: 1.1rem; cursor: pointer; color: var(--text-muted); }
.modal-box form { padding: 1.25rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }

/* ---- Auth page ----------------------------------------- */
body.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-card {
    width: 100%; max-width: 400px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: 0 4px 24px rgba(0,0,0,.1);
}
.auth-header { text-align: center; margin-bottom: 1.5rem; }
.auth-logo   { font-size: 2rem; color: var(--accent); margin-bottom: .5rem; }
.auth-header h1 { font-size: 1.2rem; font-weight: 700; color: var(--primary); }
.auth-header p  { color: var(--text-muted); font-size: .875rem; margin-top: .25rem; }
.auth-card .btn-block { margin-top: .25rem; }

/* ---- Detail view --------------------------------------- */
.detail-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1rem; flex-wrap: wrap; gap: .5rem;
}
.detail-actions { display: flex; gap: .5rem; }
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}
.lab-number-badge {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    padding: .2rem .6rem;
    border-radius: 4px;
    font-family: monospace;
    font-size: .9rem;
    margin-right: .5rem;
}
.detail-list { padding: .75rem 1rem; }
.detail-list dt { font-size: .78rem; text-transform: uppercase; color: var(--text-muted); letter-spacing: .04em; margin-top: .75rem; }
.detail-list dt:first-child { margin-top: 0; }
.detail-list dd { font-size: .9rem; margin-top: .15rem; }

/* ---- Check list ---------------------------------------- */
.check-list { list-style: none; padding: .75rem 1rem; }
.check-list li { padding: .35rem 0; font-size: .875rem; }
.check-list .checked::before   { content: '✓ '; color: var(--success); font-weight: 700; }
.check-list .unchecked::before { content: '✗ '; color: var(--border); }

/* ---- Pagination ---------------------------------------- */
.pagination { display: flex; gap: .35rem; padding: .75rem 1rem; flex-wrap: wrap; }
.page-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px;
    border-radius: 4px;
    border: 1px solid var(--border);
    font-size: .825rem;
    color: var(--text);
    text-decoration: none;
}
.page-btn:hover { background: var(--bg2); text-decoration: none; }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---- Misc ---------------------------------------------- */
.text-muted   { color: var(--text-muted); }
.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }
.text-center  { text-align: center; }
.empty-state  { text-align: center; padding: 3rem 1rem; color: var(--text-muted); font-size: 1rem; }
.inline-form  { display: inline; }
.action-col   { display: flex; gap: .35rem; align-items: center; }
code          { font-family: monospace; background: #f3f4f6; padding: .1em .35em; border-radius: 3px; font-size: .85rem; }

/* ---- Sample review card -------------------------------- */
.sample-review-card { margin-bottom: 1rem; }

/* ---- App footer ---------------------------------------- */
.app-footer {
    text-align: center;
    padding: 1rem;
    font-size: .78rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    margin-top: 1rem;
}

/* ---- Responsive ---------------------------------------- */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .form-row { flex-direction: column; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
}
