/* ============================================================
   app.css — Hogar Familiar
   ============================================================ */

:root {
    --sidebar-w: 250px;
    --topbar-h: 64px;

    /* Paleta principal */
    --primary:      #f97316;
    --primary-dark: #ea6c0a;
    --primary-soft: #fff4ed;

    --secondary:    #0ea5e9;
    --success:      #22c55e;
    --warning:      #f59e0b;
    --danger:       #ef4444;
    --info:         #8b5cf6;

    /* Fondos */
    --bg-body:      #f8f7f4;
    --bg-card:      #ffffff;
    --bg-sidebar:   #1e1b18;
    --bg-sidebar-2: #2d2926;

    /* Textos */
    --text-main:    #1c1917;
    --text-muted:   #78716c;
    --text-light:   #a8a29e;

    /* Bordes */
    --border:       #e7e5e4;
    --border-focus: #f97316;

    /* Sombras */
    --shadow-sm:    0 1px 3px rgba(0,0,0,.08);
    --shadow-md:    0 4px 16px rgba(0,0,0,.10);
    --shadow-lg:    0 8px 32px rgba(0,0,0,.14);

    --radius-sm:  8px;
    --radius-md:  12px;
    --radius-lg:  20px;

    --transition: .2s ease;
}

/* ---- Reset base ---- */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: 'Nunito', system-ui, sans-serif;
    font-size: 15px;
    background: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    min-height: 100vh;
}

h1,h2,h3,h4,h5,h6 {
    font-family: 'Sora', system-ui, sans-serif;
    font-weight: 700;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform var(--transition);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.07);
}

.brand-icon {
    width: 40px; height: 40px;
    background: var(--primary);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; color: #fff;
    flex-shrink: 0;
}

.brand-text {
    font-family: 'Sora', sans-serif;
    font-weight: 700;
    font-size: 15px;
    color: #fff;
    line-height: 1.2;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,.6);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: all var(--transition);
}

.nav-item i { font-size: 18px; flex-shrink: 0; }

.nav-item:hover {
    background: rgba(255,255,255,.07);
    color: #fff;
}

.nav-item.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(249,115,22,.4);
}

.nav-divider {
    padding: 16px 12px 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: rgba(255,255,255,.3);
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid rgba(255,255,255,.07);
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-card {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}

.user-card:hover { background: rgba(255,255,255,.07); }

.user-avatar {
    width: 36px; height: 36px;
    background: var(--primary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; color: #fff; font-size: 15px;
    flex-shrink: 0;
}

.user-info { display: flex; flex-direction: column; min-width: 0; }

.user-name {
    font-size: 13px; font-weight: 700;
    color: #fff;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.user-role { font-size: 11px; color: rgba(255,255,255,.4); }

.btn-logout {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,.5);
    text-decoration: none;
    transition: all var(--transition);
    flex-shrink: 0;
}

.btn-logout:hover { background: rgba(239,68,68,.2); color: #ef4444; }

/* ============================================================
   MAIN WRAPPER
   ============================================================ */
.main-wrapper {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition);
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-h);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-main);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
}

.sidebar-toggle:hover { background: var(--border); }

.page-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    flex: 1;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.date-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
    background: var(--bg-body);
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 600;
    text-transform: capitalize;
}

/* ============================================================
   PAGE CONTENT
   ============================================================ */
.flash-container { padding: 16px 24px 0; }

