﻿/* ================================================================ */
/* PARTIDAS MODAL - ESTILOS COMPLETOS */
/* ================================================================ */

:root {
    --modal-primary: #1a1a2e;
    --modal-secondary: #16213e;
    --modal-success: #10b981;
    --modal-warning: #f59e0b;
    --modal-error: #ef4444;
    --modal-bg: rgba(0, 0, 0, 0.8);
    --modal-content-bg: #ffffff;
    --modal-border: #e5e7eb;
    --modal-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* ================================================================ */
/* OVERLAY Y ESTRUCTURA BASE */
/* ================================================================ */

.partidas-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--modal-bg);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.partidas-modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.partidas-modal-content {
    background: var(--modal-content-bg);
    border-radius: 16px;
    box-shadow: var(--modal-shadow);
    width: 90vw;
    max-width: 1200px;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.95) translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.partidas-modal-overlay.show .partidas-modal-content {
    transform: scale(1) translateY(0);
}

/* ================================================================ */
/* HEADER DEL MODAL */
/* ================================================================ */

.partidas-modal-header {
    background: linear-gradient(135deg, var(--modal-primary), var(--modal-secondary));
    color: white;
    padding: 24px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 16px 16px 0 0;
}

.partidas-modal-title {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.partidas-modal-title .id-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
}

.partidas-modal-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 20px;
}

.partidas-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ================================================================ */
/* BODY DEL MODAL */
/* ================================================================ */

.partidas-modal-body {
    padding: 32px;
    overflow-y: auto;
    flex: 1;
}

/* ================================================================ */
/* INFORMACIÃ“N BÃSICA DE LA PARTIDA */
/* ================================================================ */

.partida-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.info-card {
    background: #f8fafc;
    border: 1px solid var(--modal-border);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.2s;
}

