/* =============================================
   NYANDARUA COUNTY INVENTORY SYSTEM
   Main Stylesheet
   ============================================= */

:root {
    --green-dark: #1a4731;
    --green-mid:  #2d7a4f;
    --green-light:#3fa066;
    --gold:       #c89b2a;
    --gold-light: #f0c040;
    --red:        #c0392b;
    --red-light:  #e74c3c;
    --bg:         #f5f6fa;
    --surface:    #ffffff;
    --surface2:   #f0f2f7;
    --border:     #dde1eb;
    --text:       #1a2233;
    --text-muted: #6b7494;
    --sidebar-w:  260px;
    --topbar-h:   58px;
    --radius:     8px;
    --shadow:     0 2px 12px rgba(0,0,0,.08);
    --shadow-md:  0 4px 24px rgba(0,0,0,.12);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--green-mid); text-decoration: none; }
a:hover { color: var(--green-dark); }

/* ---- TOPBAR ---- */
.topbar {
    position: fixed; top: 0; left: 0; right: 0;
    height: var(--topbar-h); z-index: 200;
    background: var(--green-dark);
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 100%; padding: 0 1.2rem; }
.topbar-left  { display: flex; align-items: center; gap: .8rem; }
.topbar-title { color: #fff; font-weight: 700; font-size: 1.05rem; letter-spacing: .02em; }
.sidebar-toggle { background: none; border: none; color: #fff; font-size: 1.1rem; cursor: pointer; padding: .3rem .5rem; border-radius: 4px; }
.sidebar-toggle:hover { background: rgba(255,255,255,.15); }
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.topbar-dept  { color: rgba(255,255,255,.75); font-size: .85rem; }
.user-btn { background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2); color: #fff; padding: .4rem .9rem; border-radius: 20px; cursor: pointer; font-size: .9rem; display: flex; align-items: center; gap: .4rem; }
.user-btn:hover { background: rgba(255,255,255,.22); }
.dropdown { position: relative; }
.dropdown-menu { display: none; position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); min-width: 160px; z-index: 300; }
.dropdown-menu a { display: flex; align-items: center; gap: .6rem; padding: .65rem 1rem; color: var(--text); font-size: .9rem; }
.dropdown-menu a:hover { background: var(--surface2); }
.dropdown.open .dropdown-menu { display: block; }

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

/* ---- SIDEBAR ---- */
.sidebar {
    width: var(--sidebar-w); flex-shrink: 0;
    position: fixed; top: var(--topbar-h); left: 0; bottom: 0;
    background: var(--surface); border-right: 1px solid var(--border);
    overflow-y: auto; z-index: 100;
    transition: transform .25s ease;
    display: flex; flex-direction: column;
}
.sidebar-brand { display: flex; align-items: center; gap: .8rem; padding: 1.1rem 1rem; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.brand-logo { width: 38px; height: 38px; background: var(--green-dark); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--gold); font-size: 1.1rem; flex-shrink: 0; }
.brand-name { font-weight: 700; font-size: .95rem; color: var(--text); display: block; }
.brand-sub  { font-size: .73rem; color: var(--text-muted); display: block; }
.sidebar-nav { flex: 1; padding: .5rem 0; }
.nav-section { padding: .5rem 0; }
.nav-label { display: block; padding: .4rem 1rem .2rem; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); }
.nav-link { display: flex; align-items: center; gap: .7rem; padding: .55rem 1rem; color: var(--text-muted); font-size: .9rem; transition: background .15s, color .15s; border-left: 3px solid transparent; }
.nav-link i { width: 18px; text-align: center; font-size: .95rem; }
.nav-link:hover { background: var(--surface2); color: var(--green-dark); }
.nav-link.active { background: #e8f5ee; color: var(--green-dark); border-left-color: var(--green-mid); font-weight: 600; }
.sidebar-footer { padding: .8rem 1rem; border-top: 1px solid var(--border); color: var(--text-muted); font-size: .72rem; line-height: 1.5; flex-shrink: 0; }

/* ---- MAIN CONTENT ---- */
.main-content { flex: 1; margin-left: var(--sidebar-w); min-width: 0; }
.content-inner { padding: 1.5rem; max-width: 1300px; }

/* ---- PAGE HEADER ---- */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.4rem; font-weight: 700; color: var(--text); }
.page-header .breadcrumb { font-size: .82rem; color: var(--text-muted); margin-top: .2rem; }
.page-header .breadcrumb a { color: var(--green-mid); }

