/* 
 * Sistema de Garantías - Estilos Vanilla CSS Premium (Glassmorphism)
 */

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

:root {
    /* Paleta de Colores (Diseño Moderno HSL) */
    --bg-dark: #070512;
    --bg-grid: #0d0a21;
    --glass-bg: rgba(18, 14, 38, 0.45);
    --glass-bg-hover: rgba(26, 20, 54, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-border-focus: rgba(168, 85, 247, 0.4);
    
    --primary-grad: linear-gradient(135deg, #a855f7 0%, #6366f1 100%);
    --secondary-grad: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
    --accent-grad: linear-gradient(135deg, #f43f5e 0%, #ec4899 100%);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.15);
    --warning: #f59e0b;
    --warning-glow: rgba(245, 158, 11, 0.15);
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.15);
    
    --font-sans: 'Outfit', 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    --shadow-main: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --shadow-glow: 0 0 15px rgba(168, 85, 247, 0.2);
}

/* 1. Estilos Base del Documento */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Fondos y Blobs de Luz Dinámicos (Efecto de profundidad) */
body::before {
    content: '';
    position: absolute;
    width: 450px;
    height: 450px;
    background: radial-gradient(circle, rgba(168, 85, 247, 0.18) 0%, rgba(0,0,0,0) 70%);
    top: -100px;
    right: -100px;
    z-index: -1;
    pointer-events: none;
    animation: floatBlob 20s infinite alternate;
}

body::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.14) 0%, rgba(0,0,0,0) 70%);
    bottom: -50px;
    left: -100px;
    z-index: -1;
    pointer-events: none;
    animation: floatBlob 25s infinite alternate-reverse;
}

@keyframes floatBlob {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 40px) scale(1.1); }
}

a {
    color: #a855f7;
    text-decoration: none;
    transition: var(--transition-smooth);
}

a:hover {
    color: #c084fc;
    text-shadow: 0 0 8px rgba(168, 85, 247, 0.3);
}

/* 2. Contenedor e Layouts */
header {
    padding: 20px 40px;
    background: rgba(7, 5, 18, 0.6);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(90deg, #a855f7, #06b6d4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-icon {
    font-size: 1.8rem;
}

.main-container {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 30px 20px;
}

/* 3. Estilo Glassmorphism (Tarjetas) */
.glass-panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    padding: 30px;
    box-shadow: var(--shadow-main);
    transition: var(--transition-smooth);
}

.glass-panel:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.glass-panel-interactive {
    cursor: pointer;
}

.glass-panel-interactive:hover {
    background: var(--glass-bg-hover);
    transform: translateY(-4px);
    border-color: var(--glass-border-focus);
    box-shadow: var(--shadow-glow);
}

/* 4. Formularios y Campos de Entrada */
.form-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-field {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    transition: var(--transition-smooth);
    outline: none;
}

.input-field:focus {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--glass-border-focus);
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.15);
}

textarea.input-field {
    resize: vertical;
    min-height: 100px;
}

select.input-field option {
    background-color: var(--bg-dark);
    color: var(--text-primary);
}

/* 5. Botones y Elementos Interactivos */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 10px;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition-smooth);
    outline: none;
    text-align: center;
}

.btn-primary {
    background: var(--primary-grad);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(168, 85, 247, 0.5);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
}

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

.btn-accent {
    background: var(--secondary-grad);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.3);
}

.btn-accent:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(6, 182, 212, 0.5);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.3);
    border-color: rgba(239, 68, 68, 0.6);
}

.btn-disabled, .btn:disabled {
    background: rgba(255, 255, 255, 0.02) !important;
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
    color: var(--text-muted) !important;
    cursor: not-allowed !important;
    box-shadow: none !important;
    transform: none !important;
}

/* 6. Badges de Estado */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-active {
    background-color: var(--success-glow);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.1);
}

.badge-expired {
    background-color: var(--danger-glow);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.1);
}

.badge-voided {
    background-color: var(--warning-glow);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.1);
}

/* 7. Vistas del Escáner y Sección Pública */
.public-card {
    max-width: 600px;
    width: 100%;
    margin: 40px auto;
}

.scanner-box {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    border-radius: 12px;
    overflow: hidden;
    background: #020108;
    border: 2px dashed rgba(255, 255, 255, 0.15);
    margin-bottom: 20px;
}

.scanner-box video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Línea de escaneo animada */
.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    box-shadow: inset 0 0 60px rgba(168, 85, 247, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.scanner-laser {
    position: absolute;
    width: 90%;
    height: 3px;
    background: #06b6d4;
    box-shadow: 0 0 12px 2px #06b6d4;
    animation: laserScan 2.5s infinite linear;
}

@keyframes laserScan {
    0% { top: 5%; }
    50% { top: 95%; }
    100% { top: 5%; }
}

.scan-frame {
    width: 250px;
    height: 250px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 16px;
    position: relative;
}

.scan-frame::before, .scan-frame::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-color: #a855f7;
    border-style: solid;
}

/* Esquinas iluminadas para la cámara */
.scan-frame::before {
    top: -2px; left: -2px;
    border-width: 3px 0 0 3px;
    border-top-left-radius: 8px;
}
.scan-frame::after {
    bottom: -2px; right: -2px;
    border-width: 0 3px 3px 0;
    border-bottom-right-radius: 8px;
}

/* 8. Panel de Administración y Grids */
.admin-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 30px;
    align-items: start;
}

