/* =====================================================
   Sistema de Control de Costos - Estilos CSS
   Diseño minimalista en blanco, negro y escala de grises
   ===================================================== */

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

:root {
    --color-bg: #ffffff;
    --color-sidebar: #1a1a1a;
    --color-text: #2c2c2c;
    --color-text-light: #6b6b6b;
    --color-border: #e0e0e0;
    --color-hover: #f5f5f5;
    --color-shadow: rgba(0, 0, 0, 0.08);
    --color-success: #2c2c2c;
    --color-error: #4a4a4a;
    --sidebar-width: 260px;
    --header-height: 60px;
}

body {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    font-size: 14px;
}

/* ===== LAYOUT PRINCIPAL ===== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--color-sidebar);
    color: white;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    z-index: 1000;
}

.sidebar-header {
    padding: 30px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

.logo-subtitle {
    font-size: 11px;
    font-weight: 400;
    opacity: 0.7;
    letter-spacing: 0.5px;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 14px 24px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: white;
}

.nav-item.active {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    border-left: 3px solid white;
}

.nav-icon {
    margin-right: 12px;
    font-size: 18px;
}

.sidebar-footer {
    padding: 20px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.version {
    font-size: 11px;
    opacity: 0.5;
    font-weight: 500;
}

/* ===== CONTENIDO PRINCIPAL ===== */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    background-color: #fafafa;
    min-height: 100vh;
    width: calc(100% - var(--sidebar-width));
}

.content-wrapper {
    padding: 40px;
    max-width: 1400px;
    width: 100%;
}

/* ===== CABECERA DE PÁGINA ===== */
.page-header {
    margin-bottom: 32px;
}

.page-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 6px;
    letter-spacing: -0.5px;
}

.page-subtitle {
    font-size: 14px;
    color: var(--color-text-light);
    font-weight: 400;
}

/* ===== ALERTAS ===== */
.alert {
    padding: 14px 18px;
    border-radius: 6px;
    margin-bottom: 24px;
    font-size: 14px;
    font-weight: 500;
}

.alert-success {
    background-color: #f0f0f0;
    border: 1px solid #d0d0d0;
    color: var(--color-text);
}

.alert-error {
    background-color: #f5f5f5;
    border: 1px solid #cccccc;
    color: var(--color-text);
}

/* ===== TARJETAS MÉTRICAS ===== */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.metric-card {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 1px 3px var(--color-shadow);
}

.metric-header {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
}

.metric-icon {
    font-size: 24px;
    margin-right: 12px;
}

.metric-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 6px;
    letter-spacing: -1px;
}

.metric-value.positive {
    color: #2c2c2c;
}

.metric-value.negative {
    color: #6b6b6b;
}

.metric-subtitle {
    font-size: 12px;
    color: var(--color-text-light);
}

/* ===== GRÁFICAS ===== */
.charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.chart-card {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 1px 3px var(--color-shadow);
}

.chart-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 20px;
}

.chart-placeholder {
    min-height: 300px;
    background-color: #fafafa;
    border: 1px dashed var(--color-border);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.placeholder-text {
    color: var(--color-text-light);
    font-size: 13px;
    margin-bottom: 16px;
    text-align: center;
}

.placeholder-data {
    width: 100%;
    max-height: 250px;
    overflow-y: auto;
}

/* ===== GRID DE CONTENIDO ===== */
.content-grid {
    display: grid;
    grid-template-columns: minmax(300px, 400px) minmax(0, 1fr);
    gap: 24px;
    margin-bottom: 32px;
}

/* ===== TARJETAS ===== */
.form-card, .table-card, .section-card, .detail-card {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 28px;
    box-shadow: 0 1px 3px var(--color-shadow);
    min-width: 0; /* Permite que el contenido se contraiga */
}

.form-title, .table-title, .section-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 24px;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}

.detail-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 6px;
}

