@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
    /* Fondo limpio general */
    --bg-dark: #F8F9FF;
    /* Fondo de paneles */
    --bg-card: #FFFFFF;
    /* Textos nítidos pero no negros puros para evitar fatiga */
    --text-primary: #0B1C30;
    --text-secondary: #566276;
    /* Acento Botica: Turquesa Médico */
    --accent-primary: #006948;
    --accent-hover: #00855D;
    --accent-light: rgba(0, 105, 72, 0.1);
    /* Otros */
    --success: #00855D;
    --success-bg: rgba(0, 133, 93, 0.1);
    --danger: #BA1A1A;
    --danger-bg: rgba(186, 26, 26, 0.1);
    --warning: #A85D00;
    --border-color: #D9E1ED;
    --surface-low: #EFF4FF;
    --surface-container: #E5EEFF;
    --surface-high: #DCE9FF;
    --radius-control: 8px;
    --radius-card: 12px;
    --shadow-soft: 0 1px 8px rgba(11, 28, 48, 0.06);
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    margin: 0;
    overflow-x: hidden;
}

/* Scrollbar sutil y limpio */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }

/* Wrapper global */
#wrapper {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar flotante claro */
#sidebar {
    width: 260px;
    background-color: var(--bg-card);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    flex-shrink: 0;
    box-shadow: 2px 0 10px rgba(0,0,0,0.02);
    z-index: 10;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    padding: 0 20px 30px;
    font-size: 22px;
    font-weight: 700;
    color: var(--accent-primary);
    text-decoration: none;
    gap: 12px;
}

.sidebar-logo i {
    font-size: 28px;
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--success) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-nav {
    list-style: none;
    padding: 0 15px;
    margin: 0;
    flex-grow: 1;
    overflow-y: auto;
}

.nav-item { margin-bottom: 8px; }

.nav-link {
    display: flex;
    align-items: center;
    padding: 12px 18px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 10px;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.3s ease;
    gap: 14px;
}

.nav-link i { font-size: 20px; width: 22px; text-align: center; transition: color 0.3s; }

.nav-link:hover {
    background-color: var(--accent-light);
    color: var(--accent-primary);
}
.nav-link:hover i {
    color: var(--accent-primary);
}

.nav-link.active {
    background-color: var(--accent-primary);
    color: #fff;
    box-shadow: 0 4px 10px var(--accent-light);
}

.nav-link.active-pos {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--success) 100%);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(2, 195, 154, 0.3);
    border: none;
}

.nav-link.active i, .nav-link.active-pos i { color: #fff; }

.badge-sidebar {
    margin-left: auto;
    background-color: var(--danger);
    color: white;
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 20px;
    font-weight: 600;
}

/* Main Content */
#content-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-dark);
    overflow-y: auto;
}

/* Top Navbar limpio */
#topbar {
    height: 75px;
    padding: 0 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
    z-index: 5;
}

/* Búsquedas locales de tablas y módulos; el encabezado no usa este componente. */
.search-box {
    position: relative;
    width: 350px;
}

.search-box input {
    width: 100%;
    padding: 12px 15px 12px 45px;
    background-color: var(--bg-dark);
    border: 1px solid transparent;
    border-radius: 10px;
    color: var(--text-primary);
    outline: none;
    font-size: 14px;
    transition: border 0.3s, box-shadow 0.3s;
}

.search-box input:focus {
    border-color: var(--accent-primary);
    background-color: var(--bg-card);
    box-shadow: 0 0 0 4px var(--accent-light);
}

.search-box i {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 16px;
}

.topbar-actions { display: flex; align-items: center; gap: 25px; }

.topbar-icon {
    color: var(--text-secondary);
    font-size: 22px;
    cursor: pointer;
    text-decoration: none;
    position: relative;
    transition: color 0.3s;
}

.topbar-icon:hover { color: var(--accent-primary); }
.topbar-icon .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    font-size: 9px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 5px;
    border-radius: 30px;
    transition: background 0.3s;
}
.user-profile:hover { background-color: var(--bg-dark); }

