/* Contenedor principal */
.dashboard-container {
    max-width: 95%;
    margin: 30px auto;
    padding: 0 15px;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    margin: 0;
    color: #333;
    min-height: 100vh;
}

h1 {
    margin: 0;
    color: #2c3e50;
    font-size: 28px;
}

/* Dashboard Header */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

.header-title {
    display: flex;
    align-items: center;
    gap: 15px;
}

.status-badge-header {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-running {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: #fff;
}

.badge-paused {
    background: linear-gradient(135deg, #ffc107 0%, #ffb300 100%);
    color: #000;
}

.badge-inactive {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    color: #fff;
}

.badge-error {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: #fff;
}

.header-controls {
    display: flex;
    gap: 8px;
}

.control-status-banner {
    margin-bottom: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    display: none;
    animation: slideInDown 0.3s ease-out;
}

.control-status-banner.success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: #fff;
}

.control-status-banner.error {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: #fff;
}

.alerts-section {
    margin-bottom: 20px;
}

@media (max-width: 768px) {
    .dashboard-header {
        flex-direction: column;
        gap: 15px;
    }

    .header-title {
        flex-direction: column;
        text-align: center;
    }

    .header-controls {
        width: 100%;
        justify-content: center;
    }
}

/* Controles del sistema */
.control-panel {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.control-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.control-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 12px;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.control-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.control-btn:active {
    transform: translateY(0);
}

.control-btn.btn-loading {
    opacity: 0.6;
    cursor: wait;
    pointer-events: none;
}

.pause-btn {
    background: linear-gradient(45deg, #ffc107, #ffb300);
    color: #000;
}
.resume-btn {
    background: linear-gradient(45deg, #28a745, #20c997);
    color: #fff;
}
.restart-btn {
    background: linear-gradient(45deg, #17a2b8, #20c997);
    color: #fff;
}

.timestamp {
    font-size: 11px;
    color: #6c757d;
    margin-top: 5px;
}

.system-status {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.status-healthy { background-color: #28a745; }
.status-warning { background-color: #ffc107; }
.status-critical { background-color: #dc3545; }
.status-paused { background-color: #6c757d; }

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.system-ok {
    font-size: 18px;
    font-weight: bold;
    color: #155724;
    margin: 0;
}

.system-warning {
    font-size: 18px;
    font-weight: bold;
    color: #856404;
    margin: 0;
}

.system-critical {
    font-size: 18px;
    font-weight: bold;
    color: #721c24;
    margin: 0;
}

.system-paused {
    font-size: 18px;
    font-weight: bold;
    color: #495057;
    margin: 0;
}

/* Fila de métricas principales - Grid Responsive */
.metrics-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.metric-card {
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 20px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Sección de Salud del Sistema */
.health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
    padding-bottom: 10px;
}

.health-item {
    background: rgba(248, 249, 250, 0.5);
    padding: 12px 15px;
    border-radius: 8px;
    border-left: 4px solid #007bff;
}

.health-item-label {
    font-size: 12px;
    color: #6c757d;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

.health-item-value {
    font-size: 18px;
    font-weight: bold;
    color: #2c3e50;
}

.health-item-value.status-healthy {
    color: #28a745;
}

.health-item-value.status-warning {
    color: #ffc107;
}

.health-item-value.status-critical {
    color: #dc3545;
}

.health-error-message {
    margin-top: 15px;
    padding: 12px 15px;
    background: rgba(220, 53, 69, 0.1);
    border-left: 4px solid #dc3545;
    border-radius: 8px;
    color: #721c24;
    font-size: 13px;
}

@media (max-width: 1400px) {
    .metrics-row {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }
}

@media (max-width: 768px) {
    .metrics-row {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }

    .health-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
}

/* Fila de gráficos - HORIZONTAL (solo para los dos gráficos específicos) */
.charts-row {
    display: flex;
    gap: 20px;
    width: 100%;
}

.chart-card {
    flex: 1;
    min-width: 400px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 20px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Resto de elementos - ANCHO COMPLETO VERTICAL */
.full-width-row {
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 30px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.full-width-row > h2,
.full-width-row > table,
.full-width-row > div,
.full-width-row > .control-buttons {
    padding-left: 20px;
    padding-right: 20px;
}

.full-width-row > h2:first-child {
    padding-top: 20px;
}

.full-width-row > *:last-child {
    padding-bottom: 20px;
}

/* Fila de estadísticas de entidades y reintentos */
.stats-row {
    display: flex;
    gap: 20px;
    width: 100%;
}

.stats-card {
    flex: 1;
    min-width: 300px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 20px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 20px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover,
.metric-card:hover,
.chart-card:hover,
.full-width-row:hover,
.stats-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

h2 {
    font-size: 18px;
    margin: 0 0 15px;
    color: #2c3e50;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 8px;
}

.metric-value {
    font-size: 36px;
    font-weight: bold;
    color: #0066cc;
    margin: 10px 0;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.metric-value.success {
    color: #28a745;
}

.metric-value.warning {
    color: #ffc107;
}

.metric-value.error {
    color: #dc3545;
}

.metric-label {
    font-size: 14px;
    color: #6c757d;
    font-weight: 500;
}

/* Tablas mejoradas */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

th, td {
    padding: 12px 8px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
}

th {
    background: linear-gradient(45deg, #f8f9fa, #e9ecef);
    font-weight: 600;
    color: #495057;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

tr:hover {
    background-color: #f8f9fa;
}

/* Status badges mejorados */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-ok {
    background: linear-gradient(45deg, #d4edda, #c3e6cb);
    color: #155724;
    border: 1px solid #c3e6cb;
}

.status-warning {
    background: linear-gradient(45deg, #fff3cd, #ffeaa7);
    color: #856404;
    border: 1px solid #ffeaa7;
}

.status-error {
    background: linear-gradient(45deg, #f8d7da, #fab1a0);
    color: #721c24;
    border: 1px solid #fab1a0;
}

/* Control status */
.control-status {
    margin-top: 15px;
    padding: 12px;
    border-radius: 8px;
    background: rgba(248, 249, 250, 0.8);
    border-left: 4px solid #007bff;
    font-size: 13px;
}

.control-status.success {
    border-left-color: #28a745;
    background: rgba(212, 237, 218, 0.3);
}

.control-status.error {
    border-left-color: #dc3545;
    background: rgba(248, 215, 218, 0.3);
}

/* Error analysis */
.error-analysis {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.chart-container {
    flex: 2;
    min-width: 300px;
}

.error-details {
    flex: 1;
    min-width: 250px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.error-item {
    padding: 15px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background: rgba(248, 249, 250, 0.5);
    transition: background-color 0.3s ease;
}

.error-item:hover {
    background: rgba(233, 236, 239, 0.8);
}

.error-count {
    font-weight: bold;
    color: #dc3545;
    font-size: 18px;
}

.error-type {
    font-weight: 600;
    color: #495057;
    margin-bottom: 5px;
}

/* Entidades */
.entity-item {
    margin-bottom: 15px;
    padding: 15px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.7);
    transition: all 0.3s ease;
}

.entity-item:hover {
    background: rgba(255, 255, 255, 0.9);
    border-color: #007bff;
}

.entity-details {
    margin-top: 8px;
    font-size: 12px;
    color: #6c757d;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

/* Advanced metrics */
.advanced-metrics-container {
    margin-top: 15px;
}

.advanced-metrics-container select {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #ced4da;
    width: 100%;
    background-color: white;
    font-size: 14px;
}

/* Configuración */
.config-section {
    margin-top: 20px;
    padding: 20px;
    background: rgba(248, 249, 250, 0.7);
    border-radius: 10px;
    border: 1px solid #dee2e6;
}

.config-section h4 {
    margin: 0 0 15px 0;
    color: #495057;
    font-size: 16px;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 8px;
}

.info-table {
    margin-bottom: 20px;
}

/* Consumer info panel */
.consumer-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.consumer-stat {
    background: rgba(255, 255, 255, 0.8);
    padding: 12px;
    border-radius: 8px;
    border-left: 4px solid #007bff;
    text-align: center;
}

.consumer-stat-value {
    font-size: 20px;
    font-weight: bold;
    color: #2c3e50;
}

.consumer-stat-label {
    font-size: 12px;
    color: #6c757d;
    margin-top: 4px;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin: 10px 0;
    border-left: 4px solid;
}

.alert-info {
    background-color: rgba(13, 110, 253, 0.1);
    border-left-color: #0d6efd;
    color: #055160;
}

.alert-warning {
    background-color: rgba(255, 193, 7, 0.1);
    border-left-color: #ffc107;
    color: #664d03;
}

.alert-danger {
    background-color: rgba(220, 53, 69, 0.1);
    border-left-color: #dc3545;
    color: #58151c;
}

/* Loading states */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 1024px) {
    .charts-row {
        flex-direction: column;
    }
    
    .chart-card {
        min-width: 0;
        width: 100%;
    }
    
    .stats-row {
        flex-direction: column;
    }
    
    .stats-card {
        min-width: 0;
        width: 100%;
    }
}

@media (max-width: 768px) {
    .metrics-row {
        flex-direction: column;
        align-items: center;
    }

    .metric-card {
        max-width: 100%;
        width: 100%;
    }

    .top-row {
        flex-direction: column;
        align-items: center;
    }

    .top-row .card {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .control-buttons {
        justify-content: center;
    }

    .error-analysis {
        flex-direction: column;
    }

    .consumer-info {
        grid-template-columns: 1fr;
    }

    /* Responsive table */
    table, thead, tbody, th, td, tr {
        display: block;
    }

    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    tr {
        border: 1px solid #ccc;
        margin-bottom: 10px;
        padding: 15px;
        border-radius: 8px;
        background: rgba(255, 255, 255, 0.9);
    }

    td {
        border: none;
        border-bottom: 1px solid #eee;
        position: relative;
        padding-left: 50%;
        padding-top: 8px;
        padding-bottom: 8px;
    }

    td:before {
        content: attr(data-label) ": ";
        position: absolute;
        left: 6px;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        font-weight: bold;
        color: #495057;
        font-size: 12px;
        text-transform: uppercase;
    }

    td:last-child {
        border-bottom: 0;
    }
}

@media (max-width: 480px) {
    .metric-value {
        font-size: 28px;
    }

    .control-btn {
        padding: 6px 12px;
        font-size: 11px;
    }
    
    .dashboard-container {
        padding: 0 10px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
        color: #e9ecef;
    }

    .card,
    .metric-card,
    .chart-card,
    .full-width-row,
    .stats-card {
        background: rgba(33, 37, 41, 0.95);
        color: #e9ecef;
    }

    h1, h2 {
        color: #f8f9fa;
    }

    .metric-label {
        color: #adb5bd;
    }

    th {
        background: linear-gradient(45deg, #343a40, #495057);
        color: #f8f9fa;
    }

    tr:hover {
        background-color: rgba(52, 58, 64, 0.5);
    }
}

/* Sistema de Alertas */
.alerts-wrapper {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.alert {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    animation: slideInDown 0.3s ease-out;
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alert-icon {
    font-size: 20px;
    margin-right: 12px;
}

.alert-message {
    flex: 1;
}

.alert-danger {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: #fff;
    border-left: 5px solid #bd2130;
}

.alert-warning {
    background: linear-gradient(135deg, #ffc107 0%, #e0a800 100%);
    color: #212529;
    border-left: 5px solid #d39e00;
}

.alert-info {
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
    color: #fff;
    border-left: 5px solid #117a8b;
}

/* API Button */
.api-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
    text-decoration: none;
    color: #2c3e50;
    font-weight: 600;
    font-size: 13px;
    border: 1px solid #e0e0e0;
}

.api-btn:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}