/* 
 * modules.css - Estilos globales para módulos ERP Pakar
 * Filosofía MVP: Minimalista, reutilizable, semántico
 * Fecha: 2025-01-22
 */

/* === CONTENEDORES BASE === */
.module-container {
    padding: 1rem;
    color: var(--terminal-text);
    background: var(--terminal-bg);
    min-height: 100vh;
}

.module-header {
    text-align: center;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--terminal-accent);
    padding-bottom: 1rem;
}

.module-title {
    color: var(--terminal-accent);
    margin: 0 0 0.5rem 0;
    font-size: 1.8rem;
}

.module-subtitle {
    color: var(--terminal-text);
    margin: 0;
    font-size: 0.9rem;
    opacity: 0.8;
}

/* === TABLAS RESPONSIVAS === */
.table-container {
    overflow-x: auto;
    overflow-y: hidden;
    border: 1px solid var(--terminal-accent);
    border-radius: var(--border-radius);
    margin-top: var(--spacing-md);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--terminal-bg);
    table-layout: auto;
}

.data-table th {
    background: rgba(0, 255, 0, 0.1);
    color: var(--terminal-accent);
    font-weight: bold;
    position: sticky;
    top: 0;
    white-space: nowrap;
}

.data-table th,
.data-table td {
    padding: 0.3rem 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--terminal-accent);
    white-space: nowrap;
    vertical-align: middle;
}

.data-table tr:hover {
    background: rgba(0, 255, 0, 0.05);
}

/* === TEXTO TRUNCADO PARA TABLAS === */
.text-truncate {
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    vertical-align: middle;
}

.text-truncate-sm {
    max-width: 100px;
}

.text-truncate-md {
    max-width: 200px;
}

.text-truncate-lg {
    max-width: 300px;
}

/* Tooltip para mostrar texto completo al hover */
.text-truncate {
    position: relative;
}

.text-truncate:hover {
    cursor: help;
}

/* Contenedor para celdas con texto truncado */
td {
    position: relative;
}

.text-truncate[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 0;
    background: var(--terminal-bg);
    border: 1px solid var(--terminal-accent);
    padding: 0.5rem;
    border-radius: var(--border-radius);
    white-space: normal;
    word-wrap: break-word;
    z-index: 100;
    min-width: 200px;
    max-width: 400px;
    box-shadow: 0 2px 8px rgba(0, 255, 0, 0.3);
    margin-bottom: 5px;
    font-size: 0.9rem;
    line-height: 1.4;
}

/* === GRIDS Y CARDS === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: rgba(0, 255, 0, 0.1);
    border: 1px solid var(--terminal-accent);
    border-radius: var(--border-radius);
    padding: 1rem;
    text-align: center;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--terminal-accent);
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--terminal-text);
    opacity: 0.8;
}

/* === FORMULARIOS MODULARES === */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.form-section {
    border: 1px solid var(--terminal-accent);
    border-radius: var(--border-radius);
    padding: 1rem;
    background: rgba(0, 255, 0, 0.05);
}

.form-section-title {
    color: var(--terminal-accent);
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
}

/* === BOTONES GLOBALES === */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.btn-primary {
    background: var(--terminal-accent);
    color: var(--terminal-bg);
}

.btn-primary:hover {
    background: var(--terminal-text);
    transform: scale(1.05);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--terminal-text);
    border: 1px solid var(--terminal-accent);
}

.btn-danger {
    background: rgba(255, 0, 0, 0.2);
    color: var(--error);
    border: 1px solid var(--error);
}

.btn-danger:hover {
    background: var(--error);
    color: var(--terminal-bg);
}

.btn-small {
    padding: 0.2rem 0.4rem;
    font-size: 0.75rem;
    line-height: 1;
}

/* Botón específico para tablas */
.data-table .btn-table {
    padding: 0.1rem 0.3rem !important;
    font-size: 0.75rem;
    line-height: 1;
    vertical-align: middle;
    display: inline-flex;
    align-items: center;
    height: auto;
    min-height: unset;
}

/* Iconos estandarizados para tablas */
.table-icon {
    font-size: 0.875rem !important;
    line-height: 1 !important;
    display: inline-block;
    vertical-align: middle;
}

/* Iconos específicos para archivos en botones de tabla - más pequeños */
.data-table button .table-icon {
    font-size: 0.75rem !important;
    line-height: 1 !important;
    transform: scale(0.9);
    display: inline-block;
    vertical-align: middle;
}

/* Iconos de acciones mantienen tamaño estándar */
.action-buttons .table-icon {
    font-size: 0.875rem !important;
    line-height: 1 !important;
    transform: none;
}

/* Botones ultra-compactos para iconos en tablas */
.btn-table-icon {
    padding: 0.2rem 0.3rem !important;
    font-size: 0.75rem !important;
    line-height: 1 !important;
    min-height: auto !important;
    border: 1px solid transparent !important;
    background: transparent !important;
    color: var(--terminal-accent) !important;
    vertical-align: middle;
    cursor: pointer;
    border-radius: var(--border-radius);
    transition: all var(--transition-fast);
}

.btn-table-icon:hover {
    background: rgba(0, 255, 0, 0.1) !important;
    border-color: var(--terminal-accent) !important;
}

.btn-table-icon:focus {
    outline: 2px solid var(--terminal-accent);
    outline-offset: 1px;
}

/* Optimizar padding de celdas para tablas más compactas */
.data-table td {
    padding: 0.3rem 0.5rem !important;
    vertical-align: middle;
    line-height: 1.2;
}

/* === ESTADOS === */
.status-badge {
    padding: 0.15rem 0.4rem;
    border-radius: var(--border-radius);
    font-size: 0.75rem;
    font-weight: bold;
    display: inline-block;
    line-height: 1.2;
}

.status-inactive {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
}

.status-active {
    background: rgba(0, 255, 0, 0.2);
    color: var(--terminal-accent);
}

.status-warning {
    background: rgba(255, 255, 0, 0.2);
    color: var(--warning);
}

.status-complete {
    background: rgba(0, 255, 0, 0.3);
    color: var(--success);
}

/* === MODAL === */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background: var(--terminal-bg);
    border: 2px solid var(--terminal-accent);
    border-radius: var(--border-radius);
    width: 100%;
    max-width: 1200px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

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

.modal-body {
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
}

.modal-close {
    background: none;
    border: 1px solid var(--terminal-accent);
    color: var(--terminal-accent);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--border-radius);
}

/* === SECCIONES === */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-title {
    color: var(--terminal-accent);
    margin: 0;
    font-size: 1.2rem;
}

/* === UTILIDADES === */
.text-center { text-align: center; }
.text-muted { opacity: 0.8; }
.full-width { grid-column: 1 / -1; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

/* Modal sizes */
.modal-small {
    max-width: 500px;
}

/* Warning message */
.warning-message {
    background-color: rgba(255, 0, 0, 0.1);
    border: 2px solid #ff0000;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.warning-message p {
    margin: 0.5rem 0;
    color: #ff9999;
}

.warning-message strong {
    color: #ff0000;
}

/* Detail grid for modal views */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.detail-item {
    padding: 0.5rem;
    border-bottom: 1px solid #333;
}

.detail-label {
    font-weight: bold;
    color: #00cc00;
    margin-right: 0.5rem;
}

.detail-value {
    color: #00ff00;
}

/* Action buttons group */
.action-buttons {
    display: flex;
    gap: 0.3rem;
    justify-content: center;
}

.action-buttons .btn-table {
    margin: 0;
}

/* === LOADING Y MENSAJES === */
.loading-container {
    text-align: center;
    padding: 3rem;
}

.loading-spinner {
    border: 3px solid var(--terminal-accent);
    border-top-color: transparent;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.empty-message {
    text-align: center;
    padding: 3rem;
    border: 2px dashed var(--terminal-accent);
    border-radius: var(--border-radius);
    background: rgba(0, 255, 0, 0.05);
}

/* === PREVIEW FIELD === */
.preview-field {
    padding: 0.5rem;
    background: rgba(0, 255, 0, 0.1);
    border: 1px dashed var(--terminal-accent);
    color: var(--terminal-text);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    opacity: 0.7;
    font-style: italic;
    border-radius: var(--border-radius);
}

.preview-field.preview-ready {
    opacity: 1;
    font-style: normal;
    font-weight: bold;
    border-style: solid;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .module-container {
        padding: 0.5rem;
    }
    
    .module-title {
        font-size: 1.5rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .data-table {
        font-size: 0.8rem;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.3rem;
    }
}