@import url('https://fonts.googleapis.com/css2?family=Heebo:wght@300;400;500;600;700&display=swap');

/* ── Variables ───────────────────────────────────────── */
:root {
    --wine: #6a2831;
    --wine-dark: #4e1e25;
    --wine-light: #8a3040;
    --gold: #d4af37;
    --gold-soft: #bfa76a;
    --cream: #F0E7DA;
    --bg: #f6f3ee;
    --white: #ffffff;
    --text: #2b2b2b;
    --muted: #7a7a7a;
    --border: #e2ddd4;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.07);
    --trans: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --green: #2d7a4f;
    --red: #c0392b;
    --yellow: #e67e22;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* HEADER PRINCIPAL */
.main-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: var(--cream);
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.logo {
    width: 180px;
    padding: 10px 20px;
}

.nav-container {
    display: flex;
    justify-content: flex-end;
}

.nav-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-menu li a {
    padding: 15px 20px;
    text-decoration: none;
    color: var(--wine);
    font-size: 18px;
    transition: all 0.3s ease;
}

.nav-menu li a:hover {
    background-color: var(--wine);
    color: var(--cream);
}

body {
    font-family: 'Heebo', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding-top: 140px;
}

/* ── Pantalla de login ───────────────────────────────── */
#loginScreen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--wine-dark) 0%, var(--wine) 60%, #8a3040 100%);
    padding: 20px;
}

.login-box {
    background: var(--white);
    border-radius: 20px;
    padding: 48px 40px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.login-logo {
    font-family: 'Kiona', sans-serif;
    font-size: 1.6rem;
    letter-spacing: 0.14em;
    color: var(--wine);
    margin-bottom: 4px;
}

.login-subtitle {
    font-size: 0.78rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--gold-soft);
    margin-bottom: 32px;
}

.login-field {
    position: relative;
    margin-bottom: 16px;
}

.login-field i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 1rem;
}

.login-input {
    width: 100%;
    padding: 13px 14px 13px 42px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'Heebo', sans-serif;
    font-size: 0.95rem;
    background: var(--bg);
    outline: none;
    transition: var(--trans);
}

.login-input:focus {
    border-color: var(--gold-soft);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.12);
}

.btn-login {
    width: 100%;
    background: var(--wine);
    color: var(--cream);
    border: none;
    border-radius: var(--radius-sm);
    padding: 13px;
    font-family: 'Heebo', sans-serif;
    font-size: 0.95rem;
    letter-spacing: 0.06em;
    cursor: pointer;
    transition: var(--trans);
    margin-top: 8px;
}

.btn-login:hover {
    background: var(--wine-light);
}

.login-error {
    color: var(--red);
    font-size: 0.82rem;
    margin-top: 10px;
    display: none;
}

/* ── Layout principal ────────────────────────────────── */
#adminPanel {
    display: none;
}

.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.admin-sidebar {
    width: 240px;
    background: var(--wine-dark);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 140px;
    left: 0;
    height: calc(100vh - 140px);
    z-index: 100;
    transition: var(--trans);
}

.sidebar-brand {
    padding: 28px 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand-name {
    font-family: 'Kiona', sans-serif;
    font-size: 1.1rem;
    letter-spacing: 0.12em;
    color: var(--cream);
}

.sidebar-brand-sub {
    font-size: 0.68rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(212, 175, 55, 0.7);
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-section-label {
    font-size: 0.62rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.3);
    padding: 12px 12px 6px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, 0.65);
    text-decoration: none;
    font-size: 0.88rem;
    cursor: pointer;
    transition: var(--trans);
    margin-bottom: 2px;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.sidebar-link i {
    font-size: 1rem;
    width: 20px;
}

.sidebar-link:hover,
.sidebar-link.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--cream);
}

.sidebar-link.active {
    background: rgba(212, 175, 55, 0.15);
    color: var(--gold);
}

