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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f7fa;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 30px;
    text-align: center;
    border-left: 4px solid #1abc9c;
}

h1 {
    color: #2C3E50;
    margin-bottom: 10px;
}

.subtitle {
    color: #7f8c8d;
}

/* Botones */
.btn {
    display: inline-block;
    padding: 10px 20px;
    background: #2C3E50;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    font-size: 0.95em;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(44, 62, 80, 0.2);
}

.btn-primary {
    background: #3498db;
}

.btn-primary:hover:not(:disabled) {
    background: #2980b9;
}

.btn-secondary {
    background: #95a5a6;
}

.btn-secondary:hover:not(:disabled) {
    background: #7f8c8d;
}

.btn-success {
    background: #1abc9c;
}

.btn-success:hover:not(:disabled) {
    background: #16a085;
}

.btn-danger {
    background: #e74c3c;
}

.btn-danger:hover:not(:disabled) {
    background: #c0392b;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-matching {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
}

.btn-matching:hover:not(:disabled) {
    background: linear-gradient(135deg, #8e44ad, #7d3c98);
}

/* Data Viewer */
.data-viewer {
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border-left: 4px solid #1abc9c;
}

.data-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.search-box {
    flex: 1;
    min-width: 200px;
}

.search-box input {
    width: 100%;
    padding: 10px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.95em;
    transition: border-color 0.3s;
}

.search-box input:focus {
    outline: none;
    border-color: #1abc9c;
}

.stats {
    background: #ecf0f1;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 600;
    color: #2C3E50;
}

/* Tabla */
.data-table-container {
    max-height: 60vh;
    overflow-y: auto;
    overflow-x: auto;
}

.data-table-container table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.data-table-container th,
.data-table-container td {
    padding: 12px 15px;
    border: 1px solid #e0e0e0;
    text-align: left;
}

.data-table-container th {
    background: #1abc9c;
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
    font-weight: 600;
}

.data-table-container tr:nth-child(even) {
    background-color: #f8f9fa;
}

.data-table-container tr:hover {
    background-color: #e8f8f5;
}

/* Columnas especificas */
.col-check {
    width: 40px;
    text-align: center;
}

.cell-check {
    text-align: center;
}

.row-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #e74c3c;
}

.row-selected {
    background: rgba(231, 76, 60, 0.08) !important;
}

.row-selected:hover {
    background: rgba(231, 76, 60, 0.14) !important;
}

.col-ts {
    width: 140px;
    text-align: center;
}

.col-nombre {
    min-width: 200px;
}

.col-especie {
    width: 120px;
}

.col-producto {
    min-width: 260px;
}

.col-envio {
    width: 120px;
    text-align: center;
}

.col-acciones {
    width: 100px;
    text-align: center;
}

/* Celdas especiales */
.cell-ts {
    font-family: monospace;
    font-size: 0.85em;
    color: #7f8c8d;
}

.cell-nombre {
    font-weight: 600;
    color: #2C3E50;
}

.cell-especie {
    text-transform: uppercase;
    font-size: 0.85em;
    background: #ecf0f1;
    padding: 3px 8px;
    border-radius: 4px;
    display: inline-block;
}

.cell-producto {
    line-height: 1.55;
}

.producto-nombre {
    display: block;
    font-weight: 700;
    color: #2C3E50;
    font-size: 0.92em;
}

.detalle-linea {
    display: block;
    font-size: 0.82em;
    color: #546e7a;
}

.detalle-precio {
    display: block;
    font-size: 0.82em;
    color: #27ae60;
    font-weight: 600;
}

.cell-envio {
    font-size: 0.9em;
}

.cell-envio.inmediato {
    color: #27ae60;
    font-weight: 600;
}

.cell-envio.diferido {
    color: #e67e22;
}

.loading-cell {
    text-align: center;
    padding: 40px;
    color: #7f8c8d;
}

/* Botones de accion en tabla */
.btn-action {
    padding: 6px 12px;
    font-size: 0.85em;
    border-radius: 4px;
}

/* Info message */
.info-message {
    background: #d5f4e6;
    border-left: 4px solid #1abc9c;
    padding: 15px;
    border-radius: 6px;
    margin-top: 20px;
    color: #155724;
    display: none;
}

.info-message.error {
    background: #f8d7da;
    border-left-color: #e74c3c;
    color: #721c24;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    overflow-y: auto;
}

.modal-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 10px;
    padding: 30px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
}

.modal-header h3 {
    color: #2C3E50;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    line-height: 1;
}

.modal-close:hover {
    color: #333;
}

.modal-form-group {
    margin-bottom: 20px;
}

.modal-form-group label {
    display: block;
    color: #2C3E50;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.9em;
}

.modal-form-group input,
.modal-form-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 1em;
    font-family: inherit;
    transition: border-color 0.3s;
}

.modal-form-group input:focus,
.modal-form-group select:focus {
    outline: none;
    border-color: #1abc9c;
}

.modal-form-row {
    display: flex;
    gap: 15px;
}

.modal-form-row .modal-form-group {
    flex: 1;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 2px solid #e0e0e0;
}

.modal-actions .btn-danger {
    margin-right: auto;
}

/* Stats con matches */
.stats {
    display: flex;
    gap: 15px;
    align-items: center;
}

.stats-matches {
    background: #9b59b6;
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85em;
}

/* Badge de compradores interesados */
.buyer-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 600;
    margin-left: 10px;
    cursor: pointer;
    animation: vibrate 1.5s ease-in-out infinite;
    box-shadow: 0 2px 8px rgba(155, 89, 182, 0.4);
}

.buyer-badge:hover {
    animation: none;
    transform: scale(1.05);
}

.buyer-badge .badge-icon {
    font-size: 1.1em;
}

.buyer-badge .badge-count {
    background: rgba(255, 255, 255, 0.3);
    padding: 1px 6px;
    border-radius: 10px;
}

/* Animacion de vibracion sutil */
@keyframes vibrate {
    0%, 100% {
        transform: translateX(0);
    }
    50% {
        transform: translateX(1px);
    }
}

/* Fila con compradores */
.row-has-buyers {
    background: linear-gradient(90deg, rgba(155, 89, 182, 0.08), transparent) !important;
}

.row-has-buyers:hover {
    background: linear-gradient(90deg, rgba(155, 89, 182, 0.15), rgba(232, 248, 245, 0.5)) !important;
}

/* Tooltip de compradores */
.buyers-tooltip {
    position: absolute;
    background: #2C3E50;
    color: white;
    padding: 12px 15px;
    border-radius: 8px;
    font-size: 0.85em;
    z-index: 100;
    min-width: 200px;
    max-width: 300px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

.buyers-tooltip::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 20px;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid #2C3E50;
}

.buyers-tooltip-title {
    font-weight: 700;
    margin-bottom: 8px;
    color: #1abc9c;
}

.buyers-tooltip-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.buyers-tooltip-list li {
    padding: 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.buyers-tooltip-list li:last-child {
    border-bottom: none;
}

/* Responsive */
@media (max-width: 768px) {
    .data-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box {
        order: -1;
    }

    .modal-form-row {
        flex-direction: column;
        gap: 0;
    }

    .col-ts {
        display: none;
    }

    .buyer-badge {
        margin-left: 5px;
        padding: 2px 6px;
        font-size: 0.7em;
    }
}