.page-content { padding: 24px; flex: 1; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.card-header {
    background: none;
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
    font-weight: 700;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body { padding: 20px; }

/* STAT CARDS */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition), transform var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-icon {
    width: 52px; height: 52px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.stat-icon.orange  { background: #fff4ed; color: var(--primary); }
.stat-icon.blue    { background: #f0f9ff; color: var(--secondary); }
.stat-icon.green   { background: #f0fdf4; color: var(--success); }
.stat-icon.purple  { background: #faf5ff; color: var(--info); }
.stat-icon.red     { background: #fef2f2; color: var(--danger); }
.stat-icon.yellow  { background: #fffbeb; color: var(--warning); }

.stat-info { flex: 1; min-width: 0; }

.stat-value {
    font-family: 'Sora', sans-serif;
    font-size: 26px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 600;
}

/* ============================================================
   BOTONES
   ============================================================ */
.btn {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(249,115,22,.35);
}

.btn-outline-primary { border-color: var(--primary); color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: #fff; }

/* ============================================================
   TABLAS
   ============================================================ */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-card);
}

.table {
    margin: 0;
    font-size: 14px;
}

.table thead th {
    background: #fafaf9;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    white-space: nowrap;
}

.table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    border-bottom: 1px solid #fafaf9;
}

.table tbody tr:last-child td { border-bottom: none; }

.table tbody tr:hover td { background: #fffaf7; }

/* ============================================================
   FORMULARIOS
   ============================================================ */
.form-label {
    font-weight: 700;
    font-size: 13px;
    color: var(--text-main);
    margin-bottom: 6px;
}

.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border);
    font-family: 'Nunito', sans-serif;
    font-size: 14px;
    padding: 10px 14px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(249,115,22,.15);
}

/* ============================================================
   BADGES
   ============================================================ */
.badge-estado {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
}

.badge-pendiente  { background: #fffbeb; color: #92400e; }
.badge-aprobado   { background: #f0fdf4; color: #166534; }
.badge-rechazado  { background: #fef2f2; color: #991b1b; }
.badge-comprado   { background: #f0f9ff; color: #075985; }

/* ============================================================
   STOCK BARRA
   ============================================================ */
.stock-bar { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.stock-fill { height: 100%; border-radius: 3px; transition: width .4s ease; }
.stock-ok   .stock-fill { background: var(--success); }
.stock-low  .stock-fill { background: var(--warning); }
.stock-zero .stock-fill { background: var(--danger); }

/* ============================================================
   CALENDARIO
   ============================================================ */
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.cal-header {
    text-align: center;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    padding: 8px 0;
}

.cal-day {
    min-height: 90px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: box-shadow var(--transition);
    cursor: default;
}

.cal-day.empty { background: transparent; border-color: transparent; }
.cal-day.today { border-color: var(--primary); background: var(--primary-soft); }
.cal-day.has-lunch { background: #f0fdf4; border-color: #86efac; }
.cal-day:not(.empty):hover { box-shadow: var(--shadow-sm); }

.cal-num {
    font-size: 13px;
    font-weight: 800;
    color: var(--text-muted);
    line-height: 1;
}

.cal-day.today .cal-num { color: var(--primary); }

.cal-meal {
    font-size: 12px;
    font-weight: 600;
    color: var(--success);
    line-height: 1.3;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.cal-add {
    display: none;
    font-size: 18px;
    color: var(--text-light);
    text-decoration: none;
    line-height: 1;
}

.cal-day:hover .cal-add { display: block; }

/* ============================================================
   ALERTAS (override Bootstrap)
   ============================================================ */
.alert {
    border-radius: var(--radius-sm);
    border: none;
    font-weight: 600;
    font-size: 14px;
}

.alert-success { background: #f0fdf4; color: #166534; }
.alert-danger   { background: #fef2f2; color: #991b1b; }
.alert-warning  { background: #fffbeb; color: #92400e; }
.alert-info     { background: #f0f9ff; color: #075985; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #1e1b18 0%, #292524 50%, #1e1b18 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    width: 60px; height: 60px;
    background: var(--primary);
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 28px; color: #fff;
    margin: 0 auto 20px;
}

/* ============================================================
   OVERLAY & MOBILE
   ============================================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 999;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.open { display: block; }

    .main-wrapper { margin-left: 0; }

    .sidebar-toggle { display: flex; }

    .page-content { padding: 16px; }

    .topbar { padding: 0 16px; }

    .cal-grid { grid-template-columns: repeat(7, 1fr); gap: 4px; }
    .cal-day { min-height: 60px; padding: 4px; }
    .cal-meal { display: none; }
    .date-badge { display: none; }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-orange { color: var(--primary) !important; }
.bg-orange-soft { background: var(--primary-soft) !important; }
.fw-800 { font-weight: 800 !important; }
.gap-2 { gap: 8px; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h2 {
    font-size: 20px;
    margin: 0;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state i { font-size: 48px; margin-bottom: 12px; opacity: .4; }
.empty-state p  { font-size: 15px; margin: 0; }

/* Scrollbar personalizada */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }
