/* Estilos Generales */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 50px rgba(0,0,0,0.2);
    padding: 30px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

.header h1 {
    color: #667eea;
    font-size: 2em;
}

.header .actions {
    display: flex;
    gap: 10px;
}

/* Botones */
.btn {
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s;
    border: none;
    cursor: pointer;
    display: inline-block;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn-warning {
    background: #ffc107;
    color: #000;
}

.btn-warning:hover {
    background: #e0a800;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-info {
    background: #17a2b8;
    color: white;
}

.btn-info:hover {
    background: #138496;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.875em;
}

.btn-icon {
    text-decoration: none;
    font-size: 1.2em;
    padding: 5px 8px;
    transition: transform 0.2s;
    display: inline-block;
}

.btn-icon:hover {
    transform: scale(1.2);
}

/* Tabla */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
}

td {
    padding: 12px 15px;
    border-bottom: 1px solid #f0f0f0;
}

tbody tr:hover {
    background-color: #f8f9fa;
}

.actions-cell {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* Badges */
.badge {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
    display: inline-block;
}

.badge-success {
    background-color: #28a745;
    color: white;
}

.badge-warning {
    background-color: #ffc107;
    color: #000;
}

.badge-danger {
    background-color: #dc3545;
    color: white;
}

.badge-secondary {
    background-color: #6c757d;
    color: white;
}

/* Formularios */
.form-container {
    max-width: 800px;
    margin: 0 auto;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 600;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.form-group textarea {
    resize: vertical;
    font-family: inherit;
}

.error {
    color: #dc3545;
    font-size: 0.875em;
    margin-top: 5px;
    display: block;
}

.form-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
}

/* Detalle */
.detail-container {
    max-width: 800px;
    margin: 0 auto;
}

.detail-row {
    display: grid;
    grid-template-columns: 200px 1fr;
    padding: 15px;
    border-bottom: 1px solid #f0f0f0;
}

.detail-row:hover {
    background-color: #f8f9fa;
}

.detail-label {
    font-weight: 600;
    color: #667eea;
}

.detail-value {
    color: #333;
}

.detail-value a {
    color: #667eea;
    text-decoration: none;
}

.detail-value a:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 15px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .detail-row {
        grid-template-columns: 1fr;
        gap: 5px;
    }
    
    table {
        font-size: 0.9em;
    }
    
    th, td {
        padding: 8px;
    }
}

/* Estilos para imágenes */
.imagen-cell {
    width: 80px;
    text-align: center;
}

.img-thumbnail {
    width: 70px;
    height: 70px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
}

.no-image {
    font-size: 2em;
    color: #ccc;
}

/* Galería de imágenes en formulario */
.imagenes-existentes,
.imagenes-preview {
    margin-top: 20px;
    margin-bottom: 20px;
}

.imagenes-existentes label,
.imagenes-preview label {
    display: block;
    margin-bottom: 10px;
    color: #667eea;
    font-weight: 600;
}

.imagenes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 10px;
}

.imagen-item {
    position: relative;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
}

.imagen-item img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 5px;
    margin-bottom: 8px;
}

.imagen-item span {
    display: block;
    font-size: 0.85em;
    color: #666;
    word-break: break-all;
}

.btn-eliminar-imagen {
    margin-top: 8px;
    padding: 5px 10px;
    background-color: #dc3545;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.85em;
}

.btn-eliminar-imagen:hover {
    background-color: #c82333;
}

/* Galería en detalle */
.galeria-imagenes {
    margin-bottom: 30px;
}

.galeria-imagenes h3 {
    color: #667eea;
    margin-bottom: 15px;
}

.imagenes-grid-detalle {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.imagen-detalle-item img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 10px;
    border: 3px solid #e0e0e0;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
}

.imagen-detalle-item img:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
}

/* Modal para imagen completa */
.modal-imagen {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.9);
    justify-content: center;
    align-items: center;
}

.modal-imagen-content {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

.modal-imagen .cerrar {
    position: absolute;
    top: 20px;
    right: 40px;
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}

.modal-imagen .cerrar:hover {
    color: #ccc;
}

/* Collapse para imágenes */
.imagenes-collapse {
    margin-top: 30px;
    border-top: 2px solid #f0f0f0;
    padding-top: 20px;
}

.collapse-btn {
    width: 100%;
    padding: 15px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s;
}

.collapse-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

#collapse-icon {
    font-size: 0.8em;
    transition: transform 0.3s;
}

.galeria-imagenes-content {
    margin-top: 20px;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Estilos para imagen principal */
.imagen-principal {
    border: 3px solid #ffd700 !important;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.imagen-actions {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 8px;
}

.btn-marcar-principal {
    padding: 5px 10px;
    background-color: #ffc107;
    color: #000;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 600;
}

.btn-marcar-principal:disabled {
    background-color: #ffd700;
    cursor: default;
}

.btn-marcar-principal:not(:disabled):hover {
    background-color: #ffb300;
}
/* Estilos para Filtros */
.filters-container {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    border: 1px solid #dee2e6;
}

.filters-form {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end;
}

.filter-group {
    flex: 1;
    min-width: 160px;
    display: flex;
    flex-direction: column;
}

.filter-group label {
    font-weight: 600;
    color: #495057;
    margin-bottom: 8px;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group select {
    padding: 10px 12px;
    border: 2px solid #ced4da;
    border-radius: 8px;
    font-size: 1em;
    background-color: white;
    transition: all 0.3s;
    cursor: pointer;
    color: #495057;
}

.filter-group select:hover {
    border-color: #667eea;
}

.filter-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.filters-form .btn {
    margin-top: auto;
    padding: 10px 25px;
    font-size: 0.95em;
    white-space: nowrap;
}

.filters-form .btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
}

.filters-form .btn-secondary {
    background: #6c757d;
    border: none;
}

/* Contador de resultados */
.result-count {
    background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
    border-left: 4px solid #667eea;
    padding: 15px 20px;
    margin-bottom: 20px;
    border-radius: 8px;
}

.result-count p {
    margin: 0;
    color: #495057;
    font-size: 1em;
}

.result-count strong {
    color: #667eea;
    font-weight: 700;
}

.result-count span {
    color: #764ba2;
    font-weight: 700;
    font-size: 1.1em;
}

/* Responsive para filtros */
@media (max-width: 1024px) {
    .filter-group {
        min-width: 140px;
    }
}

@media (max-width: 768px) {
    .filters-container {
        padding: 20px;
    }
    
    .filters-form {
        gap: 12px;
    }
    
    .filter-group {
        min-width: 100%;
        flex: 1 1 100%;
    }
    
    .filters-form .btn {
        width: 100%;
        margin-top: 5px;
    }
}

@media (max-width: 480px) {
    .filters-container {
        padding: 15px;
    }
    
    .filter-group label {
        font-size: 0.85em;
    }
    
    .filter-group select {
        padding: 8px 10px;
        font-size: 0.9em;
    }
}

/* Estilos para Detalle de Estado de Cuenta */
.estado-cuenta-card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    margin-bottom: 15px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
}

.card-header-estado {
    background: #667eea;
    padding: 12px 18px;
    color: white;
}

.tarjeta-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.tarjeta-nombre {
    margin: 0;
    font-size: 1.1em;
    font-weight: 600;
    color: white;
}

.periodo-badge {
    background: rgba(255,255,255,0.2);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 600;
}

.card-body-estado {
    padding: 15px;
}

/* Grid de datos */
.datos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 15px;
}

.dato-card {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid #dee2e6;
    transition: all 0.2s;
}

.dato-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.dato-icon {
    font-size: 1.5em;
    line-height: 1;
}

