/* ============================================================
   Dashboard Sorter - Styles
   Widget-based layout (like main dashboard)
   Corporate design system (Senda Insular)
   ============================================================ */

:root {
    --cyan:         #2BBCD4;
    --cyan-dark:    #22a8be;
    --cyan-light:   #d6f4f9;
    --cyan-bg:      #eefafd;
    --dark:         #1a2332;
    --darker:       #151d29;
    --bg:           #dde3eb;
    --bg-soft:      #f6f8fa;
    --white:        #ffffff;
    --text:         #1f2937;
    --subtext:      #6b7280;
    --muted:        #9ca3af;
    --border:       #e5e7eb;
    --border-strong: #d1d5db;

    /* Status dots */
    --dot-rojo:     #e53e3e;
    --dot-naranja:  #dd6b20;
    --dot-cyan:     #4db8c8;
    --dot-verde:    #38a169;

    /* Priority */
    --priority-critica: #e53e3e;
    --priority-alta:    #dd6b20;
    --priority-media:   #4db8c8;
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 13px;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ==================== HEADER ==================== */
.header {
    background: linear-gradient(180deg, #1e1e1e 0%, #2a2a2a 100%);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 52px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 0 rgba(43, 188, 212, 0.15), 0 4px 24px rgba(0, 0, 0, 0.25);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-logo {
    height: 26px;
    filter: brightness(0) invert(1);
}

.header-left h1 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--white);
    letter-spacing: 0.5px;
}

.header-left .subtitle {
    font-size: 0.78rem;
    color: var(--muted);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-refresh, .btn-config {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.2);
    color: var(--muted);
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-refresh:hover, .btn-config:hover {
    border-color: var(--cyan);
    color: var(--cyan);
}

.clock {
    font-size: 1.25rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--cyan);
}

.btn-panel {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.25);
    color: rgba(255,255,255,0.7);
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}
.btn-panel:hover {
    border-color: rgba(255,255,255,0.6);
    color: #fff;
}

.user-info {
    color: #ffffff;
    font-size: 0.82rem;
    font-weight: 500;
    opacity: 0.8;
}

.header-sep {
    width: 1px;
    height: 24px;
    background: rgba(255,255,255,0.15);
    margin: 0 4px;
}

/* ==================== SUMMARY CARDS ==================== */
.summary-bar {
    display: flex;
    gap: 12px;
    padding: 10px 14px;
    align-items: stretch;
}

.summary-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.summary-card .count {
    font-size: 2.8rem;
    font-weight: 800;
    line-height: 1;
}

.summary-card.s10 .count { color: var(--priority-critica); }
.summary-card.s14 .count { color: var(--priority-alta); }
.summary-card.s24 .count { color: var(--priority-media); }
.summary-card.watchlist .count { color: var(--dot-naranja); }

.summary-card .label {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

/* ==================== GRID LAYOUT ==================== */
.grid-bloques {
    display: flex;
    flex-direction: column;
    padding: 14px;
    flex: 1;
    min-height: 0;
    position: relative;
}

.bloque-full {
    grid-column: 1 / -1;
}

/* ==================== WIDGET (BLOQUE) ==================== */
.bloque {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    display: none;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
    min-height: 0;
}

.bloque.bloque-active {
    display: flex;
}

.bloque.bloque-hidden {
    display: none;
}

.bloque-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: linear-gradient(180deg, #fafbfc 0%, #f5f7fa 100%);
    border-bottom: 1px solid var(--border);
    min-height: 42px;
}

.bloque-titulo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text);
}

.bloque-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.dot-rojo    { background: var(--dot-rojo); }
.dot-naranja { background: var(--dot-naranja); }
.dot-cyan    { background: var(--dot-cyan); }
.dot-verde   { background: var(--dot-verde); }

.bloque-meta {
    display: flex;
    align-items: center;
    gap: 10px;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--white);
    min-width: 24px;
    text-align: center;
}

.badge-urgente  { background: var(--dot-rojo); }
.badge-canarias { background: var(--dot-cyan); }
.badge-watch    { background: var(--dot-naranja); }

.bloque-ts {
    font-size: 0.7rem;
    color: var(--muted);
}

/* ==================== TABLE ==================== */
.tabla-wrap {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.bloque-full .tabla-wrap {
    flex: 1;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

thead th {
    background: var(--bg-soft);
    padding: 8px 10px;
    text-align: left;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--subtext);
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

tbody tr {
    border-bottom: 1px solid #f0f2f4;
    transition: background 0.15s;
}

tbody tr:hover {
    background: var(--cyan-bg);
}

tbody td {
    padding: 7px 10px;
    font-size: 0.8rem;
    white-space: nowrap;
    color: var(--text);
}

td.loading {
    text-align: center;
    padding: 2rem;
    color: var(--muted);
    font-style: italic;
}

td.vacio {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--muted);
    font-size: 0.85rem;
}

/* Priority row highlight */
.row-s10 {
    border-left: 3px solid var(--priority-critica);
    background: rgba(229, 62, 62, 0.03);
}

.row-s14 {
    border-left: 3px solid var(--priority-alta);
}

/* ==================== BADGES SERVICIO ==================== */
.badge-servicio {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-servicio.s10 {
    background: #fee2e2;
    color: var(--priority-critica);
}

.badge-servicio.s14 {
    background: #fef3c7;
    color: var(--priority-alta);
}

.badge-servicio.s24 {
    background: var(--cyan-light);
    color: var(--cyan-dark);
}

/* ==================== MODAL ==================== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 200;
}

.modal-overlay.show {
    display: block;
}

.modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--white);
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 201;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    overflow: hidden;
    display: none;
    flex-direction: column;
}

.modal.show {
    display: flex;
}

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

.modal-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--subtext);
    padding: 4px 8px;
    border-radius: 4px;
}

.modal-close:hover {
    background: var(--bg);
    color: var(--text);
}

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

.modal-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.modal-table th {
    background: var(--bg-soft);
    padding: 8px 10px;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--subtext);
    border-bottom: 1px solid var(--border);
}

.modal-table td {
    padding: 8px 10px;
    font-size: 0.82rem;
    border-bottom: 1px solid #f0f2f4;
}

/* ==================== WATCHLIST CONTROLS ==================== */
.watchlist-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.watchlist-controls input {
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-family: inherit;
    flex: 1;
    min-width: 150px;
}

.watchlist-controls input:focus {
    outline: none;
    border-color: var(--cyan);
    box-shadow: 0 0 0 2px rgba(43, 188, 212, 0.15);
}

/* ==================== BUTTONS ==================== */
.btn {
    padding: 8px 16px;
    border-radius: 4px;
    border: none;
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--cyan);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--cyan-dark);
}

