/* ============================================
   SolisTech PRO - Custom Styles
   Premium Glassmorphism + Dark Mode Design
   ============================================ */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500&display=swap');

/* ============================================
   CSS Variables (Design System)
   ============================================ */
:root {
    /* Paleta Principal */
    --primary: #a855f7;           /* Purple 500 */
    --primary-dark: #7c3aed;      /* Purple 600 */
    --primary-light: #c084fc;     /* Purple 300 */
    --primary-glow: rgba(168, 85, 247, 0.4);
    --primary-glow-intense: rgba(168, 85, 247, 0.8);
    
    /* Fondos Glass */
    --glass-bg: rgba(15, 23, 42, 0.6);
    --glass-bg-dark: rgba(30, 41, 59, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-border-hover: rgba(168, 85, 247, 0.3);
    
    /* Textos */
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --text-subtle: rgba(255, 255, 255, 0.05);
    
    /* Z-Index Layers */
    --z-back: -1;
    --z-normal: 1;
    --z-modal: 1000;
    --z-toast: 9999;
}

/* ============================================
   Base Styles & Reset
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #f1f5f9;
    overflow-x: hidden;
    background: radial-gradient(circle at top left, #1e1b4b, #0f172a);
    min-height: 100vh;
}

/* Fondo animado de gradiente sutil */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 50%, rgba(168, 85, 247, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(124, 58, 237, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

/* ============================================
   Glassmorphism Effects Premium
   ============================================ */
.glass-panel {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
}

/* Brillo superior para dar volumen */
.glass-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, 
        rgba(255, 255, 255, 0) 0%, 
        rgba(255, 255, 255, 0.2) 50%, 
        rgba(255, 255, 255, 0) 100%);
    pointer-events: none;
}

.glass-panel:hover {
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.15), 0 4px 30px rgba(0, 0, 0, 0.5);
    border-color: rgba(168, 85, 247, 0.3);
    transition: all 0.3s ease;
}

/* ============================================
   Bento Grid Layout (Orden Modular)
   ============================================ */

.bento-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    grid-auto-rows: 220px;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Items pequeños (1x1) */
.bento-item {
    grid-column: span 1;
    grid-row: span 1;
}

/* Items grandes (2x2) - Gráficos */
.bento-lg {
    grid-column: span 2;
    grid-row: span 2;
}

/* Responsive: En tablet y móvil */
@media (max-width: 1280px) {
    .bento-grid {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
        grid-auto-rows: 200px;
    }

    .bento-lg {
        grid-column: span 2;
        grid-row: span 2;
    }
}

@media (max-width: 1024px) {
    .bento-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: 200px;
        gap: 1rem;
    }

    .bento-lg {
        grid-column: span 2;
        grid-row: span 1;
    }
}

@media (max-width: 768px) {
    .bento-grid {
        grid-template-columns: 1fr;
        grid-auto-rows: auto;
        gap: 1rem;
    }

    .bento-item {
        min-height: 180px;
    }

    .bento-lg {
        grid-column: span 1;
        grid-row: auto;
        min-height: 300px;
    }
}

/* ============================================
   Navigation Buttons
   ============================================ */
.nav-btn {
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.nav-btn:hover {
    background: rgba(168, 85, 247, 0.2);
    border-color: rgba(168, 85, 247, 0.4);
    color: #e9d5ff;
    transform: translateY(-2px);
}

.nav-btn.active {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.4), rgba(124, 58, 237, 0.4));
    border-color: rgba(168, 85, 247, 0.6);
    color: #ffffff;
    box-shadow: 0 4px 16px rgba(168, 85, 247, 0.3);
}

/* ============================================
   Buttons (Micro-interacciones Premium)
   ============================================ */
