﻿/* ============================================================
   AJMU MPEKETONI PHARMACY MANAGEMENT SYSTEM
   Responsive UI — v2
   ============================================================ */

/* ── Google Font ──────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --sidebar-width: 255px;
    --sidebar-bg: #0f1f3d;
    --sidebar-text: #94a3b8;
    --sidebar-active-bg: rgba(56,161,105,.15);
    --sidebar-active-border: #38a169;
    --primary: #38a169;
    --primary-dark: #2d7a54;
    --primary-light: #f0fdf4;
    --body-bg: #f1f5f9;
    --card-bg: #ffffff;
    --card-shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
    --card-radius: 16px;
    --navbar-h: 64px;
    --border-color: #e2e8f0;
    --text-main: #1e293b;
    --text-muted: #64748b;
}

/* ── Reset / Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    background: var(--body-bg);
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    color: var(--text-main);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }

/* ══════════════════════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════════════════════ */
#sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform .3s cubic-bezier(.4,0,.2,1);
    z-index: 1040;
    display: flex;
    flex-direction: column;
}
#sidebar::-webkit-scrollbar { width: 3px; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); }

.sidebar-brand {
    padding: 18px 16px 14px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}
.sidebar-brand .brand-icon {
    width: 42px; height: 42px; flex-shrink: 0;
    background: linear-gradient(135deg, #38a169, #1a6b40);
    border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    font-size: 19px; color: #fff;
    box-shadow: 0 4px 12px rgba(56,161,105,.35);
}
.sidebar-brand .brand-text { flex: 1; min-width: 0; }
.sidebar-brand h6 {
    color: #fff; font-size: 12.5px; font-weight: 700;
    margin: 0; line-height: 1.3;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-brand small { color: rgba(255,255,255,.33); font-size: 10px; display: block; }

.sidebar-nav { flex: 1; padding: 8px 0 14px; }
.nav-section-label {
    padding: 14px 18px 4px;
    font-size: 9.5px; font-weight: 700;
    letter-spacing: 2px; text-transform: uppercase;
    color: rgba(255,255,255,.22);
}

#sidebar .nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 18px;
    color: var(--sidebar-text);
    text-decoration: none; font-size: 13.5px; font-weight: 500;
    transition: all .18s ease;
    border-left: 3px solid transparent;
}
#sidebar .nav-link i { font-size: 14px; flex-shrink: 0; width: 18px; text-align: center; }
#sidebar .nav-link:hover { color: #fff; background: rgba(255,255,255,.05); border-left-color: rgba(56,161,105,.4); }
#sidebar .nav-link.active { color: #fff; background: var(--sidebar-active-bg); border-left-color: var(--sidebar-active-border); font-weight: 600; }

.sidebar-dev-credit {
    padding: 8px 16px 6px;
    text-align: center;
    font-size: 9.5px;
    color: rgba(255,255,255,.22);
    line-height: 1.7;
}
.sidebar-dev-credit a { color: rgba(56,161,105,.6); text-decoration: none; }

.sidebar-footer {
    padding: 10px 12px 12px;
    border-top: 1px solid rgba(255,255,255,.06);
    flex-shrink: 0;
}
.sidebar-footer .user-info {
    display: flex; align-items: center; gap: 10px;
    background: rgba(255,255,255,.05);
    border-radius: 12px;
    padding: 8px 10px;
}
.sidebar-footer .avatar {
    width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
    background: linear-gradient(135deg, var(--primary), #1a6b40);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 13px;
}
.sidebar-footer .u-name { color: #fff; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 110px; }
.sidebar-footer .u-role { color: rgba(255,255,255,.33); font-size: 10.5px; text-transform: capitalize; }

.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 1035;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* ══════════════════════════════════════════════════════════
   TOP NAVBAR
   ══════════════════════════════════════════════════════════ */
.top-navbar {
    position: sticky; top: 0; z-index: 100;
    height: var(--navbar-h);
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center;
    padding: 0 20px;
    gap: 12px;
    box-shadow: 0 1px 0 rgba(0,0,0,.04);
}
.top-navbar .sidebar-toggle-btn {
    display: none;
    background: none; border: none;
    width: 40px; height: 40px;
    border-radius: 10px;
    align-items: center; justify-content: center;
    font-size: 20px; color: var(--text-main);
    cursor: pointer;
    transition: background .15s;
    flex-shrink: 0;
}
.top-navbar .sidebar-toggle-btn:hover { background: #f1f5f9; }
.top-navbar .page-title-nav {
    flex: 1;
    font-size: 17px; font-weight: 700; color: var(--text-main);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.top-navbar .nav-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ══════════════════════════════════════════════════════════
   MAIN LAYOUT
   ══════════════════════════════════════════════════════════ */
#main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex; flex-direction: column;
}
.page-content { padding: 22px 24px; flex: 1; }

.system-footer {
    text-align: center;
    padding: 10px 24px 16px;
    font-size: 11px;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
}
.system-footer a { color: var(--primary); text-decoration: none; }

/* ══════════════════════════════════════════════════════════
   STAT CARDS
   ══════════════════════════════════════════════════════════ */
.stat-card {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    padding: 20px;
    box-shadow: var(--card-shadow);
    border: 1px solid rgba(0,0,0,.04);
    display: flex; align-items: center; gap: 16px;
    transition: transform .2s ease, box-shadow .2s ease;
    overflow: hidden;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(0,0,0,.1); }
.stat-card .stat-icon {
    width: 52px; height: 52px; border-radius: 14px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
}
.stat-card .stat-info { flex: 1; min-width: 0; }
.stat-card .stat-value { font-size: 28px; font-weight: 800; color: var(--text-main); line-height: 1.1; }
.stat-card .stat-label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; margin-top: 2px; }
.stat-card .stat-change { font-size: 11.5px; margin-top: 4px; }

/* ══════════════════════════════════════════════════════════
   CARDS
   ══════════════════════════════════════════════════════════ */
.card {
    border: 1px solid rgba(0,0,0,.05) !important;
    border-radius: var(--card-radius) !important;
    box-shadow: var(--card-shadow);
    background: var(--card-bg);
}
.card-header {
    background: #fff !important;
    border-bottom: 1px solid var(--border-color) !important;
    padding: 14px 20px !important;
    font-weight: 700; color: var(--text-main); font-size: 14.5px;
    border-radius: var(--card-radius) var(--card-radius) 0 0 !important;
    display: flex; align-items: center; gap: 8px;
}
.card-body { padding: 18px 20px; }

/* ══════════════════════════════════════════════════════════
   TABLES
   ══════════════════════════════════════════════════════════ */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table thead th {
    background: #f8fafc !important;
    color: #475569;
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .7px;
    border-top: none !important;
    padding: 11px 14px;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-color) !important;
}
.table tbody td {
    vertical-align: middle; font-size: 13.5px;
    padding: 10px 14px;
    border-color: #f1f5f9 !important;
    color: var(--text-main);
}
.table-hover tbody tr { transition: background .12s; }
.table-hover tbody tr:hover { background: #f8fafc !important; }
tr.row-low-stock { background: #fff7ed !important; }
tr.row-expired    { background: #fef2f2 !important; }

/* ══════════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════════ */
.btn { font-family: 'Inter', sans-serif; font-weight: 600; border-radius: 10px; transition: all .18s ease; }
.btn-primary { background: var(--primary) !important; border-color: var(--primary) !important; color: #fff !important; box-shadow: 0 2px 8px rgba(56,161,105,.3); }
.btn-primary:hover, .btn-primary:focus { background: var(--primary-dark) !important; border-color: var(--primary-dark) !important; box-shadow: 0 4px 14px rgba(56,161,105,.4); transform: translateY(-1px); }
.btn-icon { width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; font-size: 13.5px; }

/* ══════════════════════════════════════════════════════════
   FORMS
   ══════════════════════════════════════════════════════════ */
.form-control, .form-select {
    border-radius: 10px; border-color: #dde1e9;
    font-size: 13.5px; padding: .5rem .85rem;
    transition: border-color .18s, box-shadow .18s;
}
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(56,161,105,.12); }
.input-group-text { border-radius: 10px; border-color: #dde1e9; background: #f8fafc; }
.input-group > :not(:first-child) { border-radius: 0 10px 10px 0 !important; }
.input-group > :first-child { border-radius: 10px 0 0 10px !important; }

/* ══════════════════════════════════════════════════════════
   LOGIN PAGE
   ══════════════════════════════════════════════════════════ */
.login-wrapper {
    min-height: 100vh;
    background: linear-gradient(145deg, #0f1f3d 0%, #0d3320 55%, #1a6b40 100%);
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
    position: relative;
    overflow: hidden;
}
.login-wrapper::before {
    content: '';
    position: absolute;
    width: 500px; height: 500px; border-radius: 50%;
    background: rgba(56,161,105,.08);
    top: -150px; right: -150px;
    pointer-events: none;
}
.login-wrapper::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px; border-radius: 50%;
    background: rgba(56,161,105,.06);
    bottom: -100px; left: -100px;
    pointer-events: none;
}
.login-card {
    background: #fff; border-radius: 24px; padding: 40px 36px;
    width: 100%; max-width: 430px;
    box-shadow: 0 32px 80px rgba(0,0,0,.4);
    position: relative; z-index: 1;
}
.login-logo-icon {
    width: 70px; height: 70px;
    background: linear-gradient(135deg, #38a169, #0f1f3d);
    border-radius: 20px;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 14px;
    font-size: 30px; color: #fff;
    box-shadow: 0 10px 30px rgba(56,161,105,.4);
}
.login-card h4 { font-size: 20px; font-weight: 800; color: var(--text-main); }
.login-card .form-label { font-size: 12px; font-weight: 700; color: #475569; text-transform: uppercase; letter-spacing: .6px; margin-bottom: 6px; }
.login-card .btn-primary { padding: 13px; font-size: 15px; border-radius: 12px; letter-spacing: .3px; }
.login-footer-text { font-size: 11.5px; color: #94a3b8; }
.login-footer-text strong { color: var(--primary); }
.login-footer-text a { color: var(--primary); text-decoration: none; }

/* ══════════════════════════════════════════════════════════
   POS / CART
   ══════════════════════════════════════════════════════════ */
.pos-search-wrapper { position: relative; }
.pos-search-results {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0;
    background: #fff; border: 1px solid var(--border-color);
    border-radius: 14px; max-height: 320px; overflow-y: auto;
    z-index: 500; box-shadow: 0 16px 40px rgba(0,0,0,.15); display: none;
}
.search-item {
    padding: 12px 16px; cursor: pointer;
    border-bottom: 1px solid #f1f5f9; transition: background .12s;
    display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.search-item:hover { background: #f8fafc; }
.search-item:last-child { border-bottom: none; }
.search-item .item-name { font-weight: 600; font-size: 13.5px; }
.search-item .item-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }
.search-item .item-price { font-weight: 700; color: var(--primary); font-size: 14px; flex-shrink: 0; }

.cart-empty { text-align: center; padding: 44px 20px; color: #cbd5e1; }
.cart-empty i { font-size: 44px; display: block; margin-bottom: 10px; }
.cart-empty p { font-size: 13px; color: var(--text-muted); margin: 0; }

.qty-ctrl { display: flex; align-items: center; gap: 5px; }
.qty-ctrl .qty-btn {
    width: 28px; height: 28px; padding: 0;
    border-radius: 7px; font-size: 13px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border-color); background: #f8fafc; cursor: pointer;
    transition: all .15s;
}
.qty-ctrl .qty-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.qty-ctrl input[type=number] { width: 50px; text-align: center; border: 1px solid var(--border-color); border-radius: 7px; padding: 3px 4px; font-size: 13px; font-weight: 600; }
.qty-ctrl input[type=number]::-webkit-inner-spin-button { display: none; }

#staging-panel { animation: slideDown .2s ease; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
#stage-qty { max-width: 70px; }
#stage-qty::-webkit-inner-spin-button { display: none; }

.cart-summary { background: #f8fafc; border-radius: 14px; padding: 16px; border: 1px solid var(--border-color); }
.cart-summary-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; font-size: 13.5px; color: #475569; }
.cart-summary-row.grand { font-size: 20px; font-weight: 800; color: var(--primary); border-top: 2px solid var(--border-color); margin-top: 10px; padding-top: 12px; }

.pos-cart-sticky { position: sticky; top: calc(var(--navbar-h) + 16px); }
.pay-method:checked + .method-btn { background: var(--primary) !important; color: #fff !important; border-color: var(--primary) !important; }
.method-btn { transition: all .2s; border-radius: 10px !important; font-weight: 600; font-size: 13px; }
.method-btn:hover { background: var(--primary-light); border-color: var(--primary) !important; color: var(--primary); }

/* ══════════════════════════════════════════════════════════
   BADGES & INDICATORS
   ══════════════════════════════════════════════════════════ */
.badge { border-radius: 7px; font-weight: 600; font-size: 11px; padding: 3px 8px; }
.badge-stock-ok   { background: #dcfce7; color: #166534; }
.badge-stock-low  { background: #fef3c7; color: #92400e; }
.badge-stock-out  { background: #fee2e2; color: #991b1b; }
.badge-expired    { background: #fee2e2; color: #991b1b; }
.badge-expiring   { background: #fef3c7; color: #92400e; }
.badge-good       { background: #dcfce7; color: #166534; }
.stock-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; }
.dot-ok  { background: #22c55e; }
.dot-low { background: #f59e0b; }
.dot-out { background: #ef4444; }

/* ══════════════════════════════════════════════════════════
   RECEIPT
   ══════════════════════════════════════════════════════════ */
.receipt-wrapper { max-width: 420px; margin: 0 auto; background: #fff; border-radius: var(--card-radius); box-shadow: var(--card-shadow); padding: 28px; font-family: 'Courier New', monospace; }
.receipt-header { text-align: center; padding-bottom: 14px; border-bottom: 2px dashed #ddd; margin-bottom: 14px; }
.receipt-footer { text-align: center; border-top: 2px dashed #ddd; padding-top: 14px; margin-top: 14px; font-size: 12px; color: #6b7280; }
.receipt-row { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; }
.receipt-total { font-size: 16px; font-weight: 700; border-top: 1px solid #ddd; padding-top: 8px; margin-top: 8px; }

/* ══════════════════════════════════════════════════════════
   ALERTS
   ══════════════════════════════════════════════════════════ */
.alert { border-radius: 12px; border: none; font-size: 13.5px; }
.alert-danger  { background: #fef2f2; color: #991b1b; }
.alert-success { background: #f0fdf4; color: #166534; }
.alert-warning { background: #fffbeb; color: #92400e; }
.alert-expiry-card { border-left: 4px solid #f87171; background: linear-gradient(135deg, #fff5f5, #fff); border-radius: 12px; }

/* Charts */
.chart-wrapper { position: relative; height: 280px; }

/* ══════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ══════════════════════════════════════════════════════════ */

@media (max-width: 991.98px) {
    .top-navbar .sidebar-toggle-btn { display: flex; }
}

@media (min-width: 1400px) {
    .page-content { padding: 28px 32px; }
}

@media (max-width: 1199.98px) and (min-width: 992px) {
    :root { --sidebar-width: 230px; }
    .sidebar-brand h6 { font-size: 12px; }
    #sidebar .nav-link { font-size: 13px; padding: 9px 16px; }
    .stat-card .stat-value { font-size: 24px; }
}

@media (max-width: 991.98px) {
    #sidebar { transform: translateX(calc(-1 * var(--sidebar-width))); box-shadow: none; }
    #sidebar.open { transform: translateX(0); box-shadow: 6px 0 32px rgba(0,0,0,.3); }
    #main-content { margin-left: 0 !important; }
    .page-content { padding: 16px; }
    .top-navbar { padding: 0 14px; gap: 8px; }
    .top-navbar .page-title-nav { font-size: 15px; }
    .chart-wrapper { height: 210px; }
    .pos-cart-sticky { position: sticky; top: calc(var(--navbar-h) + 10px); }
}

@media (max-width: 767.98px) {
    :root { --sidebar-width: 290px; --navbar-h: 58px; }
    .page-content { padding: 12px; }
    .top-navbar { padding: 0 12px; gap: 6px; height: var(--navbar-h); }
    .top-navbar .page-title-nav { font-size: 14.5px; max-width: 160px; }
    .stat-card { padding: 14px; gap: 12px; }
    .stat-card .stat-icon { width: 44px; height: 44px; font-size: 18px; border-radius: 11px; }
    .stat-card .stat-value { font-size: 22px; }
    .stat-card .stat-label { font-size: 11.5px; }
    .card-body { padding: 14px 16px; }
    .card-header { padding: 12px 16px !important; font-size: 13.5px; }
    .table thead th { font-size: 10.5px; padding: 9px 10px; }
    .table tbody td { font-size: 13px; padding: 9px 10px; }
    .chart-wrapper { height: 180px; }
    .pos-cart-sticky { position: static; }
    #staging-panel .col-sm-4 { flex: 0 0 50%; max-width: 50%; }
    .cart-summary { padding: 12px; }
    .cart-summary-row.grand { font-size: 18px; }
    .receipt-wrapper { max-width: 100%; padding: 20px 16px; }
    .dropdown-menu.dropdown-menu-end {
        position: fixed !important;
        left: 8px !important; right: 8px !important;
        width: auto !important; min-width: unset !important;
        transform: none !important;
        top: calc(var(--navbar-h) + 6px) !important;
    }
    .btn-icon { width: 36px; height: 36px; }
    .login-card { padding: 28px 22px; }
    .login-logo-icon { width: 60px; height: 60px; font-size: 26px; border-radius: 16px; }
    .login-card h4 { font-size: 18px; }
}

@media (max-width: 480px) {
    :root { --sidebar-width: min(290px, 88vw); }
    .top-navbar .page-title-nav { font-size: 13.5px; max-width: 110px; }
    .stat-card .stat-value { font-size: 19px; }
    .stat-card .stat-icon { width: 40px; height: 40px; font-size: 16px; }
    .login-card { padding: 24px 16px; border-radius: 18px; }
    .table td .d-flex { flex-wrap: wrap; gap: 4px !important; }
}

@media print {
    #sidebar, .top-navbar, .sidebar-overlay, .no-print { display: none !important; }
    #main-content { margin-left: 0 !important; }
    .page-content { padding: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; }
}
