/* ============================================================
   Droguería Médico Amigo — Estilos principales
   Paleta: azul oscuro #003087 / azul medio #0066CC / blanco
   ============================================================ */

:root {
    --blue-dark:  #003087;
    --blue-mid:   #0066CC;
    --blue-light: #E8F0FE;
    --blue-hover: #0052A3;
    --white:      #FFFFFF;
    --bg:         #F4F7FB;
    --text:       #1A1A2E;
    --text-muted: #6B7280;
    --border:     #D1D9E6;
    --success:    #16A34A;
    --danger:     #DC2626;
    --warning:    #D97706;
    --info:       #0891B2;
    --sidebar-w:  260px;
    --radius:     10px;
    --shadow:     0 2px 12px rgba(0,48,135,.10);
    --shadow-sm:  0 1px 4px rgba(0,48,135,.07);
}

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

html { font-size: 15px; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

a { color: var(--blue-mid); text-decoration: none; }
a:hover { color: var(--blue-hover); }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--blue-dark);
    display: flex;
    flex-direction: column;
    z-index: 200;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 22px 18px 18px;
    border-bottom: 1px solid rgba(255,255,255,.12);
    text-decoration: none;
}

.sidebar-brand .brand-icon {
    width: 42px; height: 42px;
    background: var(--white);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.sidebar-brand .brand-icon svg { width: 26px; height: 26px; }

.sidebar-brand .brand-text { flex: 1; }
.sidebar-brand .brand-text span {
    display: block;
    color: var(--white);
    font-weight: 700;
    font-size: .8rem;
    line-height: 1.2;
    letter-spacing: .3px;
}
.sidebar-brand .brand-text small {
    color: rgba(255,255,255,.55);
    font-size: .68rem;
}

.sidebar-nav { flex: 1; padding: 12px 10px; }

.nav-section-title {
    text-transform: uppercase;
    font-size: .65rem;
    letter-spacing: 1.2px;
    color: rgba(255,255,255,.40);
    padding: 14px 10px 6px;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: rgba(255,255,255,.75);
    font-size: .88rem;
    font-weight: 500;
    transition: background .15s, color .15s;
    text-decoration: none;
    margin-bottom: 2px;
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }

.nav-item:hover {
    background: rgba(255,255,255,.10);
    color: var(--white);
}

.nav-item.active {
    background: var(--blue-mid);
    color: var(--white);
    font-weight: 600;
}

.nav-item.active svg { opacity: 1; }

.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid rgba(255,255,255,.12);
    font-size: .78rem;
    color: rgba(255,255,255,.45);
}

/* ── Layout principal ─────────────────────────────────────── */
.main-wrapper {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky; top: 0; z-index: 100;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
}

.topbar-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--blue-dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-user {
    display: flex; align-items: center; gap: 10px;
    font-size: .85rem; color: var(--text-muted);
}

.topbar-user .user-badge {
    width: 34px; height: 34px;
    background: var(--blue-mid);
    border-radius: 50%;
    color: var(--white);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: .85rem;
    flex-shrink: 0;
}

.content {
    flex: 1;
    padding: 28px;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-header h2, .card-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--blue-dark);
    display: flex; align-items: center; gap: 8px;
}

.card-body { padding: 20px; }

/* ── Stat cards (dashboard) ──────────────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 20px;
    display: flex; align-items: center; gap: 16px;
}

.stat-icon {
    width: 52px; height: 52px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg { width: 26px; height: 26px; }
.stat-icon.blue  { background: var(--blue-light); color: var(--blue-mid); }
.stat-icon.green { background: #DCFCE7; color: #16A34A; }
.stat-icon.red   { background: #FEE2E2; color: #DC2626; }
.stat-icon.amber { background: #FEF3C7; color: #D97706; }

.stat-info .stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--blue-dark);
    line-height: 1;
}

.stat-info .stat-label {
    font-size: .78rem;
    color: var(--text-muted);
    margin-top: 3px;
}

/* ── Tablas ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}

table.data-table th {
    text-align: left;
    padding: 10px 14px;
    background: var(--bg);
    border-bottom: 2px solid var(--border);
    font-weight: 700;
    color: var(--blue-dark);
    font-size: .80rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    white-space: nowrap;
}

table.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

table.data-table tbody tr:hover { background: #F9FAFB; }
table.data-table tbody tr:last-child td { border-bottom: none; }

/* ── Formularios ─────────────────────────────────────────── */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }

.form-label {
    font-size: .82rem;
    font-weight: 600;
    color: var(--text);
}

.form-label .required { color: var(--danger); margin-left: 2px; }

.form-control {
    padding: 9px 12px;
    border: 1.5px solid var(--border);
    border-radius: 7px;
    font-size: .9rem;
    color: var(--text);
    background: var(--white);
    transition: border-color .15s, box-shadow .15s;
    width: 100%;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--blue-mid);
    box-shadow: 0 0 0 3px rgba(0,102,204,.12);
}

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 90px; }

.form-hint {
    font-size: .75rem;
    color: var(--text-muted);
}

.form-section {
    background: var(--blue-light);
    border: 1px solid #BDD0F5;
    border-radius: 8px;
    padding: 16px;
    margin-top: 4px;
}