.user-profile img {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.user-info { display: flex; flex-direction: column; }
.user-name { font-size: 14px; font-weight: 700; color: var(--text-primary); margin-bottom: 2px;}
.user-role { font-size: 12px; color: var(--text-secondary); font-weight: 500;}

/* Main Padding */
.page-content { padding: 35px; }
.page-header { margin-bottom: 30px; }
.page-title { font-size: 26px; font-weight: 700; color: var(--text-primary); margin: 0; letter-spacing: -0.5px;}
.page-subtitle { font-size: 15px; color: var(--text-secondary); margin-top: 5px;}

/* Cards Estilo Médico/Salud (Planas, blancas, sombras tenues) */
.card-metric {
    background-color: var(--bg-card);
    border-radius: 20px;
    padding: 24px;
    border: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card-metric:hover { 
    transform: translateY(-5px); 
    box-shadow: 0 10px 25px rgba(0, 168, 150, 0.1); 
}

.metric-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.metric-title { font-size: 15px; color: var(--text-secondary); font-weight: 600; }
.metric-icon { 
    width: 48px; height: 48px; 
    border-radius: 12px; 
    display: flex; align-items: center; justify-content: center; 
    font-size: 24px; 
    background-color: var(--accent-light); 
    color: var(--accent-primary); 
}
.metric-value { font-size: 32px; font-weight: 700; margin-bottom: 8px; color: var(--text-primary); letter-spacing: -1px;}
.metric-trend { font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 5px;}
.trend-up { color: var(--success); background-color: var(--success-bg); padding: 4px 8px; border-radius: 20px;}
.trend-down { color: var(--danger); background-color: var(--danger-bg); padding: 4px 8px; border-radius: 20px;}

/* Login Page Only - Split modern design */
.login-body {
    background-color: #f0f4f8; /* Soft blueish background */
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background-image: radial-gradient(circle at top right, var(--accent-light), transparent 40%), radial-gradient(circle at bottom left, rgba(2, 195, 154,0.1), transparent 40%);
}

.login-card {
    background-color: var(--bg-card);
    width: 100%;
    max-width: 460px;
    padding: 50px 40px;
    border-radius: 24px;
    border: none;
    box-shadow: 0 20px 40px rgba(0,0,0,0.08);
}

.login-logo { text-align: center; margin-bottom: 35px; font-size: 32px; font-weight: 800; color: var(--text-primary); }
.login-logo i { color: var(--accent-primary); font-size: 40px; display: block; margin-bottom: 10px;}
.login-title { font-size: 22px; margin-bottom: 10px; font-weight: 700; text-align: center; color: var(--text-primary);}
.login-subtitle { font-size: 15px; color: var(--text-secondary); margin-bottom: 35px; text-align: center;}

.form-group { margin-bottom: 22px; }
.form-label { display: block; font-size: 14px; color: var(--text-primary); margin-bottom: 8px; font-weight: 600; }
.form-control-custom { 
    width: 100%; padding: 14px 18px; 
    border-radius: 12px; background-color: #F8FAFC; 
    border: 1px solid var(--border-color); color: var(--text-primary); 
    font-family: 'Inter'; transition: all 0.3s; font-size: 15px;
}
.form-control-custom:focus { 
    border-color: var(--accent-primary); outline: none; 
    background-color: #fff;
    box-shadow: 0 0 0 4px var(--accent-light);
}

.btn-primary-custom {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--accent-primary), var(--success));
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.3s;
    font-family: 'Inter';
    box-shadow: 0 4px 15px var(--accent-light);
}

.btn-primary-custom:hover { 
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 168, 150, 0.3);
}

.alert-danger { background-color: var(--danger-bg); color: var(--danger); padding: 14px; border-radius: 12px; font-size: 14px; margin-bottom: 25px; border: 1px solid rgba(230, 57, 70, 0.2); font-weight: 500; text-align: center;}

/* Utility classes for contrast on dark backgrounds */
.text-accent { color: var(--accent-primary) !important; }
.text-warning { color: var(--warning) !important; }