.sidebar-badge {
    margin-left: auto;
    background: var(--gold);
    color: var(--wine-dark);
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 50px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.82rem;
    cursor: pointer;
    background: none;
    border: none;
    transition: var(--trans);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    width: 100%;
}

.btn-logout:hover {
    color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.06);
}

/* Contenido principal */
.admin-main {
    flex: 1;
    margin-left: 240px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.admin-topbar {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.topbar-title {
    font-family: 'Kiona', sans-serif;
    font-size: 1rem;
    letter-spacing: 0.06em;
    color: var(--wine);
}

.topbar-date {
    font-size: 0.8rem;
    color: var(--muted);
}

.admin-content {
    padding: 32px;
    flex: 1;
}

/* ── Secciones ───────────────────────────────────────── */
.admin-section {
    display: none;
}

.admin-section.active {
    display: block;
}

/* ── Cards métricas ──────────────────────────────────── */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.metric-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.metric-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.metric-icon.wine {
    background: rgba(106, 40, 49, 0.1);
    color: var(--wine);
}

.metric-icon.gold {
    background: rgba(212, 175, 55, 0.1);
    color: var(--gold);
}

.metric-icon.green {
    background: rgba(45, 122, 79, 0.1);
    color: var(--green);
}

.metric-icon.red {
    background: rgba(192, 57, 43, 0.1);
    color: var(--red);
}

.metric-value {
    font-family: 'Kiona', sans-serif;
    font-size: 1.8rem;
    color: var(--text);
    line-height: 1;
}

.metric-label {
    font-size: 0.78rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
}

/* ── Semáforo inventario ─────────────────────────────── */
.inventory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.inv-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.inv-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.inv-card-name {
    font-size: 0.82rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
}

.semaforo {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.semaforo.green {
    background: #27ae60;
    box-shadow: 0 0 6px rgba(39, 174, 96, 0.5);
}

.semaforo.yellow {
    background: #f39c12;
    box-shadow: 0 0 6px rgba(243, 156, 18, 0.5);
}

.semaforo.red {
    background: #e74c3c;
    box-shadow: 0 0 6px rgba(231, 76, 60, 0.5);
}

.inv-card-qty {
    font-family: 'Kiona', sans-serif;
    font-size: 1.6rem;
    color: var(--text);
    line-height: 1;
}

.inv-card-unit {
    font-size: 0.78rem;
    color: var(--muted);
}

/* Barra de progreso stock */
.inv-bar-wrap {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.inv-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.inv-bar.green { background: #27ae60; }
.inv-bar.yellow { background: #f39c12; }
.inv-bar.red { background: #e74c3c; }

.inv-card-alert {
    font-size: 0.72rem;
    color: var(--red);
    display: none;
}

.inv-card-alert.visible {
    display: block;
}

/* ── Tablas ──────────────────────────────────────────── */
.admin-table-wrap {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.admin-table-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.admin-table-title {
    font-family: 'Kiona', sans-serif;
    font-size: 0.95rem;
    letter-spacing: 0.05em;
    color: var(--wine);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th {
    background: var(--bg);
    padding: 12px 16px;
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-weight: 500;
}

.admin-table td {
    padding: 14px 16px;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.admin-table tr:last-child td {
    border-bottom: none;
}

.admin-table tr:hover td {
    background: #fafaf8;
}

/* ── Botones ─────────────────────────────────────────── */
.btn-pr {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-family: 'Heebo', sans-serif;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--trans);
    border: none;
    letter-spacing: 0.04em;
}

.btn-pr-wine {
    background: var(--wine);
    color: var(--cream);
}

.btn-pr-wine:hover {
    background: var(--wine-light);
    transform: translateY(-1px);
}

.btn-pr-gold {
    background: var(--gold);
    color: var(--wine-dark);
}

.btn-pr-gold:hover {
    background: #c9a430;
    transform: translateY(-1px);
}

.btn-pr-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
}

.btn-pr-outline:hover {
    border-color: var(--wine);
    color: var(--wine);
}

.btn-pr-green {
    background: var(--green);
    color: #fff;
}

.btn-pr-green:hover {
    background: #236040;
}

.btn-pr-red {
    background: var(--red);
    color: #fff;
}

.btn-pr-red:hover {
    background: #a93226;
}

.btn-pr-sm {
    padding: 6px 12px;
    font-size: 0.78rem;
}

/* ── Formularios ─────────────────────────────────────── */
.admin-form-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 24px;
}

.admin-form-title {
    font-family: 'Kiona', sans-serif;
    font-size: 0.95rem;
    letter-spacing: 0.05em;
    color: var(--wine);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-label {
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
}

.field-input,
.field-select,
.field-textarea {
    padding: 10px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'Heebo', sans-serif;
    font-size: 0.9rem;
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: var(--trans);
    width: 100%;
}

.field-input:focus,
.field-select:focus,
.field-textarea:focus {
    border-color: var(--gold-soft);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.1);
}

.field-textarea {
    resize: vertical;
    min-height: 80px;
}

/* ── Badges estado ───────────────────────────────────── */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 50px;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    font-weight: 500;
}

.badge-pending {
    background: rgba(230, 126, 34, 0.12);
    color: var(--yellow);
}

.badge-approved {
    background: rgba(45, 122, 79, 0.12);
    color: var(--green);
}

.badge-manual {
    background: rgba(106, 40, 49, 0.12);
    color: var(--wine);
}

.badge-online {
    background: rgba(45, 122, 79, 0.12);
    color: var(--green);
}

/* ── Historial ───────────────────────────────────────── */
.history-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.history-item:last-child {
    border-bottom: none;
}

.history-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
}

.history-dot.in { background: var(--green); }
.history-dot.out { background: var(--red); }

.history-info {
    flex: 1;
}

.history-title {
    font-size: 0.88rem;
    color: var(--text);
    font-weight: 500;
}

.history-meta {
    font-size: 0.76rem;
    color: var(--muted);
    margin-top: 2px;
}

.history-amount {
    font-family: 'Kiona', sans-serif;
    font-size: 0.9rem;
}

.history-amount.in { color: var(--green); }
.history-amount.out { color: var(--red); }

/* ── Toast ───────────────────────────────────────────── */
.admin-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--wine-dark);
    color: var(--cream);
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 0.88rem;
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
}

.admin-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
    .admin-sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }

    .admin-main {
        margin-left: 0;
    }

    .admin-layout {
        flex-direction: column;
    }

    .admin-content {
        padding: 20px 16px;
    }

    .admin-topbar {
        padding: 14px 16px;
    }
}

/* Stars display */
.stars-gold {
    color: var(--gold);
    letter-spacing: 2px;
}

/* Sección insumos manuales */
.manual-supply-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 12px;
}

.manual-supply-row:last-child {
    border-bottom: none;
}

.manual-supply-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
}

.manual-supply-meta {
    font-size: 0.78rem;
    color: var(--muted);
}

.manual-supply-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.qty-inline {
    width: 80px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    text-align: center;
    outline: none;
    background: var(--bg);
    transition: var(--trans);
}

.qty-inline:focus {
    border-color: var(--gold-soft);
    background: var(--white);
}

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--muted);
}

.empty-state i {
    font-size: 2rem;
    opacity: 0.3;
    display: block;
    margin-bottom: 12px;
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Validación de campos requeridos ─────────────────── */
.field-input.invalid,
.field-select.invalid,
.field-textarea.invalid {
    border-color: var(--red);
    background: rgba(192, 57, 43, 0.04);
}

.field-required-note {
    font-size: 0.7rem;
    color: var(--red);
    margin-top: 2px;
    display: none;
}

.field-required-note.visible {
    display: block;
}