/* ============================================================
   ED_SHARED_TABLE.CSS - Estilos base para tablas de registros
   Ruta: css/pages/ed_shared_table.css
   ============================================================ */

body {
    background: var(--color-bg, #f8fafc);
    color: var(--color-text, #1e293b);
    min-height: 100vh;
    margin: 0;
    padding: 0;
    font-family: var(--font-sans, inherit);
}

.page-container {
    padding: 15px;
    max-width: 1200px;
    margin: 0 auto;
}

/* Selector */
.controls {
    background-color: var(--color-surface, #ffffff);
    padding: 12px 15px;
    border-radius: 10px;
    margin-bottom: 15px;
    border: 1px solid var(--color-border, #e2e8f0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.concepto-select {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--color-border, #cbd5e1);
    border-radius: 8px;
    font-size: 1rem;
    background-color: var(--color-surface, #ffffff);
    color: var(--color-text, #1e293b);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 16px;
    transition: border-color 0.2s ease;
}

.concepto-select:focus {
    outline: none;
    border-color: var(--color-primary, #680d03);
    box-shadow: 0 0 0 3px rgba(104, 13, 3, 0.12);
}

/* Tarjeta de la tabla */
.kardex-card {
    background-color: var(--color-surface, #ffffff);
    border: 1px solid var(--color-border, #e2e8f0);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    margin-bottom: 15px;
}

.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.kardex-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 700px;
    font-size: 0.85rem;
}

.kardex-table thead {
    background: var(--color-primary, #680d03);
    color: #ffffff;
}

.kardex-table th {
    padding: 12px 8px;
    text-align: center;
    font-weight: 600;
    font-size: 0.8rem;
    white-space: nowrap;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.kardex-table th:last-child {
    border-right: none;
}

.kardex-table tbody tr {
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.15s ease;
}

.kardex-table tbody tr:hover {
    background-color: #f9f5f0;
}

.kardex-table tbody tr:nth-child(even) {
    background-color: #fafafa;
}

.kardex-table tbody tr:nth-child(even):hover {
    background-color: #f9f5f0;
}

.kardex-table tbody tr.fila-editando {
    background-color: #FFF8E1 !important;
    box-shadow: inset 0 0 0 2px #FFB300;
}

.kardex-table td {
    padding: 12px 8px;
    text-align: center;
    color: #333;
    border-right: 1px solid #f0f0f0;
    vertical-align: middle;
}

.kardex-table td:last-child {
    border-right: none;
}

.kardex-table td:first-child {
    font-weight: 500;
    color: #666;
    white-space: nowrap;
}

/* Celdas numéricas */
.numeric-cell {
    text-align: right !important;
    font-family: 'Courier New', monospace;
    font-weight: 500;
}

.positive-movement {
    color: #2E8B57;
    font-weight: 600;
}

.negative-movement {
    color: #D32F2F;
    font-weight: 600;
}

.saldo-cell {
    font-weight: 700;
    background-color: #f8f4f0;
}

/* Badges */
.categoria-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    color: white;
    background-color: #2E8B57;
}

.concepto-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
    background-color: #f0f0f0;
    color: #333;
    white-space: nowrap;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.documento-badge {
    display: inline-block;
    padding: 3px 6px;
    background-color: #f0f0f0;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
}

.tipo-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    color: white;
}

.tipo-badge.compra {
    background-color: #2E8B57;
}

.tipo-badge.venta {
    background-color: #D32F2F;
}

/* Inputs y selects de edición inline */
.input-editable {
    width: 100%;
    padding: 6px 8px;
    border: 2px solid var(--color-primary, #680d03);
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: inherit;
    text-align: center;
    background-color: var(--color-surface, #ffffff);
    color: var(--color-text, #0f172a);
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.input-editable:focus {
    outline: none;
    border-color: var(--color-primary-hover, #831608);
    box-shadow: 0 0 0 3px rgba(104, 13, 3, 0.12);
}

.input-editable.input-numeric {
    text-align: right;
    font-family: 'Courier New', monospace;
}

.input-editable.input-datetime {
    text-align: center;
    font-size: 0.8rem;
    padding: 6px 4px;
    cursor: pointer;
    color: var(--color-text, #0f172a);
}

.input-editable.input-datetime::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.input-editable.input-datetime:hover::-webkit-calendar-picker-indicator {
    opacity: 1;
}

.input-editable.input-error {
    border-color: #D32F2F !important;
    background-color: #FFF5F5;
    animation: shake 0.3s ease;
}

.select-editable {
    width: 100%;
    padding: 6px 8px;
    border: 2px solid var(--color-primary, #680d03);
    border-radius: 6px;
    font-size: 0.8rem;
    font-family: inherit;
    text-align: center;
    background-color: var(--color-surface, #ffffff);
    color: var(--color-text, #0f172a);
    cursor: pointer;
    appearance: none;
    box-sizing: border-box;
}

.select-editable:focus {
    outline: none;
    border-color: var(--color-primary-hover, #831608);
    box-shadow: 0 0 0 3px rgba(104, 13, 3, 0.12);
}

.select-editable.select-error {
    border-color: #D32F2F !important;
    background-color: #FFF5F5;
    animation: shake 0.3s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    50% { transform: translateX(3px); }
    75% { transform: translateX(-3px); }
}

.error-mensaje {
    display: block;
    font-size: 0.65rem;
    color: #D32F2F;
    margin-top: 3px;
    font-weight: 500;
}

/* Botones de acción */
.acciones-cell {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.btn-editar {
    background-color: #FFF3E0;
    color: #E65100;
}

.btn-editar:hover {
    background-color: #FFE0B2;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(230, 81, 0, 0.2);
}

.btn-eliminar {
    background-color: #FFEBEE;
    color: #C62828;
}

.btn-eliminar:hover {
    background-color: #FFCDD2;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(198, 40, 40, 0.2);
}

.btn-guardar {
    background-color: #E8F5E9;
    color: #2E7D32;
}

.btn-guardar:hover {
    background-color: #C8E6C9;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(46, 125, 50, 0.2);
}

.btn-cancelar-edicion {
    background-color: #ECEFF1;
    color: #546E7A;
}

.btn-cancelar-edicion:hover {
    background-color: #CFD8DC;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(84, 110, 122, 0.2);
}

/* Scroll hint */
.scroll-hint {
    text-align: center;
    padding: 5px;
    font-size: 0.7rem;
    color: var(--color-primary, #680d03);
    background-color: var(--color-bg, #f8fafc);
    border-bottom: 1px solid var(--color-border, #e2e8f0);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Estados de carga */
.no-results {
    text-align: center;
    padding: 40px 20px;
    color: var(--color-text-muted, #64748b);
    font-size: 0.95rem;
}

.no-results i {
    font-size: 3rem;
    color: var(--color-primary, #680d03);
    margin-bottom: 15px;
    display: block;
}

.loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--color-primary, #680d03);
    font-size: 0.95rem;
}

.loading i {
    margin-right: 8px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Footer de la tabla */
.table-footer {
    background-color: var(--color-bg, #f8fafc);
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    border-top: 1px solid var(--color-border, #e2e8f0);
}

.table-footer span {
    color: var(--color-primary, #680d03);
    font-weight: 600;
}

.resumen-final {
    background-color: var(--color-bg, #f8fafc);
    padding: 15px 20px;
    border-top: 2px solid var(--color-primary, #680d03);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

.resumen-final span {
    color: var(--color-primary, #680d03);
    font-size: 1rem;
}

/* Descripción */
.descripcion-cell {
    text-align: left !important;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Toast de notificación */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: #2E7D32;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    z-index: 2000;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast.toast-error {
    background-color: #C62828;
}

.toast.mostrar {
    opacity: 1;
    transform: translateX(0);
}

/* Modal de confirmación */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-confirm {
    background: white;
    border-radius: 12px;
    padding: 25px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    text-align: center;
}

.modal-confirm h3 {
    margin: 0 0 10px 0;
    color: var(--color-primary, #680d03);
}

.modal-confirm p {
    color: var(--color-text-muted, #64748b);
    margin-bottom: 20px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.modal-confirm .cambios-resumen {
    background-color: var(--color-bg, #f8fafc);
    border: 1px solid var(--color-border, #e2e8f0);
    padding: 12px 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    text-align: left;
    font-size: 0.85rem;
    line-height: 1.6;
}

.modal-confirm .cambios-resumen strong {
    color: var(--color-primary, #680d03);
}

.modal-confirm .cambios-resumen .sin-cambios {
    color: #999;
    font-style: italic;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn-cancelar, .btn-confirmar {
    padding: 10px 20px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.btn-cancelar {
    background-color: #f0f0f0;
    color: #666;
}

.btn-cancelar:hover {
    background-color: #e0e0e0;
}

.btn-confirmar {
    background-color: #2E7D32;
    color: white;
}

.btn-confirmar:hover {
    background-color: #1B5E20;
}

.btn-confirmar-eliminar {
    background-color: #C62828;
    color: white;
}

.btn-confirmar-eliminar:hover {
    background-color: #B71C1C;
}

/* Responsive */
@media (max-width: 480px) {
    .kardex-table {
        font-size: 0.75rem;
    }
    
    .kardex-table th,
    .kardex-table td {
        padding: 10px 4px;
    }
    
    .categoria-badge,
    .concepto-badge,
    .tipo-badge,
    .documento-badge {
        padding: 2px 4px;
        font-size: 0.65rem;
    }
    
    .btn-icon {
        width: 28px;
        height: 28px;
        font-size: 0.8rem;
    }
    
    .input-editable,
    .select-editable {
        font-size: 0.75rem;
        padding: 4px 6px;
    }
    
    .toast {
        left: 20px;
        right: 20px;
        text-align: center;
        justify-content: center;
    }
}