/* ============================================
   ESTILOS GLOBALES
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f5f5;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    overflow: hidden;
}

.container {
    width: 100%;
    height: 100vh;
    background: white;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ============================================
   HEADER
   ============================================ */
.header {
    background: #ff183d;
    color: white;
    padding: 20px;
    text-align: center;
    flex-shrink: 0;
}

.header h1 {
    font-size: 6vh;
    margin: 0;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.header p {
    display: none;
}

.header.hidden {
    display: none;
}

.group-indicator {
    background: rgba(255, 255, 255, 0.3);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 1.2em;
    font-weight: bold;
}

/* ============================================
   CONTROLES
   ============================================ */
.controls {
    padding: 20px;
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
    flex-shrink: 0;
}

.controls.hidden {
    display: none;
}

.input-group {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.input-wrapper {
    flex: 1;
    min-width: 300px;
}

.input-wrapper label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 0.95em;
}

.input-wrapper input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 1em;
    transition: all 0.3s;
}

.input-wrapper input:focus {
    outline: none;
    border-color: #ff183d;
    box-shadow: 0 0 0 3px rgba(255, 24, 61, 0.1);
}

.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, #ff183d 0%, #ff4d6d 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 24, 61, 0.4);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #5a6268;
}

/* ============================================
   BARRA DE ESTADO
   ============================================ */
.status-bar {
    padding: 15px 20px;
    background: #fff;
    border-bottom: 2px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    flex-shrink: 0;
}

.status-bar.hidden {
    display: none;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.status-dot.disconnected {
    background: #dc3545;
}

.status-dot.connecting {
    background: #ffc107;
}

.status-dot.connected {
    background: #28a745;
}

.status-dot.error {
    background: #dc3545;
    animation: none;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.status-text {
    font-weight: 600;
    font-size: 1em;
}

.last-update {
    color: #6c757d;
    font-size: 0.9em;
}

/* ============================================
   PANEL DE DATOS
   ============================================ */
.data-panel {
    padding: 0;
    flex: 1;
    background: #f5f5f5;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.data-panel.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #6c757d;
}

.data-panel.empty svg {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.data-content {
    display: none;
}

.data-content.active {
    display: block;
}

.data-header {
    display: none;
}

/* ============================================
   SUCURSALES
   ============================================ */
.sucursales-row {
    display: flex;
    width: 100%;
    flex: 1;
    height: 100%;
}

.sucursal-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin: 8px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}

.sucursal-header {
    background: #66bb6a;
    color: white;
    padding: 2vh;
    font-weight: bold;
    font-size: 5vh;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sucursal-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* ============================================
   TABLA DE PEDIDOS
   ============================================ */
.pedidos-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #e0e0e0;
}

.pedidos-table th {
    background: #f5f5f5;
    padding: 1vh;
    text-align: center;
    font-weight: bold;
    font-size: 4vh;
    color: #333;
    border: 1px solid #e0e0e0;
}

.pedidos-table td {
    padding: 1vh;
    text-align: center;
    border: 1px solid #e0e0e0;
    font-size: 3.5vh;
}

.pedidos-table tbody tr {
    background: white;
}

.pedidos-table tbody tr:nth-child(even) {
    background: #fafafa;
}

.folio {
    font-weight: bold;
    color: #ff183d;
}

.no-pedidos {
    text-align: center;
    padding: 20px;
    color: #9e9e9e;
    font-style: italic;
}

.empty-column {
    background: rgba(255, 255, 255, 0.3);
    border: 1px solid #e0e0e0;
}

/* ============================================
   ESTADOS Y MENSAJES
   ============================================ */
.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 15px 20px;
    border-radius: 8px;
    border-left: 4px solid #dc3545;
    margin-bottom: 20px;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #6c757d;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #ff183d;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.json-viewer {
    display: none;
}

.json-viewer.visible {
    display: block;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    max-height: 300px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.8em;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin-top: 20px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1200px) {
    .sucursales-row {
        flex-wrap: wrap;
    }

    .sucursal-column {
        min-width: calc(50% - 16px);
        flex: 0 0 calc(50% - 16px);
    }
}

@media (max-width: 768px) {
    .header h1 {
        font-size: 1.8em;
        flex-direction: column;
        gap: 10px;
    }

    .input-group {
        flex-direction: column;
    }

    .input-wrapper {
        width: 100%;
        min-width: unset;
    }

    .status-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .sucursales-row {
        flex-direction: column;
    }

    .sucursal-column {
        width: 100%;
        margin: 8px;
    }
}