.btn-primary {
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    background: linear-gradient(135deg, #a855f7, #7c3aed);
    color: white;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 16px rgba(168, 85, 247, 0.4);
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(168, 85, 247, 0.6);
}

.btn-primary:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary:active {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(168, 85, 247, 0.4);
}

.btn-secondary {
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* ============================================
   Tipografía Premium
   ============================================ */

/* Encabezados con gradiente */
h1, h2, h3 {
    letter-spacing: -0.5px;
}

h1 {
    font-size: 2.25rem;
    font-weight: 800;
    background: linear-gradient(135deg, #ffffff, #cbd5e1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

h2 {
    font-size: 1.875rem;
    font-weight: 700;
    color: #ffffff;
}

h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #e2e8f0;
}

/* Etiquetas y labels */
.label-text {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #94a3b8;
    font-weight: 600;
}

/* Números técnicos con fuente mono */
.font-mono-tech {
    font-family: 'Fira Code', 'Courier New', monospace;
    letter-spacing: -0.5px;
    font-weight: 500;
}

.text-mono-lg {
    font-size: 1.5rem;
    font-family: 'Fira Code', 'Courier New', monospace;
    letter-spacing: -0.5px;
}

/* ============================================
   Status Badges Premium
   ============================================ */

.badge {
    display: inline-block;
    padding: 0.375rem 0.875rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-success {
    background: rgba(34, 197, 94, 0.15);
    color: #86efac;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #fcd34d;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-info {
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

/* ============================================
   Tarjetas KPI con Glow y Micro-interacciones
   ============================================ */

.kpi-card {
    position: relative;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.kpi-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.1) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.kpi-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 0 30px rgba(168, 85, 247, 0.25), 0 8px 40px rgba(0, 0, 0, 0.4);
    border-color: rgba(168, 85, 247, 0.5);
}

.kpi-card:hover::after {
    opacity: 1;
}

.kpi-value {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #a855f7, #e9d5ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-family: 'Fira Code', 'Courier New', monospace;
    letter-spacing: -1px;
    transition: all 0.3s ease;
}

.kpi-card:hover .kpi-value {
    font-size: 2.8rem;
}

/* ============================================
   Tablas SaaS Premium
   ============================================ */

.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.01);
}

.data-table th {
    padding: 1.25rem 1.5rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #94a3b8;
    background: transparent;
}

.data-table td {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: #e2e8f0;
    transition: all 0.2s ease;
}

.data-table tbody tr {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.data-table tbody tr:hover {
    background: rgba(168, 85, 247, 0.08);
}

.data-table tbody tr:hover td {
    color: #ffffff;
}

/* Avatar con iniciales - Premium */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    background: linear-gradient(135deg, #a855f7, #7c3aed);
    color: white;
    font-weight: 700;
    font-size: 0.875rem;
    text-transform: uppercase;
    box-shadow: 0 4px 16px rgba(168, 85, 247, 0.35);
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.avatar:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(168, 85, 247, 0.5);
}

/* Avatar con colores variados */
.avatar.bg-blue {
    background: linear-gradient(135deg, #3b82f6, #1e40af);
}

.avatar.bg-green {
    background: linear-gradient(135deg, #10b981, #047857);
}

.avatar.bg-orange {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.avatar.bg-red {
    background: linear-gradient(135deg, #ef4444, #b91c1c);
}

/* Avatar con iniciales en tabla */
.table-avatar-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* ============================================
   Form Inputs
   ============================================ */
.input-field {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #f1f5f9;
    font-family: 'Inter', sans-serif;
    transition: all 0.3s ease;
}

.input-field:focus {
    outline: none;
    border-color: rgba(168, 85, 247, 0.6);
    background: rgba(15, 23, 42, 0.8);
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.1);
}

.input-field::placeholder {
    color: #64748b;
}

/* File input styling */
input[type="file"] {
    padding: 0.5rem;
    cursor: pointer;
}

/* Select dropdown */
select.input-field {
    cursor: pointer;
}

/* Textarea */
textarea.input-field {
    resize: vertical;
    min-height: 80px;
}

/* ============================================
   Modal Overlay
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-overlay.hidden {
    display: none;
}

.modal-content {
    position: relative;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ============================================
   Custom Scrollbar (Elegant macOS-style)
   ============================================ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-glow);
    border-radius: 10px;
    transition: background 0.3s;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-glow-intense);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--primary-glow) transparent;
}

/* ============================================
   Kanban Cards (Micro-interacciones mejoradas)
   ============================================ */
.kanban-card {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.75rem;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.kanban-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(255, 255, 255, 0.1) 50%, 
        transparent 100%);
    transition: left 0.6s ease;
}

.kanban-card:hover {
    transform: translateY(-6px) scale(1.02);
    border-color: rgba(168, 85, 247, 0.5);
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.25), 0 12px 32px rgba(0, 0, 0, 0.3);
}

.kanban-card:hover::before {
    left: 100%;
}

.kanban-card h4 {
    color: #f1f5f9;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.kanban-card p {
    color: #94a3b8;
    font-size: 0.85rem;
    line-height: 1.4;
}

/* ============================================
   Kanban Drag & Drop Feedback
   ============================================ */
/* Cuando se arrastra sobre una columna */
.drag-over {
    background: rgba(168, 85, 247, 0.1) !important;
    border: 2px dashed var(--primary) !important;
    transition: all 0.2s ease;
}

/* La tarjeta que está siendo arrastrada */
.dragging {
    opacity: 0.5;
    transform: scale(0.95);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

/* ============================================
   Table Styles
   ============================================ */
table {
    border-collapse: separate;
    border-spacing: 0;
}

table thead th {
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

table tbody tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
}

table tbody tr:hover {
    background: rgba(168, 85, 247, 0.1);
}

table tbody td {
    padding: 1rem 0.75rem;
}

/* ============================================
   Mobile Cards (for tables on mobile)
   ============================================ */
.mobile-card {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.75rem;
    padding: 1rem;
    transition: all 0.3s ease;
}

.mobile-card:hover {
    border-color: rgba(168, 85, 247, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(168, 85, 247, 0.15);
}

.mobile-card-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.mobile-card-row:last-child {
    border-bottom: none;
}

.mobile-card-label {
    color: #94a3b8;
    font-weight: 500;
    font-size: 0.875rem;
}

.mobile-card-value {
    color: #f1f5f9;
    font-weight: 600;
}

/* ============================================
   Badges & Pills
   ============================================ */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-venta {
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.status-ingenieria {
    background: rgba(234, 179, 8, 0.2);
    color: #fde047;
    border: 1px solid rgba(234, 179, 8, 0.3);
}

.status-instalacion {
    background: rgba(249, 115, 22, 0.2);
    color: #fdba74;
    border: 1px solid rgba(249, 115, 22, 0.3);
}

.status-ok {
    background: rgba(34, 197, 94, 0.2);
    color: #86efac;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

/* ============================================
   Utility Classes
   ============================================ */
.text-gradient {
    background: linear-gradient(135deg, var(--primary), #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.shadow-glow-purple {
    box-shadow: 0 0 30px var(--primary-glow);
}

/* Animación de carga */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }

    100% {
        background-position: 1000px 0;
    }
}

.animate-shimmer {
    animation: shimmer 2s infinite;
}

/* Transiciones suaves */
* {
    transition-property: background-color, border-color, color, fill, stroke;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 200ms;
}

button, a, input, select, textarea {
    transition-duration: 300ms;
}

/* ============================================
   Animations
   ============================================ */
@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.animate-fade-in {
    animation: fade-in 0.5s ease;
}

@keyframes slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-slide-up {
    animation: slide-up 0.4s ease;
}

/* ============================================
   Loading Spinner
   ============================================ */
.spinner {
    border: 3px solid rgba(168, 85, 247, 0.2);
    border-top: 3px solid #a855f7;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ============================================
   Responsive Adjustments
   ============================================ */
@media (max-width: 768px) {
    .glass-panel {
        padding: 1rem !important;
    }

    .nav-btn {
        font-size: 0.875rem;
        padding: 0.5rem 1rem;
    }

    .btn-primary,
    .btn-secondary {
        font-size: 0.875rem;
        padding: 0.625rem 1.25rem;
    }

    h1 {
        font-size: 1.5rem !important;
    }

    h2 {
        font-size: 1.25rem !important;
    }
}

/* ============================================
   Google Sign-In Button Styling
   ============================================ */
#google-signin-button {
    display: flex;
    justify-content: center;
    margin: 1rem 0;
}

/* ============================================
   Chart Container
   ============================================ */
canvas {
    max-height: 300px;
}

/* ============================================
   Print Styles (for PDF/Invoice export)
   ============================================ */
@media print {
    body {
        background: white !important;
        color: black !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Ocultar elementos no esenciales */
    .nav-btn, header, .btn-primary, .btn-secondary, 
    #quick-actions-container, nav, .navbar {
        display: none !important;
    }

    /* Panel de contenido */
    .glass-panel {
        background: white !important;
        border: 1px solid #ccc !important;
        box-shadow: none !important;
        color: black !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }

    /* Asegurar texto legible */
    h1, h2, h3, h4, h5, h6, p, span, td, th, div {
        color: black !important;
        text-shadow: none !important;
    }

    /* Tablas */
    table {
        border-collapse: collapse;
    }

    table th, table td {
        border: 1px solid #ccc !important;
        color: black !important;
    }

    /* Evitar cortes de página en elementos importantes */
    .kanban-card, .bento-item {
        page-break-inside: avoid;
    }
}

/* ============================================
   MOBILE RESPONSIVE TWEAKS
   ============================================ */
@media (max-width: 768px) {
    /* Ajuste general de contenedores */
    .max-w-7xl, .container {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    /* Modales a pantalla completa en móvil */
    .modal-content, .glass-panel.w-full {
        width: 100% !important;
        height: 100vh !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        display: flex;
        flex-direction: column;
    }

    /* Ajustar tamaños de texto */
    h1 { font-size: 1.5rem !important; }
    h2 { font-size: 1.25rem !important; }
    
    /* Navegación Scrolleable Horizontal */
    nav .flex-wrap {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        padding-bottom: 5px;
        -webkit-overflow-scrolling: touch;
    }
    .nav-btn {
        white-space: nowrap;
        font-size: 0.8rem;
        padding: 0.5rem 1rem;
    }

    /* Ocultar elementos no esenciales en tablas */
    .data-table th:nth-child(n+4), 
    .data-table td:nth-child(n+4) {
        display: none; /* Oculta columnas extra en móvil */
    }
    .data-table th:last-child, 
    .data-table td:last-child {
        display: table-cell !important; /* Muestra siempre la columna de acciones */
    }
    
    /* Ajustes Dashboard Grid */
    .grid-cols-5 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .grid-cols-5 > div:first-child {
        grid-column: span 2; /* KPI Principal ancho completo */
    }
}