/* =========================================================================
   SISTEMA DE DISEÑO - SCORPION ER (Nuclear Forest & Dark Void Style)
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;600;800&display=swap');

:root {
    /* 🎨 Nueva Paleta de Colores (Referencia Imagen Adobe) */
    --brand-lava: #9ABF15;      /* Verde brillante (antes naranja) */
    --brand-forest: #6E8C03;    /* Verde base/oscuro */
    --brand-void: #0D0D0D;      /* Negro fondo profundo (Adobe #0D0D0D) */
    --brand-slate: #222224;     /* Gris oscuro para tarjetas (Adobe #3D3E40) */
    --brand-snow: #F2F2F2;      /* Blanco roto (Adobe #F2F2F2) */
    --brand-dusty: #8b8989;     /* Gris medio (Textos muted) */
    --brand-gluon: #1A1A1B;     /* Gris muy oscuro para fondos de inputs y autocompletados */
    
    --bg-body: #050505;         /* Un negro casi total para contraste */
    --bg-surface: var(--brand-void);
    --bg-card: var(--brand-slate);
    
    --accent-primary: var(--brand-lava);
    --accent-secondary: var(--brand-forest);
    
    /* Textos */
    --text-main: var(--brand-snow);
    --text-muted: var(--brand-dusty);
    --text-light: #FFFFFF;

    /* 📐 Sombras, Bordes y Espaciados - Restaurados y Mejorados */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.6);
    --radius-lg: 32px;
    --radius-md: 20px;
    --radius-sm: 12px;
    
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;

    /* 🏎️ Grid Layout Constants */
    --grid-gap: 30px; /* Aumentado de 20px a 30px para mayor aire */
}

/* =========================================================================
   RESETEOS Y TIPOGRAFÍA
   ========================================================================= */
* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Scrollbars Personalizadas */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--brand-void); }
::-webkit-scrollbar-thumb { 
    background: rgba(255, 255, 255, 0.1); 
    border-radius: 10px; 
    border: 2px solid var(--brand-void);
}
::-webkit-scrollbar-thumb:hover { background: var(--brand-lava); }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 0.5vw; /* Reducción de padding para ganar espacio */
    letter-spacing: -0.01em;
    font-size: 0.88rem; /* Tamaño base ligeramente reducido para mayor densidad de información */
    color-scheme: dark; /* Global dark mode for native UI (dropdowns, scrollbars) */
}

h1, h2, h3, h4, h5, h6 {
    color: white;
    font-family: 'Outfit', sans-serif;
}

/* =========================================================================
   COMPONENTES CORE REUTILIZABLES
   ========================================================================= */

/* Main App Wrapper */
.app-container {
    display: flex;
    width: 99.5%; /* Aumentado de 98% a 99.5% para máximo aprovechamiento */
    max-width: 1980px; /* Expandido de 1800px para pantallas ultra-wide */
    height: 98vh; /* Aprovechamiento vertical también aumentado */
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Tarjetas (Cards) */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: var(--shadow-sm);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
}

.card:hover {
    transform: translateY(-8px);
    border-color: rgba(154, 191, 21, 0.3);
    box-shadow: 0 15px 35px rgba(0,0,0,0.8), 0 0 20px rgba(154, 191, 21, 0.05);
}

.card-accent {
    background: linear-gradient(135deg, var(--brand-lava), #D35400);
    color: var(--text-light);
    border: none;
}

/* Contenedor de Registro (Centrado y Compacto) */
.registration-container {
    max-width: 1600px;
    margin: 40px auto;
    padding: 0 45px; /* Aumentado para mayor margen lateral */
    width: 100%;
}

.list-container-wide {
    max-width: 1400px;
    margin: 40px auto;
    padding: 0 20px;
    width: 100%;
}

.card-premium, .premium-card {
    background: var(--bg-card);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
    margin-bottom: 25px;
    padding: 40px; /* Añadido margen interior solicitado */
    transition: all 0.3s ease;
}

.card-premium:hover, .premium-card:hover {
    transform: translateY(-5px);
    border-color: rgba(154, 191, 21, 0.2);
    box-shadow: 0 15px 40px rgba(0,0,0,0.4);
}

.card-header-premium {
    padding: 24px 32px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.01);
    flex-wrap: wrap;
    gap: 15px;
    min-height: 80px;
}

.header-content {
    flex: 1;
    min-width: 200px;
}

