/* ============================================
   CREATE INVOICE - MODERN SaaS STYLES
   Versión independiente y modular
   ============================================ */

:root {
    /* Colores principales - Marca ConectaEDI */
    --primary-50: #e8f5e9;
    --primary-100: #c8e6c9;
    --primary-200: #a5d6a7;
    --primary-300: #81c784;
    --primary-400: #66bb6a;
    --primary-500: #4caf50;
    --primary-600: #43a047;
    --primary-700: #388e3c;
    --primary-800: #2e7d32;
    --primary-900: #1b5e20;
    
    --accent-50: #e3f2fd;
    --accent-100: #bbdefb;
    --accent-500: #2196f3;
    --accent-600: #1e88e5;
    --accent-700: #1976d2;
    
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;
    
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    --sidebar-width: 260px;
    --header-height: 70px;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;
}

/* ============================================
   LAYOUT PRINCIPAL
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.5;
}

.dashboard-container {
    display: flex;
    min-height: 100vh;
}

/* ============================================
   SIDEBAR
   ============================================ */

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--gray-900) 0%, var(--gray-800) 100%);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    border-right: 1px solid var(--gray-700);
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: var(--gray-800);
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--gray-600);
    border-radius: 4px;
}

.logo-container {
    padding: 24px 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo {
    max-width: 160px;
    height: auto;
    filter: brightness(0) invert(1);
}

.sidebar-menu {
    padding: 16px 12px;
}

.menu-item {
    padding: 12px 16px;
    color: var(--gray-300);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: var(--radius-md);
    margin-bottom: 4px;
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

.menu-item.active {
    background: linear-gradient(90deg, var(--primary-600), var(--primary-500));
    color: white;
}

.menu-item i {
    width: 20px;
    font-size: 16px;
}

.menu-separator {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 16px 12px;
}

.logout-menu-item {
    color: #f87171;
}

.logout-menu-item:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}

/* ============================================
   MAIN CONTENT
   ============================================ */

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 24px 32px;
    background: var(--gray-50);
}

/* ============================================
   HEADER MODERNO
   ============================================ */

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.header-left {
    display: flex;
    align-items: center;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    color: var(--gray-600);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all var(--transition-fast);
}

.back-btn:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
    color: var(--gray-900);
    transform: translateX(-2px);
}

.back-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary-header {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 24px;
    background: var(--primary-600);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-primary-header:hover {
    background: var(--primary-700);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.header-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 24px;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.header-action-btn:hover {
    background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.header-action-btn i,
.btn-primary-header i {
    font-size: 16px;
}

/* ============================================
   WIZARD STEPS
   ============================================ */

.wizard-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 32px;
    background: white;
    padding: 20px 32px;
    border-radius: var(--radius-xl);
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
}

.step-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.step-marker {
    width: 48px;
    height: 48px;
    background: var(--gray-100);
    border: 2px solid var(--gray-200);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all var(--transition-base);
}

.step-number {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-500);
}

.step-check {
    position: absolute;
    font-size: 20px;
    color: white;
    display: none;
}

.step-info {
    text-align: left;
}

.step-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-700);
}

.step-item.active .step-marker {
    background: var(--primary-500);
    border-color: var(--primary-500);
    box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.2);
}

.step-item.active .step-number {
    color: white;
}

.step-item.active .step-title {
    color: var(--primary-700);
}

.step-item.completed .step-marker {
    background: var(--primary-500);
    border-color: var(--primary-500);
}

.step-item.completed .step-number {
    display: none;
}

.step-item.completed .step-check {
    display: block;
}

.step-connector {
    width: 80px;
    height: 2px;
    background: var(--gray-200);
    margin: 0 16px;
}

.step-connector.completed {
    background: var(--primary-500);
}

/* ============================================
   FORM CARDS
   ============================================ */

.form-card {
    background: #f1f5f9;
    border-radius: var(--radius-xl);
    border: 1px solid var(--gray-200);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.form-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 24px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.form-card-header i {
    font-size: 20px;
    color: var(--primary-600);
}

.form-card-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-800);
    margin: 0;
    flex: 1;
}

.btn-add-line {
    background: var(--primary-50);
    border: 1px solid var(--primary-200);
    color: var(--primary-700);
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-add-line:hover {
    background: var(--primary-100);
    transform: translateY(-1px);
}

.form-card-body {
    padding: 24px;
}

/* Info Card */
.info-card {
    background: var(--gray-50);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    border: 1px solid var(--gray-200);
}

.info-card-icon {
    width: 48px;
    height: 48px;
    background: var(--primary-100);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.info-card-icon i {
    font-size: 24px;
    color: var(--primary-700);
}

.info-card-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    margin-bottom: 4px;
}

.info-card-value {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-800);
}

/* Form Groups */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.form-label i {
    font-size: 14px;
    color: var(--gray-400);
}

.required {
    color: var(--error);
    font-size: 12px;
}

.form-control-modern {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    background: white;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.form-control-modern:hover {
    border-color: var(--gray-300);
}

.form-control-modern:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

select.form-control-modern {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 20px;
}

textarea.form-control-modern {
    resize: vertical;
    min-height: 80px;
}

.form-helper {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 6px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* ============================================
   TABLA DE LÍNEAS
   ============================================ */

.lines-table-container {
    overflow-x: auto;
}

.lines-table {
    width: 100%;
    border-collapse: collapse;
}

.lines-table thead th {
    padding: 16px 12px;
    background: var(--gray-50);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-600);
    border-bottom: 1px solid var(--gray-200);
}

.lines-table tbody td {
    padding: 12px;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}

.lines-table input,
.lines-table select {
    width: 100%;
    padding: 8px 10px;
    font-size: 13px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.lines-table input:focus,
.lines-table select:focus {
    outline: none;
    border-color: var(--primary-500);
}

.lines-table .ci-line-total {
    font-weight: 600;
    color: var(--primary-700);
    text-align: right;
}

.btn-remove-line {
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.btn-remove-line:hover {
    color: var(--error);
    background: var(--gray-100);
}

.lines-info {
    padding: 16px 24px;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
    font-size: 13px;
    color: var(--gray-600);
    display: flex;
    align-items: center;
    gap: 10px;
}

.lines-info i {
    color: var(--info);
}

/* ============================================
   RESUMEN Y SUMMARY CARDS
   ============================================ */

.summary-card {
    background: white;
    border-radius: var(--radius-xl);
    border: 1px solid var(--gray-200);
    margin-bottom: 20px;
    overflow: hidden;
}

.summary-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.summary-card-header i {
    font-size: 18px;
    color: var(--primary-600);
}

.summary-card-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-800);
    margin: 0;
}

.summary-card-body {
    padding: 20px 24px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px 24px;
}

.summary-item {
    padding: 4px 0;
}

.summary-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    margin-bottom: 4px;
}

.summary-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
    word-break: break-word;
}

.summary-sub {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 2px;
}

.summary-sub:empty {
    display: none;
}

.summary-remarks {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-200);
}

/* Tabla resumen líneas */
.lines-summary-container {
    overflow-x: auto;
}

.lines-summary-table {
    width: 100%;
    border-collapse: collapse;
}

.lines-summary-table thead th {
    padding: 12px 16px;
    background: var(--gray-50);
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-600);
    border-bottom: 1px solid var(--gray-200);
}

.lines-summary-table tbody td {
    padding: 10px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
}

/* Tabla desglose IVA */
.tax-summary-container {
    overflow-x: auto;
}

.tax-summary-table {
    width: 100%;
    border-collapse: collapse;
}

.tax-summary-table thead th {
    padding: 12px 16px;
    background: var(--gray-50);
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-600);
    border-bottom: 1px solid var(--gray-200);
}

.tax-summary-table tbody td {
    padding: 10px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
}