.btn-danger {
    background: none;
    color: var(--dot-rojo);
    border: 1px solid var(--dot-rojo);
    padding: 4px 10px;
    font-size: 0.72rem;
}

.btn-danger:hover {
    background: #fee2e2;
}

/* ==================== ROTATION INDICATOR ==================== */
.rotation-indicator {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 8px 0;
}

.rot-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border-strong);
    transition: background 0.3s, transform 0.2s;
    cursor: pointer;
}

.rot-dot:hover {
    background: var(--cyan-dark);
    transform: scale(1.3);
}

.rot-dot.active {
    background: var(--cyan);
}

/* ==================== FOOTER ==================== */
.footer {
    display: none;
    background: linear-gradient(180deg, #2a2a2a 0%, #1e1e1e 100%);
    padding: 1rem 2rem;
    text-align: center;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 -1px 0 rgba(43, 188, 212, 0.1);
}

/* ==================== TOAST ==================== */
.toast {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    padding: 10px 16px;
    border-radius: 6px;
    color: var(--white);
    font-weight: 500;
    font-size: 0.82rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 1000;
    transform: translateY(80px);
    opacity: 0;
    transition: all 0.3s ease;
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--dot-verde); }
.toast.error { background: var(--dot-rojo); }
.toast.info { background: var(--cyan); }

/* ==================== RESPONSIVE (large sorter screen) ==================== */
@media (min-width: 1920px) {
    body { font-size: 15px; }
    .summary-card .count { font-size: 4rem; }
    .summary-card .label { font-size: 1.4rem; }
    .clock { font-size: 1.8rem; }
    tbody td { padding: 10px 14px; font-size: 1rem; }
    thead th { font-size: 0.85rem; padding: 10px 14px; }
    .bloque-titulo { font-size: 1.1rem; }
    .badge { font-size: 0.9rem; padding: 3px 10px; }
    .rot-dot { width: 14px; height: 14px; }
}

/* Tablet */
@media (max-width: 1200px) {
    .summary-bar { flex-wrap: wrap; }
    .summary-card { flex: 1 1 45%; }
}

@media (max-width: 768px) {
    .header { padding: 0 0.75rem; height: 48px; }
    .header-logo { height: 22px; }
    .header-left .subtitle { display: none; }
    .header-right { gap: 0.5rem; }
    .btn-refresh, .btn-config { padding: 4px 8px; font-size: 0.7rem; }
    .clock { font-size: 1rem; }

    .summary-bar { flex-wrap: wrap; gap: 8px; padding: 10px; }
    .summary-card { padding: 10px 12px; flex: 1 1 45%; }
    .summary-card .count { font-size: 2rem; }
    .summary-card .label { font-size: 0.8rem; }

    .grid-bloques { gap: 10px; padding: 10px; }
    .bloque-header { padding: 8px 10px; }
    .bloque-titulo { font-size: 0.75rem; }

    thead th { padding: 6px 8px; font-size: 0.65rem; }
    tbody td { padding: 6px 8px; font-size: 0.75rem; }

    .modal { width: 95%; max-height: 90vh; }
    .modal-header { padding: 0.75rem 1rem; }
    .modal-body { padding: 1rem; }
    .watchlist-controls { flex-direction: column; }
    .watchlist-controls input { min-width: auto; width: 100%; }

    .footer { padding: 0.75rem; font-size: 0.7rem; }
}

/* Mobile */
@media (max-width: 480px) {
    .header { height: 44px; }
    .header-logo { height: 18px; }
    .btn-config { display: none; }
    .clock { font-size: 0.9rem; }

    .summary-bar { flex-wrap: wrap; gap: 6px; padding: 8px; }
    .summary-card { padding: 8px 10px; border-radius: 4px; flex: 1 1 45%; }
    .summary-card .count { font-size: 1.5rem; }
    .summary-card .label { font-size: 0.7rem; }

    .grid-bloques { padding: 8px; gap: 8px; }
    .bloque { border-radius: 4px; }
    .bloque-titulo { font-size: 0.7rem; gap: 5px; }
    .bloque-dot { width: 8px; height: 8px; }
    .badge { font-size: 0.65rem; padding: 1px 6px; }
    .bloque-ts { display: none; }

    thead th { font-size: 0.6rem; padding: 5px 6px; }
    tbody td { font-size: 0.7rem; padding: 5px 6px; }

    .toast { bottom: 0.5rem; right: 0.5rem; left: 0.5rem; font-size: 0.75rem; }
}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
