/* ============================================================
   AlmacénPro · Sistema de Gestión de Almacenes
   Hoja de estilos principal
   ============================================================ */

:root {
    --sidebar-bg: #1f2533;
    --sidebar-bg-2: #272e3f;
    --sidebar-active: #e07a5f;       /* terracota */
    --sidebar-text: #aeb6c7;
    --sidebar-text-hover: #ffffff;

    --brand: #e07a5f;
    --brand-dark: #c75f44;
    --accent-teal: #3d8b88;
    --accent-amber: #f2cc8f;

    --body-bg: #f4f6fa;
    --card-bg: #ffffff;
    --text-dark: #2b303a;
    --text-muted: #7a8290;
    --border: #e8ebf1;

    --shadow-sm: 0 1px 3px rgba(31, 37, 51, .06);
    --shadow: 0 4px 18px rgba(31, 37, 51, .08);

    --sidebar-w: 256px;
    --topbar-h: 64px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--body-bg);
    color: var(--text-dark);
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14.5px;
}

/* ---------------- Layout ---------------- */
.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
    color: var(--sidebar-text);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 1030;
    transition: transform .25s ease;
    overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 4px; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    min-height: var(--topbar-h);
}
.sidebar-brand .logo {
    width: 38px; height: 38px;
    border-radius: 10px;
    background: var(--brand);
    display: grid; place-items: center;
    color: #fff; font-size: 20px;
    box-shadow: 0 4px 12px rgba(224,122,95,.45);
}
.sidebar-brand .name { color: #fff; font-weight: 700; font-size: 16px; line-height: 1.1; }
.sidebar-brand .sub { color: var(--sidebar-text); font-size: 11px; }

.sidebar-section {
    padding: 16px 20px 6px;
    font-size: 10.5px;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: #5d6678;
}

.nav-menu { list-style: none; margin: 0; padding: 6px 12px 24px; }
.nav-menu .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: var(--sidebar-text);
    border-radius: 9px;
    text-decoration: none;
    font-weight: 500;
    transition: all .15s ease;
    cursor: pointer;
}
.nav-menu .nav-link i { font-size: 17px; width: 20px; text-align: center; }
.nav-menu .nav-link:hover {
    background: rgba(255,255,255,.06);
    color: var(--sidebar-text-hover);
}
.nav-menu .nav-link.active {
    background: var(--sidebar-active);
    color: #fff;
    box-shadow: 0 4px 12px rgba(224,122,95,.4);
}
.nav-menu .nav-link .caret { margin-left: auto; font-size: 12px; transition: transform .2s; }
.nav-menu .nav-link[aria-expanded="true"] .caret { transform: rotate(90deg); }

.submenu { list-style: none; margin: 2px 0 4px; padding: 0 0 0 14px; }
.submenu a {
    display: block;
    padding: 8px 14px 8px 32px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 8px;
    font-size: 13.5px;
    transition: all .15s;
}
.submenu a:hover { color: #fff; background: rgba(255,255,255,.05); }
.submenu a.active { color: #fff; font-weight: 600; }
.submenu a.active::before {
    content: ""; display: inline-block;
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--brand); margin-right: 8px;
    vertical-align: middle;
}

/* ---------------- Main ---------------- */
.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: var(--topbar-h);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 1020;
}
.topbar .btn-toggle {
    border: none; background: transparent; font-size: 20px;
    color: var(--text-muted); cursor: pointer; display: none;
}
.topbar .page-title { font-weight: 700; font-size: 18px; margin: 0; }
.topbar .search {
    margin-left: 8px;
    max-width: 360px; flex: 1;
    position: relative;
}
.topbar .search input {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--body-bg);
    border-radius: 24px;
    padding: 9px 16px 9px 40px;
    font-size: 13.5px;
    outline: none;
}
.topbar .search i {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted);
}
.topbar .actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.topbar .icon-btn {
    width: 40px; height: 40px; border-radius: 10px; border: none;
    background: var(--body-bg); color: var(--text-muted);
    display: grid; place-items: center; font-size: 17px; cursor: pointer;
    position: relative;
}
.topbar .icon-btn:hover { background: #eef1f6; color: var(--text-dark); }
.topbar .icon-btn .dot {
    position: absolute; top: 8px; right: 9px;
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--brand); border: 2px solid var(--card-bg);
}

.avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--accent-teal); color: #fff;
    display: grid; place-items: center; font-weight: 700; font-size: 13px;
}

.content { padding: 24px; }

/* ---------------- Cards / stats ---------------- */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-head h1 { font-size: 22px; font-weight: 700; margin: 0; }
.page-head .breadcrumb-mini { color: var(--text-muted); font-size: 13px; }

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px; }

.stat-card {
    position: relative;
    padding: 18px 18px 16px;
    height: 100%;
    min-height: 112px;
    border-radius: 16px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.stat-card .ic {
    position: absolute; top: 16px; right: 16px;
    width: 46px; height: 46px; border-radius: 13px;
    display: grid; place-items: center; font-size: 21px;
}
.stat-card .min-w-0 { min-width: 0; }
.stat-card .label {
    color: var(--text-muted); font-size: 11.5px; font-weight: 600;
    margin: 0 0 10px; padding-right: 54px; line-height: 1.3;
    text-transform: uppercase; letter-spacing: .03em;
}
.stat-card .value {
    font-size: 26px; font-weight: 800; line-height: 1; margin: 0 0 7px;
    color: var(--text-dark);
}
.stat-card .detail { color: var(--text-muted); font-size: 11.5px; }
/* Acento de color en el borde izquierdo según el ícono */
.stat-card:has(.bg-primary)   { border-left-color: var(--brand); }
.stat-card:has(.bg-success)   { border-left-color: var(--accent-teal); }
.stat-card:has(.bg-warning)   { border-left-color: #d98620; }
.stat-card:has(.bg-info)      { border-left-color: #4682b4; }
.stat-card:has(.bg-secondary) { border-left-color: #6b7585; }
.stat-card:has(.bg-dark)      { border-left-color: #2b303a; }

.ic.bg-primary   { background: rgba(224,122,95,.14);  color: var(--brand); }
.ic.bg-success   { background: rgba(61,139,136,.14);   color: var(--accent-teal); }
.ic.bg-warning   { background: rgba(242,160,55,.16);   color: #d98620; }
.ic.bg-info      { background: rgba(70,130,180,.14);   color: #4682b4; }
.ic.bg-secondary { background: rgba(120,130,150,.14);  color: #6b7585; }
.ic.bg-dark      { background: rgba(43,48,58,.10);     color: #2b303a; }

.card-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 10px; flex-wrap: wrap; }
.card-title-row h2 { font-size: 15.5px; font-weight: 700; margin: 0; }
.card-title-row .sub { color: var(--text-muted); font-size: 12px; }

/* Contenedor de gráficos: altura fluida que se auto-ajusta a la pantalla.
   Una altura definida es clave para que Chart.js (responsive) renderice. */
.chart-box { position: relative; width: 100%; height: clamp(240px, 34vh, 340px); }
.chart-box canvas { max-width: 100%; }

.min-w-0 { min-width: 0; }

/* tables */
.table-clean { width: 100%; border-collapse: collapse; }
.table-clean th {
    text-align: left; font-size: 11.5px; text-transform: uppercase;
    letter-spacing: .04em; color: var(--text-muted); font-weight: 600;
    padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.table-clean td { padding: 11px 12px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.table-clean tr:last-child td { border-bottom: none; }
.table-clean tr:hover td { background: #fafbfd; }

.btn-accion {
    display: inline-grid; place-items: center;
    width: 32px; height: 32px; border-radius: 8px;
    color: var(--text-muted); background: var(--body-bg);
    text-decoration: none; font-size: 14px; margin-left: 4px;
    transition: all .15s;
}
.btn-accion:hover { background: var(--brand); color: #fff; }
.btn-accion.danger:hover { background: #d24a4a; color: #fff; }

.badge-soft { padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.badge-soft.success { background: rgba(61,139,136,.14); color: var(--accent-teal); }
.badge-soft.danger  { background: rgba(224,72,72,.12);  color: #d24a4a; }
.badge-soft.info    { background: rgba(70,130,180,.14); color: #4682b4; }

.progress-thin { height: 8px; background: var(--body-bg); border-radius: 6px; overflow: hidden; }
.progress-thin > span { display: block; height: 100%; border-radius: 6px; background: var(--brand); }

/* ---------------- Login ---------------- */
.login-wrap {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: var(--body-bg);
}
.login-side {
    background: linear-gradient(150deg, #1f2533 0%, #2b3346 55%, var(--brand-dark) 130%);
    color: #fff;
    padding: 56px;
    display: flex; flex-direction: column; justify-content: center;
    position: relative; overflow: hidden;
}
.login-side::after {
    content: ""; position: absolute; right: -80px; bottom: -80px;
    width: 320px; height: 320px; border-radius: 50%;
    background: radial-gradient(circle, rgba(224,122,95,.35), transparent 70%);
}
.login-side .logo-lg {
    width: 60px; height: 60px; border-radius: 16px; background: var(--brand);
    display: grid; place-items: center; font-size: 30px; margin-bottom: 28px;
    box-shadow: 0 8px 24px rgba(224,122,95,.5);
}
.login-side h1 { font-size: 30px; font-weight: 800; margin: 0 0 14px; line-height: 1.2; }
.login-side p { color: rgba(255,255,255,.78); font-size: 15px; max-width: 380px; }
.login-side .feat { margin-top: 30px; list-style: none; padding: 0; }
.login-side .feat li { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; color: rgba(255,255,255,.9); }
.login-side .feat i { color: var(--accent-amber); font-size: 18px; }

.login-form-side { display: flex; align-items: center; justify-content: center; padding: 40px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-size: 24px; font-weight: 700; margin: 0 0 6px; }
.login-card .muted { color: var(--text-muted); margin-bottom: 28px; }
.login-card label { font-weight: 600; font-size: 13px; margin-bottom: 6px; display: block; }
.login-card .form-control { border-radius: 10px; padding: 12px 14px; }
.btn-brand {
    background: var(--brand); border: none; color: #fff; font-weight: 600;
    border-radius: 10px; padding: 12px; width: 100%; font-size: 15px;
    transition: background .15s;
}
.btn-brand:hover { background: var(--brand-dark); color: #fff; }

/* ---------------- Module placeholder ---------------- */
.empty-state {
    text-align: center; padding: 64px 24px;
}
.empty-state .big-ic {
    width: 96px; height: 96px; border-radius: 24px; margin: 0 auto 22px;
    background: rgba(224,122,95,.12); color: var(--brand);
    display: grid; place-items: center; font-size: 44px;
}
.empty-state h2 { font-weight: 700; margin: 0 0 10px; }
.empty-state p { color: var(--text-muted); max-width: 480px; margin: 0 auto 8px; }
.empty-state .tag {
    display: inline-block; margin-top: 18px; padding: 6px 16px;
    background: var(--accent-amber); color: #6b4e16; border-radius: 20px;
    font-size: 12.5px; font-weight: 600;
}

/* ---------------- Responsive ---------------- */
.sidebar-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1029;
}
@media (max-width: 992px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .topbar .btn-toggle { display: block; }
    .sidebar-backdrop.show { display: block; }
}
@media (max-width: 768px) {
    .login-wrap { grid-template-columns: 1fr; }
    .login-side { display: none; }
    .topbar .search { display: none; }
    .content { padding: 16px; }
    .page-head h1 { font-size: 19px; }
    .stat-card { padding: 14px; min-height: 100px; }
    .stat-card .ic { width: 40px; height: 40px; font-size: 18px; top: 12px; right: 12px; }
    .stat-card .value { font-size: 22px; }
    .stat-card .label { padding-right: 46px; }
    .topbar .actions .d-md-block { display: none !important; }
}
@media (max-width: 480px) {
    .stat-card .detail { display: none; }
}

/* ---------------- Impresión (PDF) ---------------- */
@media print {
    .sidebar, .topbar, .no-print, .btn-accion { display: none !important; }
    .main { margin-left: 0 !important; }
    .content { padding: 0 !important; }
    .card { border: none !important; box-shadow: none !important; }
    .print-head { display: block !important; }
    body { background: #fff !important; }
    .table-clean th { color: #333 !important; }
    a[href]:after { content: ""; }
}