.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.card-title-premium {
    font-size: 1.4rem;
    font-weight: 700;
    color: white;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-subtitle-premium {
    font-size: 0.9rem;
    color: var(--brand-dusty);
    margin: 0;
}

/* Modificadores de Espaciado */
.mb-4 { margin-bottom: var(--space-lg) !important; }
.mt-4 { margin-top: var(--space-lg) !important; }
.p-4 { padding: var(--space-lg) !important; }

/* 🌟 Premium Header System */
.premium-header-modern {
    margin-bottom: 40px;
    padding-left: 20px;
    border-left: 4px solid var(--brand-lava);
    position: relative;
}

.page-title {
    font-size: 2.2rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: -1px;
    line-height: 1.1;
    margin-bottom: 8px;
    font-family: 'Outfit', sans-serif;
}

.page-subtitle {
    color: var(--brand-dusty);
    font-size: 0.95rem;
    font-weight: 400;
    max-width: 600px;
}

.card-body-premium {
    padding: 32px;
}

.table-responsive-premium {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-premium {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table-premium th {
    background: rgba(255, 255, 255, 0.02);
    padding: 18px 25px;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--brand-dusty);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.table-premium td {
    padding: 20px 25px;
    vertical-align: middle;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.table-row-hover:hover {
    background: rgba(255, 255, 255, 0.01);
}

.td-primary {
    color: white;
    font-weight: 500;
}

.td-secondary {
    color: var(--brand-dusty);
    font-size: 0.9rem;
}

.action-group-premium {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-action-edit, .btn-action-view, .btn-action-delete {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-decoration: none;
    font-size: 1.2rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
}

.btn-action-edit:hover { background: rgba(52, 152, 219, 0.15); border-color: #3498db; transform: scale(1.1); }
.btn-action-view:hover { background: rgba(46, 204, 113, 0.15); border-color: #2ecc71; transform: scale(1.1); }
.btn-action-delete:hover { background: rgba(231, 76, 60, 0.15); border-color: #e74c3c; transform: scale(1.1); }

.badge-premium {
    background: rgba(154, 191, 21, 0.1);
    color: var(--brand-lava);
    padding: 6px 12px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.85rem;
    border: 1px solid rgba(154, 191, 21, 0.2);
}

.badge-status {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.status-success { background: rgba(46, 204, 113, 0.1); color: #2ecc71; border: 1px solid rgba(46, 204, 113, 0.2); }
.status-warning { background: rgba(241, 196, 15, 0.1); color: #f1c40f; border: 1px solid rgba(241, 196, 15, 0.2); }
.status-danger { background: rgba(231, 76, 60, 0.1); color: #e74c3c; border: 1px solid rgba(231, 76, 60, 0.2); }

/* 🔘 Premium Action Buttons */
.btn-premium-save {
    background: var(--brand-lava);
    color: var(--brand-void);
    font-weight: 700;
    padding: 12px 32px;
    border-radius: 12px;
    border: none;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(154, 191, 21, 0.2);
}

.btn-premium-save:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(154, 191, 21, 0.4);
    background: #b5e01a;
    color: var(--brand-void);
}

.btn-premium-cancel {
    background: rgba(255, 255, 255, 0.05);
    color: var(--brand-snow);
    font-weight: 600;
    padding: 12px 24px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.btn-premium-cancel:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-color: rgba(255, 255, 255, 0.2);
}

.premium-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(to bottom, var(--brand-lava), var(--brand-forest));
}

/* Grid Logic for Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--grid-gap);
    margin-bottom: 25px;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--grid-gap);
    margin-bottom: 30px;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--grid-gap);
    margin-bottom: 25px;
}

@media (max-width: 768px) {
    .form-grid-3, .form-grid-2 {
        grid-template-columns: 1fr;
    }
}

.form-group-full {
    grid-column: 1 / -1;
}

/* Botones */
.btn {
    padding: 10px 24px; /* Un poco más compactos */
    border-radius: var(--radius-sm);
    border: none;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-family: 'Outfit', sans-serif;
}

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

.btn-primary:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(245, 110, 15, 0.3);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--brand-lava);
    color: var(--brand-lava);
}

.btn-outline:hover {
    background: var(--brand-lava);
    color: #000;
}

.btn-primary {
    background-color: var(--brand-lava) !important;
    color: #000 !important; /* Texto negro para contraste sobre verde brillante */
    font-weight: 700;
}

.btn-primary:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(154, 191, 21, 0.4) !important;
}

.btn-secondary, 
.btn[style*="background:#F4F6F8"], 
.btn[style*="background: #F4F6F8"],
.btn[style*="background:#f4f6f8"] {
    background: rgba(255, 255, 255, 0.08) !important;
    color: var(--brand-snow) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15) !important;
}

/* Forzar que enlaces que parecen botones hereden colores correctos */
a.btn:not(.btn-primary):not(.btn-outline) {
    background: rgba(255, 255, 255, 0.08) !important;
    color: var(--brand-snow) !important;
}

/* Menús Flotantes de Búsqueda (Autocompletado) */
#clienteResults, #searchResults, .search-results {
    background: var(--brand-gluon) !important;
    border: 1px solid rgba(255,255,255,0.1) !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5) !important;
}

#clienteResults div, #searchResults div {
    color: var(--brand-snow) !important;
    border-bottom: 1px solid rgba(255,255,255,0.05) !important;
}

#clienteResults div:hover, #searchResults div:hover {
    background: rgba(255,255,255,0.05) !important;
}

/* Inputs y Selects - Normalización Agresiva */
.input-field, 
.form-control, 
input[type="text"], 
input[type="number"], 
input[type="email"], 
input[type="password"],
input[type="date"],
select, 
textarea {
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1.5px solid rgba(255, 255, 255, 0.1) !important;
    padding: 14px 18px !important; /* Ligeramente aumentado */
    border-radius: 14px !important; /* Más redondeado y premium */
    width: 100%;
    min-height: 52px; /* Asegura que no se aplaste */
    font-family: inherit;
    outline: none;
    font-size: 0.9rem; /* Fuente más legible */
    transition: all 0.2s;
    color: white !important;
    display: block;
    color-scheme: dark;
}

/* Forzar que las opciones del select sean visibles en modo oscuro */
select option {
    background-color: #222224 !important; /* Fondo casi negro para opciones */
    color: white !important;
    padding: 12px !important;
}

.input-field::placeholder {
    color: var(--brand-dusty);
}

.input-field:focus, 
.form-control:focus, 
input:focus, 
select:focus, 
textarea:focus {
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: var(--brand-lava) !important;
    box-shadow: 0 0 0 4px rgba(154, 191, 21, 0.15) !important;
    color: white !important;
}

/* Labels */
.form-group label, .mb-3 label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--brand-lava); /* Verde lava para labels para que resalten */
    margin-bottom: 10px;
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    opacity: 0.9;
}