/* Shared visual system based on the supplied pharmacy UI references. */
body { font-family: 'Plus Jakarta Sans', sans-serif; color: var(--text-primary); background: var(--bg-dark); }
#sidebar { width: 256px; padding: 12px 0; background: #fff; border-right-color: rgba(188,202,192,.45); box-shadow: 1px 0 8px rgba(11,28,48,.04); }
.sidebar-logo { padding: 8px 16px 18px; margin: 0 12px 12px; border-bottom: 1px solid rgba(188,202,192,.35); font-size: 17px; }
.sidebar-logo i { font-size: 24px; }
.sidebar-nav { padding: 0 10px; }
.nav-item { margin-bottom: 3px; }
.nav-link { padding: 9px 11px; border-radius: 8px; font-size: 13px; gap: 10px; color: #3D4A42; transition: background .16s ease, color .16s ease; }
.nav-link i { width: 20px; font-size: 18px; }
.nav-link:hover { background: #EFF4FF; color: var(--accent-primary); }
.nav-link.active, .nav-link.active-pos { background: #00855D; color: #fff; box-shadow: none; border: 0; }
.nav-link.active i, .nav-link.active-pos i { color: #fff; }
#topbar { height: 64px; min-height: 64px; padding: 0 24px; box-shadow: 0 1px 8px rgba(11,28,48,.04); }
.page-content { padding: 24px; }
.page-header { margin-bottom: 22px; }
.page-title { font-size: 24px; letter-spacing: -.6px; }
.page-subtitle { font-size: 13px; }
.card-metric { border: 1px solid var(--border-color); border-radius: 12px; padding: 18px; box-shadow: var(--shadow-soft); transition: box-shadow .18s ease, border-color .18s ease; }
.card-metric:hover { transform: none; border-color: rgba(0,105,72,.22); box-shadow: 0 4px 14px rgba(11,28,48,.08); }
.dashboard-metric { min-height: 170px; display: flex; flex-direction: column; justify-content: space-between; }
.dashboard-metric .metric-title { color: var(--text-secondary); font-size: 12px; text-transform: uppercase; letter-spacing: .045em; }
.dashboard-metric .metric-icon { width: 36px; height: 36px; background: #EFF4FF; color: var(--accent-primary); font-size: 19px; }
.dashboard-metric-value { margin: 10px 0; color: var(--text-primary); font: 700 26px/1.25 'JetBrains Mono', monospace; letter-spacing: -.04em; }
.dashboard-metric-note { display: inline-flex; align-items: center; gap: 6px; width: fit-content; padding: 4px 8px; border-radius: 5px; color: var(--accent-primary); background: var(--success-bg); font-size: 11px; font-weight: 600; }
.dashboard-metric-alert { color: var(--danger); background: var(--danger-bg); }
.section-eyebrow { display: flex; align-items: center; gap: 7px; margin-bottom: 7px; color: var(--accent-primary); font-size: 10px; font-weight: 700; letter-spacing: .08em; }
.overview-card { min-height: 132px; display: flex; flex-direction: column; justify-content: space-between; gap: 10px; }
.overview-label { color: var(--text-secondary); font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.overview-value { color: var(--text-primary); font: 700 23px/1.2 'JetBrains Mono', monospace; letter-spacing: -.04em; }
.overview-note { display: flex; align-items: center; gap: 6px; color: var(--accent-primary); font-size: 11px; font-weight: 600; }
.overview-warning { color: var(--warning); }
.overview-danger { color: var(--danger); }
.inventory-action { width: auto; padding: 9px 14px; text-decoration: none; font-size: 13px; }
.table-custom tbody tr:last-child td { border-bottom: 0; }
.table-responsive { border-radius: 9px; }
.metric-icon { border-radius: 9px; }
.form-control-custom, .form-control, .form-select { border-radius: 8px; font-family: 'Plus Jakarta Sans', sans-serif; }
.form-control-custom { padding: 10px 12px; background: #F8FAFC; font-size: 14px; }
.btn-primary-custom { border-radius: 8px; background: var(--accent-primary); box-shadow: none; font-family: 'Plus Jakarta Sans', sans-serif; }
.btn-primary-custom:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 3px 10px var(--accent-light); }
.alert { border-radius: 8px; }
.table-custom { width: 100%; border-collapse: separate; border-spacing: 0; color: var(--text-primary); font-size: 13px; }
.table-custom thead th { background: #EFF4FF; color: #566276; font-size: 11px; font-weight: 700; letter-spacing: .045em; text-transform: uppercase; border-bottom: 1px solid var(--border-color); padding: 11px 12px; white-space: nowrap; }
.table-custom tbody td { border-bottom: 1px solid rgba(217,225,237,.72); padding: 12px; vertical-align: middle; }
.table-custom tbody tr:hover { background: rgba(239,244,255,.62); }
.font-monospace, code { font-family: 'JetBrains Mono', monospace !important; }
@media (max-width: 900px) {
    #sidebar { width: 220px; }
    #topbar { padding: 0 14px; }
    .page-content { padding: 16px; }
}
@media (max-width: 640px) {
    #wrapper { height: auto; min-height: 100vh; overflow: visible; }
    #sidebar { display: none; }
    #content-wrapper { min-height: 100vh; overflow: visible; }
    #topbar { height: 58px; min-height: 58px; }
    .page-content { padding: 12px; }
    .page-title { font-size: 21px; }
    .card-metric { padding: 14px; }
}

/* Scanner actions and POS search: keep the icon, field and action aligned. */
.scanner-pair-trigger {
    width: auto !important;
    min-height: 42px;
    margin: 0 !important;
    padding: 9px 12px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    white-space: nowrap;
    border: 1px solid var(--accent-primary) !important;
    border-radius: 8px !important;
    background: #fff !important;
    color: var(--accent-primary) !important;
    box-shadow: none !important;
    font: 600 12px/1.2 'Plus Jakarta Sans', sans-serif !important;
}
.scanner-pair-trigger:hover {
    background: var(--accent-light) !important;
    color: var(--accent-hover) !important;
    transform: none !important;
}
.pos-right > .pos-search-box {
    width: 100%;
    min-width: 0;
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center;
    gap: 8px;
}
.pos-right > .pos-search-box input {
    flex: 1 1 0;
    width: 0;
    min-width: 0;
    height: 42px;
    box-sizing: border-box;
    padding: 9px 12px 9px 40px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #EFF4FF;
    font-size: 13px;
}
.pos-right > .pos-search-box > i {
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    pointer-events: none;
}
.pos-right > .pos-search-box .scanner-pair-trigger {
    flex: 0 0 auto;
}
.product-scan-controls { align-items: center; }
.product-scan-controls .form-control-custom { flex: 1 1 auto; width: auto; min-width: 0; }
.product-scan-controls .scanner-pair-trigger { flex: 0 0 auto; }
@media (max-width: 1050px) {
    .pos-layout { height: auto; min-height: calc(100vh - 80px); flex-direction: column; }
    .pos-left, .pos-right { flex: 1 1 auto; width: 100%; min-width: 0; }
    .pos-left { min-height: 580px; }
    .pos-right { min-height: 440px; }
}
@media (max-width: 600px) {
    .pos-right > .pos-search-box { gap: 6px; }
    .pos-right > .pos-search-box .scanner-pair-trigger { width: 44px !important; padding: 0 !important; overflow: hidden; font-size: 0 !important; }
    .pos-right > .pos-search-box .scanner-pair-trigger i { font-size: 17px; }
}

/* Real tablet/phone layout: the navigation becomes a drawer instead of stealing POS width. */
.mobile-menu-toggle { display: none; }
#content-wrapper { min-width: 0; }
@media (max-width: 991px) {
    #wrapper { display: block; width: 100%; height: auto; min-height: 100vh; overflow: visible; }
    #sidebar {
        display: flex !important;
        position: fixed;
        inset: 0 auto 0 0;
        width: min(280px, 86vw);
        height: 100vh;
        height: 100dvh;
        overflow-y: auto;
        transform: translateX(-105%);
        transition: transform .22s ease;
        z-index: 1002;
    }
    #sidebar.mobile-open { transform: translateX(0); }
    #sidebarBackdrop { display: none; position: fixed; inset: 0; background: rgba(11,28,48,.42); z-index: 1001; }
    #sidebarBackdrop.visible { display: block; }
    #content-wrapper { width: 100%; min-width: 0; min-height: 100vh; overflow: visible; }
    #topbar { position: sticky; top: 0; width: 100%; min-width: 0; height: 60px; min-height: 60px; gap: 10px; padding: 0 14px; z-index: 100; }
    .mobile-menu-toggle { width: 40px; height: 40px; flex: 0 0 40px; display: inline-flex; align-items: center; justify-content: center; padding: 0; border: 1px solid var(--border-color); border-radius: 8px; background: #fff; color: var(--text-primary); font-size: 22px; }
    .topbar-actions { min-width: 0; margin-left: auto; gap: 12px; }
    .pos-layout { width: 100%; min-width: 0; }
}
@media (max-width: 640px) {
    body { overflow-x: hidden; }
    #topbar { padding: 0 10px; }
    #topbar .user-info { display: none; }
    .topbar-actions { gap: 9px; }
    .user-profile { gap: 7px; }
    .user-profile img { width: 34px; height: 34px; }
    .pos-layout { gap: 14px; }
    .pos-left { min-height: 560px; }
    .pos-right { min-height: 430px; }
    .pos-cart { overflow-x: auto; }
    .pos-cart table { min-width: 560px; }
    .pos-totals { padding: 12px; }
}
