/* Linear & Vercel Inspired Minimalist Dark SaaS Design System */

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

:root {
    --bg-dark: #09090b;
    --bg-card: #121215;
    --bg-card-hover: #18181c;
    --bg-input: #1a1a1e;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.16);
    
    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;

    --accent-purple: #8b5cf6;
    --accent-blue: #3b82f6;
    --accent-cyan: #06b6d4;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;

    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.5), 0 0 1px 1px rgba(255, 255, 255, 0.05);
    --shadow-glow-purple: 0 0 20px -5px rgba(139, 92, 246, 0.3);
    --shadow-glow-rose: 0 0 20px -5px rgba(244, 63, 94, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

/* Scrollbar personalizado */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
    background: #27272a;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #3f3f46;
}

/* Sidebar Layout */
.app-sidebar {
    width: 260px;
    background-color: #0d0d10;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 50;
}

.brand-container {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
}

.brand-logo {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--shadow-glow-purple);
}

.brand-title {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(180deg, #ffffff, #a1a1aa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-subtitle {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.nav-menu {
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.nav-section-title {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 700;
    padding: 12px 12px 6px 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: all 0.15s ease;
    cursor: pointer;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}

.nav-item.active {
    background-color: rgba(139, 92, 246, 0.12);
    color: #c4b5fd;
    border: 1px solid rgba(139, 92, 246, 0.25);
}

.nav-item i {
    font-size: 1.1rem;
}

.nav-badge {
    margin-left: auto;
    background: rgba(244, 63, 94, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(244, 63, 94, 0.3);
    font-size: 0.72rem;
    padding: 2px 7px;
    border-radius: 99px;
    font-weight: 600;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--accent-emerald);
    box-shadow: 0 0 10px var(--accent-emerald);
}

/* Main Content Area */
.app-main {
    margin-left: 260px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Top Header */
.app-header {
    height: 64px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    background-color: rgba(9, 9, 11, 0.8);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 40;
}

.page-header-title {
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

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

/* Content Container */
.content-body {
    padding: 32px;
    flex: 1;
}

/* Tab Views Container */
.tab-content {
    display: none;
    animation: fadeIn 0.2s ease-in-out;
}
.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Metric Cards Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.metric-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
}

.metric-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
}

.metric-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 500;
}

.metric-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.metric-icon.purple { background: rgba(139, 92, 246, 0.12); color: #a78bfa; }
.metric-icon.blue { background: rgba(59, 130, 246, 0.12); color: #60a5fa; }
.metric-icon.rose { background: rgba(244, 63, 94, 0.12); color: #f87171; }
.metric-icon.emerald { background: rgba(16, 185, 129, 0.12); color: #34d399; }
.metric-icon.amber { background: rgba(245, 158, 11, 0.12); color: #fbbf24; }

.metric-value {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    font-family: var(--font-mono);
}

.metric-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Linear Cards Layout */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    margin-bottom: 24px;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-body {
    padding: 24px;
}

/* Custom Data Table */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.85rem;
}

.custom-table th {
    padding: 12px 16px;
    background-color: rgba(255, 255, 255, 0.02);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
}

.custom-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.custom-table tr:hover td {
    background-color: var(--bg-card-hover);
    color: var(--text-primary);
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 99px;
    font-size: 0.73rem;
    font-weight: 600;
    border: 1px solid transparent;
}

.badge-emerald { background: rgba(16, 185, 129, 0.1); color: #34d399; border-color: rgba(16, 185, 129, 0.25); }
.badge-blue { background: rgba(59, 130, 246, 0.1); color: #60a5fa; border-color: rgba(59, 130, 246, 0.25); }
.badge-purple { background: rgba(139, 92, 246, 0.1); color: #a78bfa; border-color: rgba(139, 92, 246, 0.25); }
.badge-rose { background: rgba(244, 63, 94, 0.1); color: #f87171; border-color: rgba(244, 63, 94, 0.25); }
.badge-amber { background: rgba(245, 158, 11, 0.1); color: #fbbf24; border-color: rgba(245, 158, 11, 0.25); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
    text-decoration: none;
    font-family: var(--font-sans);
}

.btn-primary {
    background: linear-gradient(180deg, #6366f1, #4f46e5);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover {
    background: linear-gradient(180deg, #4f46e5, #4338ca);
}

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

.btn-danger {
    background-color: rgba(244, 63, 94, 0.12);
    color: #f87171;
    border: 1px solid rgba(244, 63, 94, 0.3);
}
.btn-danger:hover {
    background-color: rgba(244, 63, 94, 0.2);
}

.btn-warning {
    background-color: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}
.btn-warning:hover {
    background-color: rgba(245, 158, 11, 0.2);
}

.btn-success {
    background-color: rgba(16, 185, 129, 0.12);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}
.btn-success:hover {
    background-color: rgba(16, 185, 129, 0.2);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.78rem;
}

.btn-icon {
    width: 28px;
    height: 28px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-icon svg {
    width: 14px;
    height: 14px;
}

/* Forms and Inputs */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.form-control {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 0.88rem;
    font-family: var(--font-sans);
    outline: none;
    transition: all 0.15s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

optgroup {
    background-color: #18181b;
    color: #c4b5fd;
    font-weight: 700;
    font-style: normal;
    padding: 6px 4px;
}

select option {
    background-color: #0f172a;
    color: #f4f4f5;
    padding: 6px 8px;
}

select.form-control {
    cursor: pointer;
}

/* Grid Layouts */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 650px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
    animation: modalIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
}
.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

/* Remito Document Format (Simulación de Hoja de Papel A4 Imprimible) */
.remito-box {
    background: #ffffff;
    color: #0f172a;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-md);
    padding: 36px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    font-family: var(--font-sans);
}

.remito-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 3px solid #4f46e5;
    padding-bottom: 18px;
    margin-bottom: 24px;
}

.remito-title {
    font-size: 1.35rem;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.02em;
}

.remito-code {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    color: #4f46e5;
    font-weight: 800;
}

.remito-details-box {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 16px;
    border-radius: 8px;
    color: #1e293b;
}

.remito-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.remito-table th {
    background-color: #f1f5f9;
    color: #0f172a;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    padding: 10px 12px;
    border-bottom: 2px solid #cbd5e1;
    text-align: left;
}

.remito-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e2e8f0;
    color: #334155;
    font-size: 0.84rem;
}

.signatures-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 50px;
    margin-top: 60px;
    padding-top: 20px;
}

.signature-box {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.signature-space {
    height: 60px;
    width: 100%;
}

.signature-line {
    width: 100%;
    border-top: 1.5px solid #64748b;
    text-align: center;
    padding-top: 8px;
    font-size: 0.8rem;
    color: #334155;
}

#print-area {
    display: none;
}

/* Printable Remito Layout (Para Impresión Limpia sin Hoja en Blanco) */
@media print {
    body {
        background: #ffffff !important;
        color: #000000 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Ocultar absolutamente todo excepto la zona exclusiva de impresión #print-area */
    body > *:not(#print-area) {
        display: none !important;
    }

    #print-area {
        display: block !important;
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 24px !important;
        background: #ffffff !important;
        color: #000000 !important;
    }

    #print-area * {
        color: #000000 !important;
    }

    #print-area .remito-box {
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
        background: #ffffff !important;
    }

    #print-area .remito-header {
        display: flex !important;
        justify-content: space-between !important;
        border-bottom: 3px solid #000000 !important;
        padding-bottom: 12px !important;
        margin-bottom: 20px !important;
    }

    #print-area .remito-title {
        color: #000000 !important;
    }

    #print-area .remito-code {
        color: #000000 !important;
    }

    #print-area .remito-details-box {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        background: #f8fafc !important;
        border: 1px solid #cbd5e1 !important;
        padding: 12px !important;
        margin-bottom: 20px !important;
    }

    #print-area .remito-table {
        width: 100% !important;
        border-collapse: collapse !important;
    }

    #print-area .remito-table th {
        background-color: #f1f5f9 !important;
        color: #000000 !important;
        border-bottom: 2px solid #000000 !important;
    }

    #print-area .remito-table td {
        border-bottom: 1px solid #cbd5e1 !important;
        color: #000000 !important;
    }

    #print-area .signatures-container {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 50px !important;
        margin-top: 50px !important;
    }

    #print-area .signature-line {
        border-top: 1.5px solid #000000 !important;
        color: #000000 !important;
    }
}