.detail-subtitle {
    font-size: 14px;
    color: var(--color-text-light);
}

.detail-info {
    display: flex;
    gap: 32px;
    margin-bottom: 28px;
    padding: 20px;
    background-color: #fafafa;
    border-radius: 6px;
    flex-wrap: wrap;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.info-label {
    font-size: 12px;
    color: var(--color-text-light);
    font-weight: 500;
}

.info-value {
    font-size: 16px;
    font-weight: 600;
}

.detail-actions {
    margin-top: 24px;
}

/* ===== FORMULARIOS ===== */
.form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.flex-grow {
    flex: 1;
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--color-text);
}

.form-input, .form-select, .form-textarea {
    padding: 12px 14px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 14px;
    font-family: 'Montserrat', sans-serif;
    transition: all 0.2s ease;
    background-color: white;
    width: 100%;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: #2c2c2c;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-section {
    margin-top: 28px;
    padding-top: 28px;
    border-top: 1px solid var(--color-border);
}

.insumo-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    align-items: flex-end;
    padding: 12px;
    background-color: #fafafa;
    border-radius: 6px;
    border: 1px solid var(--color-border);
}

.insumo-row .form-group {
    margin-bottom: 0;
}

.insumo-row .form-input,
.insumo-row .form-select {
    background-color: white;
}

.insumo-row .form-input:focus,
.insumo-row .form-select:focus {
    background-color: white;
    border-color: #2c2c2c;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

/* ===== BOTONES ===== */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Montserrat', sans-serif;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background-color: #2c2c2c;
    color: white;
}

.btn-primary:hover {
    background-color: #1a1a1a;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px var(--color-shadow);
}

.btn-secondary {
    background-color: white;
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

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

.btn-remove {
    background-color: #f5f5f5;
    color: var(--color-text);
    padding: 12px 16px;
}

.btn-remove:hover {
    background-color: #e0e0e0;
}

.btn-action {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.btn-action:hover {
    background-color: var(--color-hover);
}

.btn-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--color-text-light);
    padding: 0;
}

.btn-close:hover {
    color: var(--color-text);
}

/* ===== TABLAS ===== */
.table-container {
    overflow-x: auto;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    width: 100%;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
}

.data-table, .simple-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
    table-layout: auto;
}

.data-table thead {
    background-color: #fafafa;
}

.data-table th {
    padding: 14px 12px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    color: var(--color-text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--color-border);
    white-space: nowrap;
}

.data-table td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--color-border);
    font-size: 13px;
}

