/* Floor Stock Inspection System — Dr. Samir Abbas Hospital theme
   Brand palette & typography extracted from dsah.sa:
   green #2b925d · light green #a7e3c4 · red #c72f28 · ink #252525
   Fonts: Montserrat (UI) + Playfair Display (headings) — as on dsah.sa */

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&family=Playfair+Display:wght@600;700&family=Tajawal:wght@400;500;700&display=swap');

:root {
    --bg: #f6f8f7;
    --card: #ffffff;
    --ink: #252525;
    --muted: #6f7d75;
    --line: #e2e9e4;
    --primary: #2b925d;          /* DSAH green */
    --primary-dark: #23744a;
    --primary-light: #a7e3c4;
    --primary-tint: #eaf6ef;
    --danger: #c72f28;           /* DSAH red (logo heart) */
    --warn: #d98300;
    --ok: #2b925d;
    --info: #2a90ef;
    --shadow: 0 1px 3px rgba(37,37,37,.08), 0 1px 2px rgba(37,37,37,.04);
    --font-ui: 'Montserrat', 'Tajawal', 'Segoe UI', Arial, sans-serif;
    --font-head: 'Playfair Display', 'Tajawal', Georgia, serif;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: var(--font-ui);
    color: var(--ink);
    background: var(--bg);
    font-size: 14.5px;
    line-height: 1.55;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-family: var(--font-head); font-size: 1.6rem; margin: 0 0 .25rem; color: var(--ink); }
h2 { font-family: var(--font-head); font-size: 1.2rem; margin: 1.5rem 0 .6rem; color: var(--primary-dark); }
h3 { margin: 0; font-size: 1rem; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: .85em; }