@media (max-width: 992px) {
    .admin-layout {
        grid-template-columns: 1fr;
    }
}

.admin-header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.admin-title-area h2 {
    font-size: 1.8rem;
    font-weight: 700;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
}

.product-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
}

.product-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.product-card-body h3 {
    font-size: 1.25rem;
    margin-bottom: 8px;
    font-weight: 600;
}

.product-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 15px;
}

.product-meta span strong {
    color: var(--text-primary);
}

.product-card-footer {
    display: flex;
    gap: 10px;
    margin-top: auto;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* 9. Historial y Línea de Tiempo (Events) */
.timeline {
    position: relative;
    padding-left: 20px;
    margin-top: 15px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 5px;
    bottom: 5px;
    width: 2px;
    background: rgba(255, 255, 255, 0.08);
}

.timeline-item {
    position: relative;
    padding-bottom: 20px;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-dot {
    position: absolute;
    left: -20px;
    top: 5px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
}

.timeline-dot.creacion { background: #3b82f6; box-shadow: 0 0 8px #3b82f6; }
.timeline-dot.mantenimiento { background: #06b6d4; box-shadow: 0 0 8px #06b6d4; }
.timeline-dot.reparacion { background: #a855f7; box-shadow: 0 0 8px #a855f7; }
.timeline-dot.comentario { background: var(--text-muted); }

.timeline-content {
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    padding: 12px;
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.timeline-type {
    font-weight: 600;
    text-transform: uppercase;
}

/* 10. Vista Detalle de Garantía (Público y Detalle Admin) */
.warranty-status-panel {
    text-align: center;
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 25px;
}

.warranty-status-panel.active {
    background: radial-gradient(circle at center, rgba(16, 185, 129, 0.08) 0%, rgba(16, 185, 129, 0.02) 100%);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.warranty-status-panel.expired {
    background: radial-gradient(circle at center, rgba(239, 68, 68, 0.08) 0%, rgba(239, 68, 68, 0.02) 100%);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.warranty-status-panel.voided {
    background: radial-gradient(circle at center, rgba(245, 158, 11, 0.08) 0%, rgba(245, 158, 11, 0.02) 100%);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.warranty-days {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1;
    margin: 15px 0 5px;
    background: var(--primary-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.warranty-days-expired {
    font-size: 2.5rem;
    font-weight: 800;
    color: #ef4444;
    margin: 15px 0 5px;
}

/* 11. Modal Glassmorphic */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(4, 3, 10, 0.8);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.25s ease-out;
}

.modal-content {
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: scaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleUp {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.modal-close:hover {
    color: var(--text-primary);
}

/* 12. Estilos para Generador de QR */
.qr-container {
    background: #ffffff;
    padding: 15px;
    border-radius: 8px;
    display: inline-block;
    margin: 15px 0;
}

/* Indicador de carga de IA (Pulse) */
.ai-loading-container {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    color: #a855f7;
    margin-top: 10px;
}

.ai-pulse-dot {
    width: 8px;
    height: 8px;
    background-color: #a855f7;
    border-radius: 50%;
    animation: pulse 1.4s infinite ease-in-out both;
}

.ai-pulse-dot:nth-child(2) { animation-delay: 0.2s; }
.ai-pulse-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

/* Barra de Búsqueda */
.search-wrapper {
    position: relative;
    max-width: 400px;
    width: 100%;
}

.search-wrapper input {
    padding-left: 40px;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* Estilos de Notificación Flotante (Toast) */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: rgba(18, 14, 38, 0.9);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    border-radius: 10px;
    padding: 16px 24px;
    color: var(--text-primary);
    box-shadow: var(--shadow-main);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    max-width: 400px;
    animation: slideInRight 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-info { border-left: 4px solid #3b82f6; }

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Pestañas de Navegación del Panel Admin */
.admin-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 25px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 5px;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 600;
    padding: 8px 18px;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    border-bottom: 2px solid transparent;
    transition: var(--transition-smooth);
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.tab-btn.active {
    color: var(--text-primary);
    border-bottom: 2px solid #a855f7;
    background: rgba(168, 85, 247, 0.06);
}

/* Footer del Sitio */
footer {
    text-align: center;
    padding: 30px;
    font-size: 0.85rem;
    color: var(--text-muted);
    border-top: 1px solid rgba(255, 255, 255, 0.03);
    margin-top: auto;
}

/* Estilos para buscadores dinámicos interactivos */
.search-results-list {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    z-index: 100;
    max-height: 180px;
    overflow-y: auto;
    background: rgba(15, 11, 35, 0.98);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.search-result-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: var(--transition-smooth);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    text-align: left;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: rgba(168, 85, 247, 0.12);
    color: var(--text-primary);
}

.search-result-item strong {
    color: var(--text-primary);
}

.selected-badge {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-top: 10px;
    animation: fadeIn 0.3s ease;
}

.selected-badge.client {
    background: rgba(168, 85, 247, 0.08);
    border: 1px solid rgba(168, 85, 247, 0.2);
    color: #c084fc;
}

.selected-badge.catalog {
    background: rgba(6, 182, 212, 0.08);
    border: 1px solid rgba(6, 182, 212, 0.2);
    color: #22d3ee;
}

.selected-badge-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    transition: var(--transition-smooth);
}

.selected-badge-close:hover {
    color: var(--danger);
}