/* ==========================================================================
   Responsive & Mobile Friendly Styles
   ========================================================================== */

/* Asegurar que las tablas mantengan un ancho adecuado para no colapsar columnas */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.custom-table {
    min-width: 850px;
    table-layout: auto;
}

.custom-table th, .custom-table td {
    padding: 12px 14px;
    white-space: normal;
    word-break: break-word;
}

/* Evitar saltos de línea para datos clave que deben verse en una sola línea */
.custom-table td:nth-child(1), /* Número de Serie */
.custom-table td:nth-child(5), /* Orden de compra / Specs */
.custom-table td:nth-child(6) { /* Estado */
    white-space: nowrap !important;
}

/* Botón toggle para el menú de hamburguesa en móvil */
.sidebar-toggle-btn {
    display: none !important;
}

/* Backdrop para cerrar el menú lateral en móviles */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 45;
}

.sidebar-open .sidebar-backdrop {
    display: block;
}

@media (max-width: 1024px) {
    .app-sidebar {
        left: -260px;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .sidebar-open .app-sidebar {
        left: 0;
    }
    
    .app-main {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    .sidebar-toggle-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.08);
        color: var(--text-primary);
        width: 38px;
        height: 38px;
        border-radius: var(--radius-sm);
        cursor: pointer;
        transition: all 0.2s;
    }
    
    .sidebar-toggle-btn:hover {
        background: rgba(255, 255, 255, 0.1);
    }
    
    .app-header {
        height: auto !important;
        min-height: 64px;
        padding: 16px 20px !important;
        gap: 12px;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .header-actions {
        width: auto;
        gap: 8px !important;
    }
}

@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .header-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .content-body {
        padding: 16px !important;
    }

    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 12px;
    }
    
    .card-header > div {
        width: 100%;
        flex-direction: column;
        align-items: stretch !important;
        gap: 8px !important;
    }
    
    .card-header input, 
    .card-header select, 
    .card-header button {
        width: 100% !important;
    }

    .metrics-grid {
        grid-template-columns: 1fr !important;
    }
    
    .modal-content {
        width: 95% !important;
        margin: 10px auto;
        max-height: 90vh;
        overflow-y: auto;
    }
}