.dato-content {
    flex: 1;
}

.dato-content label {
    display: block;
    font-size: 0.7em;
    color: #6c757d;
    font-weight: 600;
    margin-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.dato-content span {
    display: block;
    font-size: 1em;
    color: #495057;
    font-weight: 600;
}

/* Formulario de vencimiento */
.dato-vencimiento {
    background: #fff9e6;
    border-color: #ffc107;
}

.vencimiento-form label {
    margin-bottom: 8px;
}

.vencimiento-input-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.vencimiento-input-group input {
    flex: 1;
    padding: 6px 10px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 600;
    color: #495057;
}

.vencimiento-input-group input:focus {
    outline: none;
    border-color: #667eea;
}

.vencimiento-input-group .btn {
    padding: 6px 12px;
    font-size: 1em;
}

/* Formulario de estado de pago */
.dato-pago {
    background: #e8f5e9;
    border-color: #28a745;
}

.pago-form label {
    margin-bottom: 8px;
}

.pago-input-group {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.estado-pago-badge {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 600;
    display: inline-block;
}

.estado-pago-badge.pagado {
    background-color: #28a745;
    color: white;
}

.estado-pago-badge.pendiente {
    background-color: #ffc107;
    color: #000;
}

.pago-input-group .btn {
    padding: 6px 12px;
    font-size: 0.9em;
}

/* Totales destacados */
.totales-destacados {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.total-card {
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    transition: all 0.2s;
    border: 2px solid;
}

.total-card:hover {
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
}

.total-pesos {
    background: #f0fdf4;
    border-color: #28a745;
}

.total-dolares {
    background: #eff6ff;
    border-color: #007bff;
}

.total-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.total-icon {
    font-size: 1.1em;
    line-height: 1;
}

.total-label {
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #495057;
}

.total-amount {
    font-size: 1.4em;
    font-weight: 700;
    text-align: right;
    color: #212529;
}

/* Sección de gastos */
.gastos-section {
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    border: 1px solid #e0e0e0;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 2px solid #667eea;
    flex-wrap: wrap;
    gap: 8px;
}

.section-header h3 {
    margin: 0;
    color: #667eea;
    font-size: 1.1em;
}

.gastos-count {
    background: #f0f4ff;
    padding: 4px 12px;
    border-radius: 12px;
    font-weight: 600;
    color: #667eea;
    border: 1px solid #667eea;
    font-size: 0.85em;
}

/* Estilos mejorados para la tabla de gastos */
.gastos-section table {
    margin-top: 0;
}

.fecha-cell {
    font-weight: 600;
    color: #495057;
}

.tipo-badge {
    background: #e9ecef;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 600;
    color: #495057;
    display: inline-block;
}

.descripcion-cell {
    color: #495057;
    font-weight: 500;
}

.cuota-badge {
    background: #fff9e6;
    padding: 4px 10px;
    border-radius: 5px;
    font-size: 0.8em;
    font-weight: 600;
    color: #856404;
    display: inline-block;
}

.monto-cell {
    font-family: 'Courier New', monospace;
    font-size: 1em;
    color: #28a745;
    font-weight: 600;
}

.moneda-badge {
    padding: 4px 8px;
    border-radius: 5px;
    font-weight: 600;
    font-size: 0.85em;
    display: inline-block;
}

.moneda-pesos {
    background: #d4edda;
    color: #155724;
}

.moneda-dolares {
    background: #cce5ff;
    color: #004085;
}

.actions-column {
    text-align: center;
}

.actions-cell {
    text-align: center;
    white-space: nowrap;
}

.actions-cell .btn {
    padding: 6px 10px;
    margin: 0 2px;
    font-size: 1em;
}

/* Responsive para detalle de estado de cuenta */
@media (max-width: 768px) {
    .tarjeta-info {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .tarjeta-nombre {
        font-size: 1.4em;
    }
    
    .datos-grid {
        grid-template-columns: 1fr;
    }
    
    .totales-destacados {
        grid-template-columns: 1fr;
    }
    
    .total-amount {
        font-size: 1.8em;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .gastos-section table {
        font-size: 0.85em;
    }
    
    .actions-cell .btn {
        padding: 6px 10px;
        font-size: 1em;
        margin: 2px;
    }
}

@media (max-width: 480px) {
    .card-body-estado {
        padding: 20px;
    }
    
    .dato-card {
        padding: 15px;
    }
    
    .dato-icon {
        font-size: 2em;
    }
    
    .total-card {
        padding: 20px;
    }
    
    .total-amount {
        font-size: 1.5em;
    }
}

/* Estilos para módulo de Cuentas y Gastos de Débito */
.totals-container {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin: 25px 0;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 10px;
}

.total-card {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 30px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
}

.total-label {
    font-size: 0.95em;
    color: #666;
    font-weight: 600;
}

.total-value {
    font-size: 1.5em;
    font-weight: bold;
    color: #667eea;
}

/* Alertas adicionales */
.alert-warning {
    background-color: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
}

.alert-info {
    background-color: #d1ecf1;
    border: 1px solid #17a2b8;
    color: #0c5460;
}

/* Textos especiales */
.text-danger {
    color: #dc3545 !important;
    font-weight: bold;
}

.text-muted {
    color: #6c757d;
    font-size: 0.875em;
}

.form-text {
    display: block;
    margin-top: 5px;
}

/* ============================================
   RESPONSIVE TABLES - MOBILE CARDS
   ============================================ */

/* Ocultar labels móviles en desktop */
.mobile-label {
    display: none;
}

@media screen and (max-width: 768px) {
    
    /* Mostrar labels móviles */
    .mobile-label {
        display: inline-block;
        font-weight: 700;
        color: #667eea;
        margin-right: 8px;
    }
    
    /* Cambiar estructura de tabla a bloques en móviles */
    .table-container table,
    .table-container table tbody {
        display: block;
        width: 100%;
    }
    
    /* Ocultar encabezados */
    .table-container table thead {
        display: none;
    }
    
    /* Convertir cada fila en una card */
    .table-container table tbody tr {
        display: block;
        background: white;
        border: 2px solid #ddd;
        border-radius: 10px;
        margin-bottom: 15px;
        padding: 15px;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    }
    
    /* Cada celda se muestra como un bloque */
    .table-container table tbody td {
        display: block;
        padding: 10px 0;
        border-bottom: 1px solid #f0f0f0;
        font-size: 0.95em;
        text-align: left;
    }
    
    .table-container table tbody td:last-child {
        border-bottom: none;
        text-align: center;
        padding-top: 15px;
        margin-top: 10px;
        border-top: 2px solid #667eea;
    }
    
    .table-container table tbody td:last-child a {
        display: inline-block;
        margin: 0 10px;
    }
    
    /* Acciones en móviles - más grandes */
    .table-container table tbody td:last-child a {
        font-size: 2em !important;
        display: inline-block;
        margin: 0 5px;
    }
    
    /* Header y filtros más compactos */
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .header h1 {
        font-size: 1.5em;
    }
    
    .header .actions {
        flex-direction: column;
        width: 100%;
    }
    
    .header .actions .btn {
        width: 100%;
        text-align: center;
    }
    
    .filters-form {
        flex-direction: column;
    }
    
    .filter-group {
        width: 100% !important;
    }
    
    .result-count {
        flex-direction: column;
        gap: 10px;
    }
    
    /* Mejorar espaciado del container en móviles */
    .container {
        padding: 15px;
    }
}

/* Para tablets (entre 768px y 1024px) */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    .container {
        padding: 20px;
    }
    
    .table-container table {
        font-size: 0.9em;
    }
    
    .table-container table th,
    .table-container table td {
        padding: 8px;
    }
}
