/* ================================================================
   app.css — Panderetas Pro | Design System
   Fuentes: Sora (display) + DM Mono (datos)
   Paleta: Dark steel azul + Naranja constructor
   ================================================================ */

:root {
    --color-bg:        #0f1117;
    --color-surface:   #1a1d27;
    --color-surface2:  #232736;
    --color-border:    #2d3149;
    --color-primary:   #f97316;   /* naranja construcción */
    --color-primary-d: #c2610c;
    --color-primary-l: #fed7aa;
    --color-accent:    #38bdf8;   /* celeste técnico */
    --color-success:   #22c55e;
    --color-danger:    #ef4444;
    --color-warning:   #eab308;
    --color-info:      #38bdf8;
    --color-text:      #e2e8f0;
    --color-muted:     #64748b;
    --color-nav:       #111520;
    --font-body:       'Sora', sans-serif;
    --font-mono:       'DM Mono', monospace;
    --radius:          12px;
    --radius-sm:       8px;
    --nav-h:           64px;
    --shadow:          0 4px 24px rgba(0,0,0,.4);
    --shadow-glow:     0 0 20px rgba(249,115,22,.15);
}

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

html { scroll-behavior: smooth; }

body {
    background-color: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: 0.925rem;
    line-height: 1.6;
    min-height: 100vh;
}

/* ── Navbar ────────────────────────────────────────────────── */
.app-navbar {
    background: var(--color-nav);
    border-bottom: 1px solid var(--color-border);
    height: var(--nav-h);
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(12px);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    text-decoration: none;
}

.brand-icon {
    font-size: 1.5rem;
    color: var(--color-primary);
    animation: pulse-icon 3s ease-in-out infinite;
}

@keyframes pulse-icon {
    0%, 100% { opacity: 1; }
    50% { opacity: .6; }
}

.brand-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -.02em;
}

.brand-accent { color: var(--color-primary); }

.nav-link {
    color: var(--color-muted) !important;
    font-size: .85rem;
    font-weight: 500;
    padding: .4rem .75rem !important;
    border-radius: var(--radius-sm);
    transition: all .2s;
}

.nav-link:hover,
.nav-link.active {
    color: var(--color-text) !important;
    background: var(--color-surface2);
}

.nav-link.active {
    color: var(--color-primary) !important;
    background: rgba(249,115,22,.1);
}

/* Avatar círculo */
.avatar-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px; height: 34px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-d));
    border-radius: 50%;
    font-weight: 700;
    font-size: .85rem;
    color: white;
}

/* ── Main content ─────────────────────────────────────────── */
.main-content {
    min-height: calc(100vh - var(--nav-h) - 48px);
    padding: 1.5rem;
}

@media (min-width: 992px) {
    .main-content { padding: 2rem 2.5rem; }
}

/* ── Footer ────────────────────────────────────────────────── */
.app-footer {
    padding: .75rem 0;
    border-top: 1px solid var(--color-border);
    margin-top: auto;
}

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

.card-header {
    background: var(--color-surface2);
    border-bottom: 1px solid var(--color-border);
    border-radius: var(--radius) var(--radius) 0 0 !important;
    padding: 1rem 1.25rem;
    font-weight: 600;
}

/* Stat cards (KPIs) */
.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    position: relative;
    overflow: hidden;
    transition: transform .2s, box-shadow .2s;
}

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

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--card-accent, var(--color-primary));
}

.stat-card.accent-success::before { --card-accent: var(--color-success); }
.stat-card.accent-danger::before  { --card-accent: var(--color-danger); }
.stat-card.accent-info::before    { --card-accent: var(--color-info); }
.stat-card.accent-warning::before { --card-accent: var(--color-warning); }

.stat-label {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--color-muted);
}

.stat-value {
    font-size: 1.9rem;
    font-weight: 700;
    font-family: var(--font-mono);
    line-height: 1.2;
    color: var(--color-text);
}

.stat-icon {
    font-size: 2rem;
    opacity: .15;
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
}

/* ── Tablas ────────────────────────────────────────────────── */
.table {
    color: var(--color-text);
    --bs-table-bg: transparent;
    --bs-table-striped-bg: rgba(255,255,255,.02);
    --bs-table-hover-bg: rgba(249,115,22,.05);
    --bs-table-border-color: var(--color-border);
}

.table thead th {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--color-muted);
    border-bottom: 2px solid var(--color-border);
    padding: .75rem 1rem;
}

.table tbody td {
    padding: .75rem 1rem;
    vertical-align: middle;
    border-color: var(--color-border);
}

/* ── Formularios ────────────────────────────────────────────── */
.form-control,
.form-select {
    background: var(--color-surface2);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    border-radius: var(--radius-sm);
    padding: .6rem .9rem;
    transition: border-color .2s, box-shadow .2s;
}

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

.form-control::placeholder { color: var(--color-muted); }

