/* ============================================
   ESTILOS PRINCIPALES - ESTRUCTURA DE COSTOS
   Soy Solidario - 2025
   ============================================ */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #06b6d4;
    --dark: #1f2937;
    --gray: #6b7280;
    --light: #f3f4f6;
    --white: #ffffff;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 12px;
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--dark);
    line-height: 1.6;
}

/* Contenedor principal */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 24px;
    margin-bottom: 24px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--light);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Navegación */
.navbar {
    background: var(--white);
    padding: 15px 30px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    border-radius: 0 0 var(--radius) var(--radius);
}

.navbar-brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.navbar-menu {
    display: flex;
    gap: 20px;
    align-items: center;
}

.navbar-menu a {
    color: var(--gray);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.3s;
}

.navbar-menu a:hover, .navbar-menu a.active {
    background: var(--primary);
    color: var(--white);
}

/* Botones */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

.btn-success {
    background: var(--secondary);
    color: var(--white);
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: var(--white);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* Formularios */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--dark);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--light);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
}

.form-control-sm {
    padding: 8px 12px;
    font-size: 0.9rem;
}

/* Tablas */
.table-responsive {
    overflow-x: auto;
}

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

.table th, .table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--light);
}

.table th {
    background: var(--light);
    font-weight: 600;
    color: var(--dark);
    white-space: nowrap;
}

.table tr:hover {
    background: #f9fafb;
}

.table input {
    width: 100%;
    min-width: 80px;
}

/* Grid de productos */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.product-card {
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
    border-radius: var(--radius);
    padding: 20px;
    border-left: 4px solid var(--primary);
}

.product-card h3 {
    color: var(--primary);
    margin-bottom: 15px;
}

/* Badges/Etiquetas */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.badge-costo { background: #dbeafe; color: #1d4ed8; }
.badge-gasto { background: #fef3c7; color: #d97706; }
.badge-fijo { background: #e0e7ff; color: #4338ca; }
.badge-variable { background: #d1fae5; color: #059669; }

/* Resumen financiero */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.summary-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    padding: 20px;
    border-radius: var(--radius);
    text-align: center;
}

.summary-card.green { background: linear-gradient(135deg, #10b981 0%, #059669 100%); }
.summary-card.orange { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); }
.summary-card.red { background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); }
.summary-card.purple { background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%); }

.summary-value {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.summary-label {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--light);
    padding-bottom: 0;
    flex-wrap: wrap;
}

.tab {
    padding: 12px 24px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--gray);
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.3s;
}

.tab:hover {
    color: var(--primary);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Login */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
}

.login-logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo h1 {
    color: var(--primary);
    font-size: 1.8rem;
}

.login-logo p {
    color: var(--gray);
    margin-top: 5px;
}

/* Alertas */
.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.alert-success { background: #d1fae5; color: #065f46; border-left: 4px solid #10b981; }
.alert-danger { background: #fee2e2; color: #991b1b; border-left: 4px solid #ef4444; }
.alert-warning { background: #fef3c7; color: #92400e; border-left: 4px solid #f59e0b; }
.alert-info { background: #dbeafe; color: #1e40af; border-left: 4px solid #3b82f6; }

/* Tooltip de ayuda */
.help-tooltip {
    display: inline-block;
    width: 18px;
    height: 18px;
    background: var(--info);
    color: white;
    border-radius: 50%;
    text-align: center;
    line-height: 18px;
    font-size: 12px;
    cursor: help;
    margin-left: 5px;
}

/* Sección de categoría */
.category-section {
    margin-bottom: 30px;
    border: 1px solid var(--light);
    border-radius: var(--radius);
    overflow: hidden;
}

.category-header {
    background: var(--light);
    padding: 15px 20px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.category-header.costo-fijo { border-left: 4px solid #3b82f6; }
.category-header.costo-variable { border-left: 4px solid #10b981; }
.category-header.costo-directo { border-left: 4px solid #8b5cf6; }
.category-header.costo-indirecto { border-left: 4px solid #f59e0b; }
.category-header.gasto-fijo { border-left: 4px solid #ef4444; }
.category-header.gasto-variable { border-left: 4px solid #ec4899; }

.category-body {
    padding: 15px 20px;
}

.category-total {
    background: #f9fafb;
    padding: 10px 20px;
    text-align: right;
    font-weight: 600;
    border-top: 1px solid var(--light);
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 15px;
    }
    
    .navbar-menu {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .card {
        padding: 15px;
    }
    
    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .table th, .table td {
        padding: 8px 10px;
        font-size: 0.85rem;
    }
}

/* Animaciones */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

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

.modal {
    background: var(--white);
    border-radius: var(--radius);
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

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

/* Progress bar */
.progress-bar {
    height: 8px;
    background: var(--light);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transition: width 0.5s ease;
}

/* Prorrateo visual */
.prorrateo-bar {
    display: flex;
    height: 30px;
    border-radius: 6px;
    overflow: hidden;
    margin: 10px 0;
}

.prorrateo-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
    font-weight: 500;
    min-width: 40px;
}

/* Colores para productos */
.color-1 { background: #3b82f6; }
.color-2 { background: #10b981; }
.color-3 { background: #f59e0b; }
.color-4 { background: #ef4444; }
.color-5 { background: #8b5cf6; }
.color-6 { background: #ec4899; }