.tax-summary-table tfoot th,
.tax-summary-table tfoot td {
    padding: 12px 16px;
    background: var(--gray-50);
    font-weight: 600;
    border-top: 1px solid var(--gray-200);
}

/* Total Card */
.total-card {
    background: linear-gradient(135deg, var(--primary-50) 0%, white 100%);
    border-radius: var(--radius-xl);
    padding: 24px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--primary-200);
    margin-bottom: 20px;
}

.total-item {
    text-align: center;
    flex: 1;
}

.total-item span {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    margin-bottom: 8px;
}

.total-item strong {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-800);
}

.total-item.total-grand strong {
    font-size: 28px;
    color: var(--primary-700);
}

/* Info Alert */
.info-alert {
    background: var(--accent-50);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--accent-700);
    border: 1px solid var(--accent-100);
}

.info-alert i {
    font-size: 18px;
}

/* ============================================
   ALERTAS
   ============================================ */

.alert {
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}

.alert-danger {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}

.alert-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1024px) {
    .form-row {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .total-card {
        flex-direction: column;
        gap: 16px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        position: fixed;
        z-index: 1100;
    }
    
    .main-content {
        margin-left: 0;
        padding: 16px;
    }
    
    .wizard-steps {
        flex-direction: column;
        gap: 16px;
    }
    
    .step-connector {
        width: 2px;
        height: 30px;
        margin: 0;
    }
    
    .summary-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

/* ============================================
   BOTÓN CREAR FACTURA (Color morado #5e17eb)
   ============================================ */

.btn-create-invoice {
    background: linear-gradient(135deg, #5e17eb, #4f13c9) !important;
    border: none !important;
}

.btn-create-invoice:hover {
    background: linear-gradient(135deg, #4f13c9, #4010a3) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(94, 23, 235, 0.3);
}

/* ============================================
   ESTILOS MORADOS SOLO PARA ELEMENTOS ESPECÍFICOS
   Botones Siguiente, Crear Factura y Steps 1,2,3
   ============================================ */

/* Botón Siguiente */
.btn-primary-header {
    background: #5e17eb;
}

.btn-primary-header:hover {
    background: #4f13c9;
}

/* Botón Crear Factura */
.header-action-btn {
    background: linear-gradient(135deg, #5e17eb, #4f13c9);
}

.header-action-btn:hover {
    background: linear-gradient(135deg, #4f13c9, #4010a3);
}

/* Step indicators - números 1, 2, 3 activos */
.step-item.active .step-marker {
    background: #5e17eb;
    border-color: #5e17eb;
    box-shadow: 0 0 0 4px rgba(94, 23, 235, 0.2);
}

/* Step indicators - números completados */
.step-item.completed .step-marker {
    background: #5e17eb;
    border-color: #5e17eb;
}

/* Línea conectora entre steps */
.step-connector.completed {
    background: #5e17eb;
}

/* ============================================
   TÍTULOS DE STEPS (Cabecera, Líneas, Resumen)
   ============================================ */

/* Color del título cuando el step está activo */
.step-item.active .step-title {
    color: #5e17eb;
}

/* Opcional: si quieres que el título también sea morado cuando está completado */
.step-item.completed .step-title {
    color: #5e17eb;
}

/* ============================================
   WIZARD STEPS CON BOTONES INTEGRADOS
   ============================================ */

.wizard-steps {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
    background: white;
    padding: 20px 32px;
    border-radius: var(--radius-xl);
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
    gap: 20px;
}

.steps-wrapper {
    display: flex;
    align-items: center;
    flex: 1;
    justify-content: center;
}

.steps-buttons {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Responsive */
@media (max-width: 768px) {
    .wizard-steps {
        flex-direction: column;
    }
    
    .steps-wrapper {
        flex-direction: column;
        width: 100%;
    }
    
    .steps-buttons {
        width: 100%;
        justify-content: center;
    }
}