.info-card:hover {
    background: #f1f5f9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.info-card h4 {
    margin: 0 0 16px 0;
    font-size: 14px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value {
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 8px;
}

.info-secondary {
    font-size: 14px;
    color: #64748b;
}

/* Colores especÃ­ficos para diferentes tipos de informaciÃ³n */
.info-card.codigo .info-value {
    color: var(--modal-primary);
}

.info-card.precio-oferta .info-value {
    color: var(--modal-success);
}

.info-card.precio-real .info-value {
    color: var(--modal-warning);
}

.info-card.precio-real.mayor .info-value {
    color: var(--modal-error);
}

.info-card.cantidad .info-value {
    color: var(--modal-secondary);
}

/* ================================================================ */
/* SECCIÃ“N DE GRÃFICOS */
/* ================================================================ */

.charts-section {
    margin-bottom: 32px;
}

.charts-section h3 {
    font-size: 20px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

.chart-container {
    background: #ffffff;
    border: 1px solid var(--modal-border);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
}

.chart-container h4 {
    margin: 0 0 20px 0;
    font-size: 16px;
    font-weight: 600;
    color: #374151;
}

.chart-canvas {
    width: 100% !important;
    height: 200px !important;
}

/* ================================================================ */
/* TABLA DE GASTOS */
/* ================================================================ */

.gastos-section {
    margin-bottom: 24px;
}

.gastos-section h3 {
    font-size: 20px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.gastos-table-container {
    background: var(--table-bg);
    border: 1px solid var(--modal-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.gastos-table {
    width: 100%;
    border-collapse: collapse;
}

.gastos-table th {
    background: var(--bg-light);
    color: #374151;
    font-weight: var(--font-weight-semibold);
    padding: var(--table-cell-padding-lg);
    text-align: left;
    border-bottom: 1px solid var(--modal-border);
    font-size: var(--table-font-size-lg);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.gastos-table td {
    padding: var(--table-cell-padding-md);
    border-bottom: 1px solid var(--table-border-light);
    font-size: var(--table-font-size-lg);
    color: #1e293b;
}

.gastos-table tr:hover {
    background: var(--table-row-hover);
}

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

/* Estilos para diferentes columnas */
.gastos-table .fecha-col {
    font-family: var(--font-family);
    font-weight: 600;
    color: var(--modal-primary);
}

.gastos-table .monto-col {
    text-align: right;
    font-weight: 600;
    color: var(--modal-success);
}

.gastos-table .categoria-col {
    font-size: 12px;
    color: var(--modal-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ================================================================ */
/* ESTADOS Y BADGES */
/* ================================================================ */

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.activo {
    background: #dcfce7;
    color: #166534;
}

.status-badge.pendiente {
    background: #fef3c7;
    color: #92400e;
}

.status-badge.completado {
    background: #dbeafe;
    color: #1e40af;
}

/* ================================================================ */
/* LOADING Y ESTADOS */
/* ================================================================ */

.partidas-modal-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px;
    color: #64748b;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f1f5f9;
    border-top: 4px solid var(--modal-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.partidas-modal-error {
    padding: 40px;
    text-align: center;
    color: var(--modal-error);
}

.partidas-modal-error .error-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

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

@media (max-width: 768px) {
    .partidas-modal-content {
        width: 95vw;
        max-height: 95vh;
        margin: 20px;
    }

    .partidas-modal-header {
        padding: 20px;
    }

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

    .partidas-modal-body {
        padding: 20px;
    }

    .partida-info-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .charts-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .gastos-table {
        font-size: 12px;
    }

    .gastos-table th,
    .gastos-table td {
        padding: 8px 6px;
    }
}

@media (max-width: 480px) {
    .partidas-modal-content {
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }

    .partidas-modal-header {
        border-radius: 0;
    }
}

/* ================================================================ */
/* ANIMACIONES Y EFECTOS */
/* ================================================================ */

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

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

.slide-up {
    animation: slideUp 0.3s ease-out;
}

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

/* ================================================================ */
/* UTILIDADES */
/* ================================================================ */

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

.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }

.text-sm { font-size: 14px; }
.text-xs { font-size: 12px; }
.text-lg { font-size: 18px; }
.text-xl { font-size: 20px; }

.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }

.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }

/* ================================================================ */
/* ESTILOS PARA MODAL COMPLETO */
/* ================================================================ */

.partidas-content-wrapper {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 24px 0;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--modal-border);
}

.section-title i {
    color: var(--modal-primary);
}

/* InformaciÃ³n BÃ¡sica */
.partidas-info-section {
    background: #f8fafc;
    border-radius: 16px;
    padding: 24px;
    border: 1px solid var(--modal-border);
}

.partidas-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

.info-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    transition: all 0.2s ease;
}

.info-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.info-card.span-2 {
    grid-column: span 2;
}

.info-label {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.info-value {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
}

.partida-id {
    background: var(--modal-success);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    display: inline-block;
}

.precio-oferta {
    color: #3b82f6;
}

.precio-real {
    color: var(--modal-success);
}

.precio-real.precio-alto {
    color: var(--modal-error);
    background: #fef2f2;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #fecaca;
}

/* GrÃ¡ficos */
.partidas-charts-section {
    background: #f8fafc;
    border-radius: 16px;
    padding: 24px;
    border: 1px solid var(--modal-border);
}

.charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

.chart-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}

.chart-card h4 {
    margin: 0 0 20px 0;
    font-size: 16px;
    font-weight: 600;
    color: #374151;
}

.chart-wrapper {
    position: relative;
    height: 200px;
    width: 100%;
}

/* Tabla de Gastos */
.partidas-expenses-section {
    background: #f8fafc;
    border-radius: 16px;
    padding: 24px;
    border: 1px solid var(--modal-border);
}

.expenses-badge {
    background: var(--modal-primary);
    color: white;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: 600;
}

.no-expenses {
    text-align: center;
    padding: 40px 20px;
    background: white;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
}

.no-expenses-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.no-expenses-title {
    font-size: 18px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

.no-expenses-text {
    color: #6b7280;
    font-size: 14px;
}

.expenses-table-container {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.expenses-table {
    width: 100%;
    border-collapse: collapse;
}

.expenses-header th {
    background: linear-gradient(135deg, var(--modal-primary), var(--modal-secondary));
    color: white;
    padding: 16px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.expense-row {
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.2s ease;
}

.expense-row:hover {
    background: #f8fafc;
}

.expense-cell {
    padding: 12px;
    font-size: 14px;
    color: #374151;
}

.expenses-total {
    background: #f3f4f6;
    font-weight: 700;
}

.expenses-total td {
    padding: 16px 12px;
    border-top: 2px solid var(--modal-primary);
}

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

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

/* Loading */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid var(--modal-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

.loading-text {
    color: #6b7280;
    font-size: 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
    .partidas-info-grid {
        grid-template-columns: 1fr;
    }
    
    .info-card.span-2 {
        grid-column: span 1;
    }
    
    .charts-container {
        grid-template-columns: 1fr;
    }
    
    .expenses-table-container {
        overflow-x: auto;
    }
}

/* ================================================================ */
/* ESTILOS PARA PESTAÃ‘A DE OBSERVACIONES */
/* ================================================================ */

.observaciones-container {
    padding: 20px;
    background: #f8fafc;
    min-height: 500px;
}

.observaciones-header {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.observaciones-header h3 {
    margin: 0 0 10px 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.partida-info {
    display: flex;
    gap: 20px;
    font-size: 0.9rem;
    opacity: 0.9;
}

.observaciones-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Formulario de nueva observaciÃ³n */
.observacion-form {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
}

.observacion-form h4 {
    margin: 0 0 20px 0;
    color: #374151;
    font-size: 1.2rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

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

.form-group label {
    font-weight: 500;
    margin-bottom: 5px;
    color: #374151;
    font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.2s;
    background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #1a1a2e;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 20px;
}

.btn-save-obs {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.btn-save-obs:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* Lista de observaciones */
.observaciones-lista {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
}

.observaciones-lista h4 {
    margin: 0 0 20px 0;
    color: #374151;
    font-size: 1.2rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.historial-container {
    max-height: 500px;
    overflow-y: auto;
}

.loading-observaciones,
.no-observaciones,
.error-observaciones {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
}

.loading-observaciones i {
    font-size: 2rem;
    color: #1a1a2e;
    margin-bottom: 10px;
}

.no-observaciones i,
.error-observaciones i {
    font-size: 3rem;
    margin-bottom: 15px;
    color: #9ca3af;
}

.error-observaciones i {
    color: #ef4444;
}

/* Items de observaciones */
.observaciones-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.observacion-item {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 15px;
    background: #fafafa;
    transition: all 0.2s;
}

.observacion-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-color: #d1d5db;
}

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

.obs-info {
    flex: 1;
}

.obs-asunto {
    margin: 0 0 8px 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #374151;
}

.obs-meta {
    display: flex;
    gap: 15px;
    font-size: 0.85rem;
    color: #6b7280;
}

.obs-tipo {
    background: #f3f4f6;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.obs-actions {
    display: flex;
    gap: 8px;
}

.btn-edit-obs,
.btn-delete-obs {
    background: none;
    border: 1px solid #d1d5db;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.8rem;
}

.btn-edit-obs {
    color: #1a1a2e;
}

.btn-edit-obs:hover {
    background: #1a1a2e;
    color: white;
    border-color: #1a1a2e;
}

.btn-delete-obs {
    color: #ef4444;
}

.btn-delete-obs:hover {
    background: #ef4444;
    color: white;
    border-color: #ef4444;
}

.obs-content {
    font-size: 0.9rem;
    line-height: 1.5;
    color: #4b5563;
}

.obs-content p {
    margin: 0;
}

/* Tipos de observaciones con colores */
.obs-general .obs-tipo { background: #f3f4f6; color: #374151; }
.obs-tecnica .obs-tipo { background: #dbeafe; color: #1e40af; }
.obs-calidad .obs-tipo { background: #dcfce7; color: #15803d; }
.obs-seguridad .obs-tipo { background: #fef3c7; color: #d97706; }
.obs-avance .obs-tipo { background: #e0e7ff; color: #5b21b6; }
.obs-problema .obs-tipo { background: #fee2e2; color: #dc2626; }
.obs-mejora .obs-tipo { background: #ecfdf5; color: #059669; }

/* Notificaciones */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border-radius: 8px;
    padding: 15px 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-left: 4px solid #1a1a2e;
    z-index: 11000;
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.3s ease;
}

.notification.show {
    transform: translateX(0);
    opacity: 1;
}

.notification-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.notification-success {
    border-left-color: #10b981;
}

.notification-error {
    border-left-color: #ef4444;
}

.notification-info {
    border-left-color: #3b82f6;
}

/* Responsive para observaciones */
@media (max-width: 1024px) {
    .observaciones-content {
        flex-direction: column;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .partida-info {
        flex-direction: column;
        gap: 5px;
    }
}

@media (max-width: 768px) {
    .observaciones-container {
        padding: 15px;
    }
    
    .observaciones-header {
        padding: 15px;
    }
    
    .observacion-form,
    .observaciones-lista {
        padding: 15px;
    }
    
    .obs-header {
        flex-direction: column;
        gap: 10px;
    }
    
    .obs-actions {
        align-self: flex-start;
    }
}