/* ---- Top bar (DSAH green header) ---- */
.topbar {
    display: flex; align-items: center; gap: 1.25rem;
    background: var(--primary); color: #fff;
    padding: 0 1.25rem; height: 62px;
    box-shadow: 0 2px 8px rgba(43,146,93,.28);
}
.brand { display: flex; align-items: center; gap: .65rem; font-weight: 600; font-size: .98rem; }
.brand img { height: 40px; width: auto; display: block; }
.brand .brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand .brand-sub { font-size: .68rem; font-weight: 500; color: #d9f2e4; letter-spacing: .04em; text-transform: uppercase; }
.mainnav { display: flex; gap: .15rem; margin-left: .75rem; flex: 1; }
.mainnav a {
    color: #eafaf1; padding: .45rem .75rem; border-radius: 0;
    font-weight: 500; font-size: .88rem; position: relative;
}
.mainnav a::after {
    content: ""; position: absolute; left: 12%; right: 88%; bottom: 2px; height: 3px;
    background: #fff; border-radius: 2px; transition: right .35s cubic-bezier(.77,0,.175,1);
}
.mainnav a:hover { text-decoration: none; color: #fff; }
.mainnav a:hover::after { right: 12%; }
.userbox { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.userbox .uname { font-weight: 600; font-size: .88rem; }
.userbox .urole { font-size: .72rem; color: #d9f2e4; }
.userbox .logout { color: #fff; font-size: .78rem; margin-top: 2px; text-decoration: underline; }

.container { max-width: 1080px; margin: 1.5rem auto; padding: 0 1.25rem; }
.sitefoot {
    text-align: center; color: var(--muted); font-size: .78rem; padding: 2rem 0 1.1rem;
    border-top: 1px solid var(--line); margin-top: 2rem; background: #fff;
}
.sitefoot .foot-hospital { display: block; font-weight: 600; color: var(--primary-dark); margin-bottom: .15rem; }

.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; margin-bottom: .5rem; }
.page-head h1 { flex: 0 0 auto; }
.page-head .muted { width: 100%; margin: 0; }
.head-actions { margin-left: auto; display: flex; gap: .5rem; }
.back { font-size: .85rem; }

/* ---- Buttons ---- */
.btn {
    display: inline-block; padding: .52rem 1.05rem; border-radius: 999px;
    border: 1px solid transparent; font-size: .86rem; font-weight: 600;
    cursor: pointer; text-align: center; line-height: 1.2; background: #fff;
    font-family: var(--font-ui); transition: background .2s, color .2s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-light { background: #fff; color: var(--primary-dark); border-color: var(--primary-light); }
.btn-light:hover { background: var(--primary-tint); }
.btn-danger { background: #fff; color: var(--danger); border-color: #e8b6b3; }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { padding: .3rem .7rem; font-size: .78rem; }

/* ---- Cards / stat grid ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1.1rem 1.25rem; box-shadow: var(--shadow); margin-bottom: 1rem; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 1rem; margin: 1rem 0 1.5rem; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-left-width: 5px; border-radius: 12px; padding: 1rem 1.2rem; box-shadow: var(--shadow); }
.stat-card:hover { text-decoration: none; transform: translateY(-1px); }
.stat-card .stat-num { font-family: var(--font-head); font-size: 2.1rem; font-weight: 700; line-height: 1; }
.stat-card .stat-label { color: var(--muted); font-size: .82rem; margin-top: .35rem; font-weight: 500; }
.stat-card.danger { border-left-color: var(--danger); }
.stat-card.danger .stat-num { color: var(--danger); }
.stat-card.warn { border-left-color: var(--warn); }
.stat-card.warn .stat-num { color: var(--warn); }
.stat-card.info { border-left-color: var(--primary); }
.stat-card.info .stat-num { color: var(--primary); }

/* ---- Unit cards ---- */
.unit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px,1fr)); gap: 1rem; }
.unit-card {
    background: var(--card); border: 1px solid var(--line); border-top: 4px solid var(--primary);
    border-radius: 12px; padding: 1rem 1.1rem; box-shadow: var(--shadow);
    display: flex; flex-direction: column; gap: .5rem;
}
.unit-card-head { display: flex; justify-content: space-between; align-items: baseline; }
.due-row { display: flex; align-items: center; gap: .5rem; font-size: .85rem; }
.due-label { flex: 1; color: var(--ink); }
.unit-alert { background: #fdf1f0; color: #a02c26; border: 1px solid #f0c9c6; border-radius: 8px; padding: .35rem .6rem; font-size: .83rem; }
.unit-ok { background: var(--primary-tint); color: var(--primary-dark); border: 1px solid var(--primary-light); border-radius: 8px; padding: .35rem .6rem; font-size: .83rem; }
.unit-actions { display: flex; gap: .5rem; margin-top: auto; padding-top: .3rem; }

/* ---- Tables ---- */
.data-table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); font-size: .88rem; }
.data-table th, .data-table td { padding: .55rem .7rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table thead th {
    background: var(--primary); color: #fff;
    font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600;
}
.data-table tbody tr:nth-child(even) { background: #fafcfb; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .num { text-align: right; white-space: nowrap; }
.row-expired { background: #fdf1f0 !important; }
.row-near { background: #fff9ec !important; }
.row-actions { display: flex; gap: .4rem; align-items: center; }
.row-actions form { margin: 0; }

/* ---- Badges & pills ---- */
.badge { display: inline-block; padding: .16rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 600; white-space: nowrap; }
.badge-expired { background: #f7dedc; color: #a02c26; }
.badge-near { background: #fdeecd; color: #9a6a00; }
.badge-ok { background: #d3efdf; color: #1d6b43; }
.badge-unknown { background: #e6e9e7; color: #55605a; }
.pill { display: inline-block; padding: .16rem .6rem; border-radius: 999px; font-size: .76rem; font-weight: 600; }
.pill-pharmacist { background: #d3efdf; color: #1d6b43; }
.pill-nurse { background: #e3edfb; color: #1c5fae; }

.sec-danger { color: var(--danger); }
.sec-warn { color: #9a6a00; }
.sec-info { color: var(--primary-dark); }

/* ---- Flash ---- */
.flash { padding: .7rem 1rem; border-radius: 10px; margin: .75rem 0; font-size: .88rem; }
.flash.success { background: var(--primary-tint); color: var(--primary-dark); border: 1px solid var(--primary-light); }
.flash.error { background: #fdf1f0; color: #a02c26; border: 1px solid #f0c9c6; }

/* ---- Forms ---- */
label { display: block; font-size: .83rem; color: #3c463f; font-weight: 500; margin-bottom: .6rem; }
input[type=text], input[type=password], input[type=number], input[type=month], select, textarea {
    width: 100%; padding: .48rem .65rem; border: 1px solid #c6d4cb; border-radius: 8px;
    font-size: .9rem; font-family: var(--font-ui); margin-top: .2rem; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-light); border-color: var(--primary); }
.grid-form { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 1rem; }
.grid-form .wide { grid-column: 1 / -1; }
.grid-form .form-actions { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: .5rem; }
.filter-bar { margin-left: auto; }
.filter-bar label { margin: 0; }

.inspect-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 1rem; }
.inspect-table input.qty-in { width: 70px; }
.inspect-table input.exp-in { width: 140px; }
.inspect-table input.note-in { width: 100%; min-width: 120px; }
.inspect-table td { vertical-align: middle; }

.unit-scope legend { font-weight: 600; font-size: .85rem; padding: 0 .3rem; }
.unit-scope { border: 1px solid var(--line); border-radius: 10px; padding: .6rem .8rem; }
label.inline { display: inline-flex; align-items: center; gap: .35rem; font-weight: 400; margin: .2rem .8rem .2rem 0; }
label.inline input { width: auto; margin: 0; }
.unit-checks { margin-top: .4rem; }

/* ---- Login (DSAH-branded) ---- */
.login-body {
    display: flex; align-items: center; justify-content: center; min-height: 100vh;
    background: linear-gradient(150deg, #2b925d 0%, #23744a 55%, #194f34 100%);
    font-family: var(--font-ui);
}
.login-card { background: #fff; border-radius: 16px; padding: 2rem 2.2rem; width: 400px; box-shadow: 0 16px 48px rgba(10,40,25,.35); }
.login-head { text-align: center; margin-bottom: 1.25rem; }
.login-head .login-logo { max-width: 240px; height: auto; margin-bottom: .8rem; }
.login-head h1 { font-family: var(--font-head); font-size: 1.22rem; margin: .3rem 0 .1rem; }
.login-head p { color: var(--muted); margin: 0; font-size: .83rem; }
.login-form label { margin-bottom: .9rem; }

/* ---- Record / print sheet ---- */
.record-sheet { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 1.5rem; box-shadow: var(--shadow); }
.record-brand { display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-bottom: 3px solid var(--primary); padding-bottom: .8rem; margin-bottom: 1rem; }
.record-brand img { height: 48px; width: auto; }
.record-brand .record-title { text-align: right; }
.record-brand .record-title h1 { font-size: 1.25rem; margin: 0; }
.record-brand .record-title .muted { font-size: .8rem; }
.record-brand .record-title .form-code {
    display: inline-block; margin-top: .25rem; padding: .1rem .55rem;
    border: 1px solid var(--primary); border-radius: 6px;
    color: var(--primary-dark); font-size: .78rem; font-weight: 600; letter-spacing: .04em;
}
.seal-card { border-left: 4px solid var(--danger); }
.seal-card .seal-label b { color: var(--danger); }
.record-meta td.seal-num { font-weight: 700; letter-spacing: .05em; }
.record-meta { border-collapse: collapse; margin: .5rem 0 1rem; font-size: .88rem; }
.record-meta th { text-align: left; padding: .25rem 1rem .25rem 0; color: var(--muted); font-weight: 600; }
.record-meta td { padding: .25rem 2rem .25rem 0; }
.sign-row { display: flex; gap: 3rem; margin-top: 2.5rem; }
.sign-box { flex: 1; }
.sign-line { border-bottom: 1px solid #252525; padding: .4rem .2rem; min-height: 1.6rem; }
.sign-label { font-size: .8rem; color: var(--muted); margin-top: .3rem; }
.print-toolbar { display: flex; justify-content: space-between; padding: 1rem; max-width: 1000px; margin: 0 auto; }
.print-page { background: #fff; }
.print-page .record-sheet { max-width: 1000px; margin: 0 auto 2rem; border: none; box-shadow: none; }

@media print {
    .topbar, .sitefoot, .no-print, .head-actions, .print-toolbar { display: none !important; }
    body { background: #fff; }
    .container { margin: 0; max-width: none; }
    .record-sheet { border: none; box-shadow: none; padding: 0; }
    .data-table { box-shadow: none; }
    .data-table thead th { background: #eef4f0 !important; color: #252525 !important; -webkit-print-color-adjust: exact; }
}

@media (max-width: 640px) {
    .grid-form, .inspect-meta { grid-template-columns: 1fr; }
    .mainnav { display: none; }
    .topbar { gap: .75rem; }
    .brand .brand-text { display: none; }
}