.form-section-title {
    font-size: .82rem;
    font-weight: 700;
    color: var(--blue-dark);
    margin-bottom: 12px;
    display: flex; align-items: center; gap: 6px;
}

/* ── Botones ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 7px;
    font-size: .88rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background .15s, transform .1s, box-shadow .15s;
    text-decoration: none;
    font-family: inherit;
    white-space: nowrap;
}

.btn:active { transform: scale(.98); }
.btn svg { width: 16px; height: 16px; }

.btn-primary {
    background: var(--blue-mid);
    color: var(--white);
    box-shadow: 0 2px 6px rgba(0,102,204,.25);
}
.btn-primary:hover { background: var(--blue-hover); color: var(--white); }

.btn-dark {
    background: var(--blue-dark);
    color: var(--white);
}
.btn-dark:hover { background: #002060; color: var(--white); }

.btn-outline {
    background: transparent;
    color: var(--blue-mid);
    border: 1.5px solid var(--blue-mid);
}
.btn-outline:hover { background: var(--blue-light); }

.btn-success {
    background: var(--success);
    color: var(--white);
}
.btn-success:hover { background: #15803D; color: var(--white); }

.btn-danger {
    background: var(--danger);
    color: var(--white);
}
.btn-danger:hover { background: #B91C1C; color: var(--white); }

.btn-sm { padding: 5px 11px; font-size: .8rem; }
.btn-sm svg { width: 14px; height: 14px; }

/* ── Badges / Pills ──────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 50px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .3px;
}
.badge-blue   { background: var(--blue-light); color: var(--blue-dark); }
.badge-green  { background: #DCFCE7; color: #15803D; }
.badge-red    { background: #FEE2E2; color: #B91C1C; }
.badge-amber  { background: #FEF3C7; color: #92400E; }
.badge-gray   { background: #F3F4F6; color: #6B7280; }

/* Tipo de conteo */
.badge-caj { background: #EDE9FE; color: #5B21B6; }
.badge-uni { background: #DBEAFE; color: #1D4ED8; }
.badge-ind { background: #DCFCE7; color: #15803D; }

/* ── Alertas ─────────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: .88rem;
    display: flex; align-items: flex-start; gap: 10px;
    border: 1px solid transparent;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

.alert-success { background: #F0FDF4; border-color: #BBF7D0; color: #15803D; }
.alert-danger  { background: #FEF2F2; border-color: #FECACA; color: #B91C1C; }
.alert-warning { background: #FFFBEB; border-color: #FDE68A; color: #92400E; }
.alert-info    { background: #F0F9FF; border-color: #BAE6FD; color: #0369A1; }

/* ── Login page ──────────────────────────────────────────── */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--blue-dark) 0%, var(--blue-mid) 100%);
    padding: 20px;
}

.login-card {
    background: var(--white);
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(0,48,135,.30);
    padding: 44px 40px;
    width: 100%;
    max-width: 420px;
}

.login-logo {
    text-align: center;
    margin-bottom: 28px;
}

.login-logo .cross-icon {
    width: 72px; height: 72px;
    background: var(--blue-dark);
    border-radius: 18px;
    display: inline-flex; align-items: center; justify-content: center;
    margin-bottom: 14px;
}

.login-logo .cross-icon svg { width: 42px; height: 42px; }

.login-logo h1 {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--blue-dark);
    line-height: 1.2;
}

.login-logo p {
    color: var(--text-muted);
    font-size: .82rem;
    margin-top: 4px;
}

/* ── Page header ─────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h1 {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--blue-dark);
    display: flex; align-items: center; gap: 10px;
}

.page-header h1 svg { width: 24px; height: 24px; color: var(--blue-mid); }

/* ── Búsqueda / filtros ──────────────────────────────────── */
.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.search-input-wrap {
    position: relative; flex: 1; min-width: 200px;
}
.search-input-wrap svg {
    position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
    width: 16px; height: 16px; color: var(--text-muted);
}
.search-input-wrap input {
    padding-left: 34px;
}

/* ── Tablas de stock: presentación ───────────────────────── */
.stock-display { line-height: 1.5; }
.stock-display .unit-block {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: .83rem;
}
.stock-display .unit-value { font-weight: 700; color: var(--blue-dark); }
.stock-display .unit-label { color: var(--text-muted); font-size: .75rem; }
.stock-display .sep { color: var(--border); margin: 0 4px; }

/* ── Modal sencillo ──────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 900;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.modal-box {
    background: var(--white);
    border-radius: 14px;
    width: 100%; max-width: 520px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    overflow: hidden;
}
.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: .95rem; font-weight: 700; color: var(--blue-dark); }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 4px; }
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ── Utilidades ──────────────────────────────────────────── */
.text-muted   { color: var(--text-muted); }
.text-small   { font-size: .8rem; }
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.fw-bold      { font-weight: 700; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.d-flex  { display: flex; }
.gap-1   { gap: 8px; }
.gap-2   { gap: 16px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }

.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}
.empty-state svg { width: 48px; height: 48px; opacity: .3; margin-bottom: 12px; }
.empty-state p   { font-size: .9rem; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform .25s; }
    .sidebar.open { transform: translateX(0); }
    .main-wrapper { margin-left: 0; }
    .content { padding: 16px; }
    .form-grid { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