/* ---- CARDS ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { padding: .9rem 1.2rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem; }
.card-title { font-weight: 600; font-size: 1rem; color: var(--text); }
.card-body { padding: 1.2rem; }

/* ---- STAT CARDS ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.2rem; display: flex; align-items: center; gap: 1rem; box-shadow: var(--shadow); }
.stat-icon { width: 48px; height: 48px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; flex-shrink: 0; }
.stat-icon.green { background: #e8f5ee; color: var(--green-mid); }
.stat-icon.gold  { background: #fdf6e3; color: var(--gold); }
.stat-icon.red   { background: #fdecea; color: var(--red); }
.stat-icon.blue  { background: #e8f0fe; color: #1a73e8; }
.stat-label { font-size: .8rem; color: var(--text-muted); }
.stat-value { font-size: 1.55rem; font-weight: 700; color: var(--text); line-height: 1.1; }

/* ---- TABLES ---- */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
thead th { background: var(--surface2); color: var(--text-muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; padding: .65rem .9rem; text-align: left; border-bottom: 2px solid var(--border); }
tbody tr { border-bottom: 1px solid var(--border); transition: background .12s; }
tbody tr:hover { background: var(--surface2); }
tbody td { padding: .65rem .9rem; vertical-align: middle; }
.td-muted { color: var(--text-muted); font-size: .85rem; }

/* ---- BADGES ---- */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .55rem; border-radius: 12px; font-size: .75rem; font-weight: 600; }
.badge-success { background: #e8f5ee; color: #1a6635; }
.badge-warning { background: #fdf6e3; color: #8a6000; }
.badge-danger  { background: #fdecea; color: #a02020; }
.badge-info    { background: #e8f0fe; color: #1a57c0; }
.badge-gray    { background: #f0f2f7; color: var(--text-muted); }

/* ---- BUTTONS ---- */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem 1rem; border-radius: 6px; font-size: .9rem; font-weight: 500; cursor: pointer; border: none; transition: filter .15s, box-shadow .15s; }
.btn:hover { filter: brightness(.92); }
.btn-primary { background: var(--green-mid); color: #fff; }
.btn-success { background: var(--green-dark); color: #fff; }
.btn-warning { background: var(--gold); color: #fff; }
.btn-danger  { background: var(--red); color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-sm { padding: .3rem .7rem; font-size: .82rem; }
.btn-group { display: flex; gap: .4rem; flex-wrap: wrap; }

/* ---- FORMS ---- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: .35rem; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: .85rem; font-weight: 600; color: var(--text); }
input[type=text], input[type=email], input[type=number], input[type=password], input[type=date],
select, textarea {
    padding: .5rem .75rem; border: 1px solid var(--border); border-radius: 6px;
    font-size: .9rem; color: var(--text); background: var(--surface);
    width: 100%; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green-mid); box-shadow: 0 0 0 3px rgba(45,122,79,.12); }
textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: .78rem; color: var(--text-muted); }

/* ---- ALERTS / FLASH ---- */
.alert { padding: .75rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-size: .9rem; display: flex; align-items: flex-start; gap: .6rem; }
.alert-success { background: #e8f5ee; color: #1a5c30; border: 1px solid #b2d8bf; }
.alert-danger   { background: #fdecea; color: #8b1a1a; border: 1px solid #f5b4b0; }
.alert-warning  { background: #fdf6e3; color: #7a5000; border: 1px solid #f0d080; }
.alert-info     { background: #e8f0fe; color: #1a3c8a; border: 1px solid #b0c8f8; }

/* ---- FILTERS BAR ---- */
.filters-bar { display: flex; align-items: center; flex-wrap: wrap; gap: .6rem; padding: .8rem 1.2rem; background: var(--surface2); border-bottom: 1px solid var(--border); }
.filters-bar input[type=text], .filters-bar select { width: auto; min-width: 160px; }
.search-input { position: relative; }
.search-input input { padding-left: 2rem; }
.search-input i { position: absolute; left: .65rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: .85rem; }

/* ---- PAGINATION ---- */
.pagination { display: flex; align-items: center; gap: .3rem; margin-top: 1rem; flex-wrap: wrap; }
.pagination a, .pagination span { padding: .35rem .7rem; border: 1px solid var(--border); border-radius: 5px; font-size: .85rem; color: var(--text-muted); }
.pagination a:hover { background: var(--surface2); border-color: var(--green-mid); color: var(--green-mid); }
.pagination .current { background: var(--green-mid); color: #fff; border-color: var(--green-mid); }

/* ---- MODAL ---- */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 500; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-md); width: 90%; max-width: 560px; max-height: 90vh; overflow-y: auto; }
.modal-header { padding: 1rem 1.2rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text-muted); }
.modal-body { padding: 1.2rem; }
.modal-footer { padding: .9rem 1.2rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .5rem; }

/* ---- LOGIN ---- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--green-dark); padding: 1rem; }
.login-card { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-md); width: 100%; max-width: 420px; overflow: hidden; }
.login-header { background: linear-gradient(135deg, var(--green-dark), var(--green-mid)); padding: 2rem; text-align: center; color: #fff; }
.login-header .shield { font-size: 2.8rem; color: var(--gold-light); margin-bottom: .5rem; }
.login-header h1 { font-size: 1.15rem; font-weight: 700; }
.login-header p  { font-size: .82rem; opacity: .8; margin-top: .3rem; }
.login-body { padding: 2rem; }
.login-body .form-group { margin-bottom: 1rem; }
.login-footer { padding: .8rem; background: var(--surface2); text-align: center; font-size: .78rem; color: var(--text-muted); border-top: 1px solid var(--border); }

/* ---- STOCK LEVEL INDICATOR ---- */
.stock-bar { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; width: 80px; }
.stock-bar-fill { height: 100%; border-radius: 3px; }
.stock-bar-fill.ok    { background: var(--green-mid); }
.stock-bar-fill.low   { background: var(--gold); }
.stock-bar-fill.empty { background: var(--red); }

/* ---- RESPONSIVE ---- */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-md); }
    .main-content { margin-left: 0; }
    .topbar-dept { display: none; }
}
@media (max-width: 600px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .form-grid  { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; }
    .content-inner { padding: 1rem .75rem; }
}
@media print {
    .topbar, .sidebar, .btn, .filters-bar, .pagination { display: none !important; }
    .main-content { margin-left: 0; }
    .card { box-shadow: none; border: 1px solid #ccc; }
}