.form-label {
    font-size: .82rem;
    font-weight: 600;
    color: var(--color-muted);
    margin-bottom: .35rem;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.form-select option { background: var(--color-surface2); }

/* ── Botones ────────────────────────────────────────────────── */
.btn {
    font-weight: 600;
    font-size: .875rem;
    border-radius: var(--radius-sm);
    padding: .5rem 1.1rem;
    transition: all .2s;
    letter-spacing: .01em;
}

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

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

.btn-outline-secondary {
    border-color: var(--color-border);
    color: var(--color-muted);
}

.btn-outline-secondary:hover {
    background: var(--color-surface2);
    color: var(--color-text);
    border-color: var(--color-muted);
}

/* ── Badges de estado ───────────────────────────────────────── */
.badge-estado {
    font-size: .72rem;
    font-weight: 600;
    padding: .3em .7em;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.estado-contacto_inicial { background:

/* ── Alertas de stock ───────────────────────────────────────── */
.stock-alert-badge {
    background: rgba(239,68,68,.15);
    color: var(--color-danger);
    border: 1px solid rgba(239,68,68,.2);
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 700;
    padding: .25em .6em;
}

/* ── Página de login ────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
    padding: 1rem;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 20px;
    padding: 2.5rem;
    box-shadow: var(--shadow), 0 0 60px rgba(249,115,22,.08);
}

.login-logo {
    font-size: 3rem;
    text-align: center;
    margin-bottom: .5rem;
}

.login-title {
    font-size: 1.6rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: -.03em;
}

/* ── Dashboard worker (mobile-first) ────────────────────────── */
.week-meter-ring {
    width: 160px;
    height: 160px;
    margin: 0 auto;
    position: relative;
}

.week-meter-ring svg { transform: rotate(-90deg); }

.week-meter-value {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 1.6rem;
    color: var(--color-text);
}

.week-meter-label {
    font-size: .7rem;
    color: var(--color-muted);
    display: block;
    font-family: var(--font-body);
    font-weight: 500;
}

/* ── Rentabilidad indicador ─────────────────────────────────── */
.margen-bar {
    height: 6px;
    background: var(--color-border);
    border-radius: 999px;
    overflow: hidden;
}

.margen-bar-fill {
    height: 100%;
    border-radius: 999px;
    transition: width .5s ease;
}

.margen-positivo .margen-bar-fill { background: var(--color-success); }
.margen-neutro .margen-bar-fill   { background: var(--color-warning); }
.margen-negativo .margen-bar-fill { background: var(--color-danger); }

/* ── Dropdown oscuro ────────────────────────────────────────── */
.dropdown-menu {
    background: var(--color-surface2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}

.dropdown-item {
    color: var(--color-text);
    font-size: .875rem;
    padding: .5rem 1rem;
    transition: background .15s;
}

.dropdown-item:hover {
    background: rgba(255,255,255,.05);
    color: var(--color-text);
}

.dropdown-item.text-danger:hover { background: rgba(239,68,68,.1); }

.dropdown-divider { border-color: var(--color-border); }
.dropdown-item-text { font-size: .8rem; }

/* ── Alertas override ───────────────────────────────────────── */
.alert {
    border-radius: var(--radius-sm);
    border: none;
    font-size: .875rem;
}

.alert-success { background: rgba(34,197,94,.12); color: #86efac; }
.alert-danger  { background: rgba(239,68,68,.12); color: #fca5a5; }
.alert-warning { background: rgba(234,179,8,.12); color: #fde68a; }
.alert-info    { background: rgba(56,189,248,.12); color: #7dd3fc; }

/* ── Chart containers ───────────────────────────────────────── */
.chart-container {
    position: relative;
    height: 280px;
    width: 100%;
}

/* ── Página de título ───────────────────────────────────────── */
.page-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .75rem;
}

.page-title {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -.03em;
    margin: 0;
}

.page-title .icon {
    color: var(--color-primary);
    margin-right: .4rem;
}

/* ── Animaciones ─────────────────────────────────────────────── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.fade-in-up { animation: fadeInUp .35s ease both; }

.fade-in-up:nth-child(1) { animation-delay: .05s; }
.fade-in-up:nth-child(2) { animation-delay: .10s; }
.fade-in-up:nth-child(3) { animation-delay: .15s; }
.fade-in-up:nth-child(4) { animation-delay: .20s; }

/* ── Scrollbar personalizado ────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--color-bg); }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-muted); }

/* ── Utilities extra ────────────────────────────────────────── */
.mono { font-family: var(--font-mono); }
.text-primary-custom { color: var(--color-primary); }
.text-accent { color: var(--color-accent); }

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

/* Modal oscuro */
.modal-content {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.modal-header {
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface2);
}

.modal-footer {
    border-top: 1px solid var(--color-border);
}

.btn-close { filter: invert(1); }
