/* Reset y estilos base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
    display: flex;
    min-height: 100vh;
}

/* Sidebar lateral colapsable */
.sidebar {
    width: 70px;
    background: linear-gradient(135deg, #2d164c 0%, #062156 100%);
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    transition: width 0.3s ease;
    overflow-x: hidden;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.sidebar:hover {
    width: 250px;
}

.sidebar-header {
    padding: 20px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 15px;
    white-space: nowrap;
}

.sidebar-header h1 {
    font-size: 1.5rem;
    margin: 0;
    color: white;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar:hover .sidebar-header h1 {
    opacity: 1;
}

.sidebar-logo {
    font-size: 24px;
    min-width: 40px;
    text-align: center;
}

.sidebar-nav {
    padding: 20px 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 15px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.3s ease;
    white-space: nowrap;
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    border-left-color: #ddff19;
}

.sidebar-link.active {
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
    border-left-color: #ddff19;
    font-weight: 500;
}

.sidebar-icon {
    font-size: 20px;
    min-width: 40px;
    text-align: center;
}

.sidebar-text {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar:hover .sidebar-text {
    opacity: 1;
}

/* Contenido principal */
.main-content {
    flex: 1;
    margin-left: 70px;
    transition: margin-left 0.3s ease;
    padding: 20px;
    min-height: 100vh;
}

.sidebar:hover ~ .main-content {
    margin-left: 250px;
}

/* Header dentro del contenido */
.page-header {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.page-header h1 {
    color: #2d164c;
    font-size: 2rem;
    margin-bottom: 10px;
}

.page-header p {
    color: #666;
    font-size: 1rem;
}

/* Contenedor principal */
.container {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Main content */
main {
    min-height: 60vh;
    margin-bottom: 3rem;
}

/* Dashboard */
.dashboard {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: linear-gradient(135deg, #2d164c 0%, #062156 100%);
    color: white;
    padding: 1.5rem;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border-left: 4px solid #ddff19;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(45, 22, 76, 0.2);
}

.stat-card h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    opacity: 0.9;
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
}

.quick-actions {
    text-align: center;
}

.quick-actions h2 {
    margin-bottom: 1.5rem;
    color: #333;
}

.action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Botones */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 5px;
    text-decoration: none;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
}

.btn-primary {
    background: linear-gradient(135deg, #2d164c 0%, #062156 100%);
    color: white;
    border: none;
    position: relative;
    overflow: hidden;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(45, 22, 76, 0.3);
}

.btn-primary::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn-primary:hover::after {
    left: 100%;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-outline {
    background: transparent;
    border: 2px solid #667eea;
    color: #667eea;
}

.btn-outline:hover {
    background: #667eea;
    color: white;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Formularios */
.factura-form, .email-form, .filtros-form {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.form-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #eee;
}

.form-section:last-of-type {
    border-bottom: none;
}

.form-section h2 {
    color: #667eea;
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #555;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* Items de factura */
#items-container {
    margin-bottom: 1rem;
}

.item-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
    gap: 1rem;
    align-items: end;
    margin-bottom: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 5px;
}

.item-total {
    background: #e9ecef;
    font-weight: bold;
}

.remove-item {
    padding: 0.5rem;
    min-width: 40px;
}

.totales-section {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 5px;
    margin-top: 1rem;
}

.total-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.total-final {
    font-size: 1.3rem;
    font-weight: bold;
    border-top: 2px solid #ddd;
    padding-top: 0.5rem;
    margin-top: 0.5rem;
}

/* Alertas */
.alert {
    padding: 1rem;
    border-radius: 5px;
    margin-bottom: 1rem;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-success {
    background: #d1edff;
    color: #155724;
    border: 1px solid #c3e6cb;
}

/* Factura preview */
.success-message {
    background: #d1edff;
    padding: 1.5rem;
    border-radius: 5px;
    margin-bottom: 2rem;
    text-align: center;
}

.factura-preview {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.factura-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #667eea;
}

.empresa-info h2 {
    color: #667eea;
    margin-bottom: 0.5rem;
}

.factura-info h3 {
    color: #333;
    margin-bottom: 0.5rem;
}

.cliente-info {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 5px;
    margin-bottom: 1.5rem;
}

.items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
}

.items-table th,
.items-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.items-table th {
    background: #667eea;
    color: white;
    font-weight: 500;
}

.items-table tr:hover {
    background: #f8f9fa;
}

.factura-totales {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 5px;
    margin-bottom: 1.5rem;
}

.factura-notas {
    background: #fff3cd;
    padding: 1rem;
    border-radius: 5px;
    border-left: 4px solid #ffc107;
}

/* Sección de datos de pago en cotizaciones */
.datos-pago-section {
    background: #e8f5e9;
    padding: 1.5rem;
    border-radius: 5px;
    margin-bottom: 1.5rem;
    border-left: 4px solid #4caf50;
}

.datos-pago-section h4 {
    color: #2e7d32;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.pago-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.pago-item {
    padding: 0.5rem;
}

.pago-item.full-width {
    grid-column: 1 / -1;
}

.pago-item strong {
    display: block;
    color: #555;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.pago-item span {
    color: #333;
    font-weight: 500;
}

/* Sección de condiciones adicionales en cotizaciones */
.condiciones-section {
    background: #e3f2fd;
    padding: 1.5rem;
    border-radius: 5px;
    margin-bottom: 1.5rem;
    border-left: 4px solid #2196f3;
}

.condiciones-section h4 {
    color: #1565c0;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.condiciones-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.condicion-item {
    padding: 0.5rem;
}

.condicion-item strong {
    display: block;
    color: #555;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.condicion-item span {
    color: #333;
    font-weight: 500;
}

/* Badges para estados */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 15px;
    font-size: 0.85rem;
    font-weight: 500;
}

.badge-pendiente {
    background: #fff3cd;
    color: #856404;
}

.badge-aceptada {
    background: #d1edff;
    color: #155724;
}

.badge-rechazada {
    background: #f8d7da;
    color: #721c24;
}

.badge-vencida {
    background: #e2e3e5;
    color: #383d41;
}

/* Lista de facturas */
.filtros-section {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.totales-resumen {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.total-card {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.total-card h3 {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.total-number {
    font-size: 1.5rem;
    font-weight: bold;
    color: #667eea;
}

.facturas-list {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.table-responsive {
    overflow-x: auto;
}

.facturas-table {
    width: 100%;
    border-collapse: collapse;
}

.facturas-table th,
.facturas-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.facturas-table th {
    background: #667eea;
    color: white;
    font-weight: 500;
}

.facturas-table tr:hover {
    background: #f8f9fa;
}

.estado-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 500;
}

.estado-pendiente {
    background: #fff3cd;
    color: #856404;
}

.estado-pagada {
    background: #d1edff;
    color: #155724;
}

.estado-cancelada {
    background: #f8d7da;
    color: #721c24;
}

.no-results {
    text-align: center;
    padding: 3rem;
    color: #666;
}

/* Email form */
.email-form-container {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.factura-info-summary {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 5px;
    margin-bottom: 1.5rem;
}

.email-preview {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 5px;
    margin-top: 1.5rem;
}

.preview-content {
    background: white;
    padding: 1rem;
    border-radius: 5px;
    border: 1px solid #ddd;
}

.preview-text {
    white-space: pre-wrap;
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 5px;
    margin-top: 0.5rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 0;
    color: #666;
    border-top: 1px solid #ddd;
    margin-top: 3rem;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .main-nav {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .nav-link {
        text-align: center;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .item-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .factura-header {
        flex-direction: column;
        gap: 1rem;
    }
    
    .totales-resumen {
        grid-template-columns: 1fr;
    }
    
    .table-responsive {
        font-size: 0.875rem;
    }
    
    .form-actions {
        justify-content: stretch;
    }
    
    .form-actions .btn {
        flex: 1;
    }
}