.data-table tbody tr:hover {
    background-color: var(--color-hover);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.simple-table th,
.simple-table td {
    padding: 10px 12px;
    text-align: left;
    font-size: 13px;
}

.simple-table thead {
    background-color: #f5f5f5;
}

.simple-table tbody tr {
    border-bottom: 1px solid var(--color-border);
}

.total-row {
    background-color: #f5f5f5;
    font-weight: 600;
}

.total-row td {
    border-top: 2px solid var(--color-border);
}

.actions {
    display: flex;
    gap: 6px;
    white-space: nowrap;
}

.empty-state {
    padding: 40px 20px;
    text-align: center;
    color: var(--color-text-light);
    font-size: 14px;
}

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.badge-quimico {
    background-color: #f0f0f0;
    color: #2c2c2c;
}

.badge-solvente {
    background-color: #e8e8e8;
    color: #2c2c2c;
}

.badge-aditivo {
    background-color: #e0e0e0;
    color: #2c2c2c;
}

.badge-catalizador {
    background-color: #d8d8d8;
    color: #2c2c2c;
}

.badge-otro {
    background-color: #cccccc;
    color: #2c2c2c;
}

/* ===== FILTROS ===== */
.filter-form {
    margin-bottom: 24px;
    padding: 20px;
    background-color: #fafafa;
    border-radius: 6px;
}

.filter-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

/* ===== MODAL ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background-color: white;
    border-radius: 8px;
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

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

.modal-title {
    font-size: 20px;
    font-weight: 700;
}

.modal-body {
    padding: 24px;
}

/* ===== UTILIDADES ===== */
.font-medium {
    font-weight: 500;
}

.font-bold {
    font-weight: 700;
}

.text-muted {
    color: var(--color-text-light);
}

.text-right {
    text-align: right;
}

.text-red {
    color: #6b6b6b;
}

.text-green {
    color: #2c2c2c;
}

/* ===== RESPONSIVE ===== */

/* Pantallas grandes (1400px - 1600px) */
@media (min-width: 1400px) and (max-width: 1600px) {
    .content-grid {
        grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
    }
}

/* Pantallas medianas-grandes (1200px - 1399px) */
@media (min-width: 1200px) and (max-width: 1399px) {
    .content-grid {
        grid-template-columns: minmax(300px, 350px) minmax(0, 1fr);
    }
    
    .data-table th,
    .data-table td {
        padding: 12px 10px;
    }
}

/* Tablets grandes y laptops pequeñas (1024px y menos) */
@media (max-width: 1024px) {
    .content-grid {
        grid-template-columns: 1fr;
    }

    .charts-container {
        grid-template-columns: 1fr;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .form-card, .table-card, .section-card, .detail-card {
        padding: 20px;
    }
    
    .content-wrapper {
        padding: 30px;
    }
    
    /* Las tablas ahora tienen todo el ancho disponible */
    .data-table,
    .simple-table {
        min-width: 500px;
    }
}

/* Tablets (768px y menos) */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: relative;
        height: auto;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .content-wrapper {
        padding: 20px;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .filter-row {
        grid-template-columns: 1fr;
    }

    .insumo-row {
        flex-direction: column;
        align-items: stretch;
    }

    .page-title {
        font-size: 24px;
    }
    
    .detail-info {
        flex-direction: column;
        gap: 16px;
    }
    
    .detail-header {
        flex-direction: column;
        gap: 12px;
    }
    
    .charts-container {
        grid-template-columns: 1fr;
    }
    
    .chart-card {
        padding: 16px;
    }
    
    /* Tablas compactas en tablets */
    .data-table,
    .simple-table {
        min-width: 480px;
    }
    
    .data-table th,
    .data-table td {
        padding: 10px 8px;
        font-size: 12px;
    }
    
    .data-table th {
        font-size: 10px;
    }
    
    .btn-action {
        font-size: 16px;
        padding: 4px 6px;
    }
}

/* Móviles (480px y menos) */
@media (max-width: 480px) {
    .content-wrapper {
        padding: 16px;
    }
    
    .form-card, .table-card, .section-card, .detail-card {
        padding: 16px;
    }
    
    .page-title {
        font-size: 20px;
    }
    
    .page-subtitle {
        font-size: 13px;
    }
    
    .metric-value {
        font-size: 24px;
    }
    
    .metric-title {
        font-size: 11px;
    }
    
    .btn {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn {
        width: 100%;
    }
    
    /* Tablas extra compactas en móviles */
    .data-table,
    .simple-table {
        min-width: 450px;
    }
    
    .data-table th,
    .data-table td {
        padding: 8px 6px;
        font-size: 11px;
    }
    
    .data-table th {
        font-size: 9px;
    }
    
    .badge {
        font-size: 9px;
        padding: 3px 6px;
    }
    
    .modal-content {
        max-width: 100%;
        margin: 0;
        border-radius: 0;
        max-height: 100vh;
    }
    
    .modal {
        padding: 0;
    }
    
    .filter-form {
        padding: 16px;
    }
}

/* Ajuste para pantallas muy anchas */
@media (min-width: 1600px) {
    .content-wrapper {
        max-width: 1600px;
    }
    
    .metrics-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .content-grid {
        grid-template-columns: 420px minmax(0, 1fr);
    }
}