/* Secciones de Formulario */
.form-section-title {
    color: var(--brand-lava);
    font-size: 0.95rem; /* Más pequeño y táctico */
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    border-bottom: 2px solid rgba(154, 191, 21, 0.1);
    padding-bottom: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Outfit', sans-serif;
}

.input-group-premium {
    position: relative;
    width: 100%;
}

.input-group-premium span.input-icon {
    position: absolute;
    left: 18px;
    bottom: 15px; /* Fijado al fondo para ignorar la altura del label */
    font-size: 1.15rem;
    opacity: 0.8;
    pointer-events: none;
    z-index: 10;
}

.input-group-premium .form-control, 
.input-group-premium select,
.input-group-premium input {
    padding-left: 52px !important; /* Espacio generoso para el icono */
}

.form-actions-container {
    display: grid;
    grid-template-columns: 1fr 1.5fr; /* Desigual como en la imagen */
    gap: 20px;
    margin-top: 40px;
    padding-top: 30px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-premium-save {
    padding: 16px 30px !important;
    border-radius: 18px !important; /* Más redondeado como la imagen */
    font-weight: 800 !important;
    background: var(--brand-lava) !important;
    border: none !important;
    color: #000 !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 20px rgba(154, 191, 21, 0.2) !important;
}

.btn-premium-cancel {
    background: rgba(34, 34, 36, 0.8) !important; /* Color brand-slate */
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: var(--brand-snow) !important;
    padding: 16px 30px !important;
    border-radius: 18px !important;
    font-weight: 700 !important;
    text-transform: uppercase;
}

/* Etiquetas de Estado (Badges) */
.badge {
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-pending { background-color: rgba(243, 156, 18, 0.15); color: #F39C12; }
.badge-completed { background-color: rgba(46, 204, 113, 0.15); color: #2ECC71; }
.badge-error { background-color: rgba(231, 76, 60, 0.15); color: #E74C3C; }
.badge-discount { background-color: rgba(154, 191, 21, 0.15); color: var(--brand-lava); margin-right: 5px; }
.badge-discount-fixed { background-color: rgba(52, 152, 219, 0.15); color: #3498DB; }

/* Mensajes de Django */
.messages {
    list-style: none;
    padding: 0;
    margin-bottom: 24px;
}
.messages li {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    font-weight: 500;
    background: rgba(46, 204, 113, 0.1);
    color: #2ECC71;
    border: 1px solid rgba(46, 204, 113, 0.2);
}

/* Menú Sidebar Específicos */
.sidebar-link {
    text-decoration: none;
    color: var(--brand-dusty);
    padding: 12px 18px; /* Menos espacio vertical */
    display: flex;
    align-items: center;
    gap: 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    font-size: 0.88rem;
}

.sidebar-link:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-link.active {
    color: white;
    background: rgba(154, 191, 21, 0.1);
    font-weight: 600;
}

.sidebar-link.active::after {
    content: "";
    position: absolute;
    right: 18px;
    width: 6px;
    height: 6px;
    background-color: var(--brand-lava);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--brand-lava);
}

/* Tablas Modernas */
.table-modern {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    color: var(--brand-snow);
    margin-top: 10px;
}

.table-modern thead th {
    background: rgba(255, 255, 255, 0.03);
    padding: 18px 15px;
    color: var(--brand-dusty);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 1.2px;
    border-bottom: 2px solid rgba(154, 191, 21, 0.2);
    text-align: left;
}

.table-modern thead th:first-child { border-radius: 12px 0 0 0; }
.table-modern thead th:last-child { border-radius: 0 12px 0 0; }

.table-modern tbody td {
    padding: 16px 15px;
    background: transparent;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.9rem;
    vertical-align: middle;
}

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

.table-modern tbody tr:hover td {
    background: rgba(154, 191, 21, 0.03);
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px;
    color: var(--brand-snow);
}

thead tr {
    background: transparent !important;
}

thead th {
    border: none !important;
}

th {
    padding: 12px 15px;
    color: var(--brand-dusty);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 1px;
}

td {
    padding: 12px 15px; /* Reducido de 16px a 12px para mayor densidad */
    background: rgba(255, 255, 255, 0.055) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.02) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02) !important;
    color: var(--brand-snow);
}

tr {
    background: transparent !important;
    border: none !important;
}

tr td:first-child { border-left: 1px solid rgba(255, 255, 255, 0.03); border-radius: 12px 0 0 12px; }
tr td:last-child { border-right: 1px solid rgba(255, 255, 255, 0.03); border-radius: 0 12px 12px 0; }

/* Autocompletado Premium */
.premium-autocomplete-results {
    position: absolute;
    width: 100%;
    background: var(--brand-gluon);
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-height: 250px;
    overflow-y: auto;
    border-radius: var(--radius-sm);
    z-index: 1001;
    margin-top: 5px;
    box-shadow: var(--shadow-md);
}

.premium-autocomplete-results div {
    padding: 12px 16px;
    cursor: pointer;
    color: var(--brand-snow);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.2s;
}

.premium-autocomplete-results div:hover {
    background: rgba(154, 191, 21, 0.1);
    color: var(--brand-lava);
}

/* Secciones Técnicas Especiales */
.premium-tech-section {
    background: rgba(110, 140, 3, 0.03);
    border: 1px solid rgba(110, 140, 3, 0.1);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
}

/* =========================================================================
   ESTILOS RESPONSIVOS
   ========================================================================= */
@media (max-width: 992px) {
    .app-container { border-radius: 0; min-height: 100vh; height: auto; }
}

/* 📊 Summary Cards (Para Cotizaciones/Ventas) */
.summary-actions-grid {
    display: flex;
    justify-content: flex-end;
    margin-top: 40px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 30px;
}

.summary-premium-card {
    background: rgba(0, 0, 0, 0.2);
    padding: 30px;
    border-radius: 24px;
    min-width: 400px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: var(--shadow-sm);
}

.summary-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 1.1rem;
    color: var(--brand-dusty);
}

.summary-value {
    font-weight: 600;
    color: var(--brand-snow);
}

.summary-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(154, 191, 21, 0.3), transparent);
    margin: 20px 0;
}

.summary-total {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--brand-lava);
    letter-spacing: -1px;
}

.w-100 { width: 100% !important; }
