/*
 * Tema azul de TCTEL. Se carga después del CSS de Tailwind (public/build) y está escrito a mano:
 * ni la PC ni el servidor tienen Node para recompilar Tailwind. Todas las clases empiezan con "tc-".
 */

:root {
    --tc-blue-950: #0b1f4d;
    --tc-blue-900: #102a6b;
    --tc-blue-800: #1e3a8a;
    --tc-blue-700: #1d4ed8;
    --tc-blue-600: #2563eb;
    --tc-blue-500: #3b82f6;
    --tc-blue-200: #bfdbfe;
    --tc-blue-100: #dbeafe;
    --tc-blue-50: #eff6ff;
    --tc-surface: #ffffff;
    --tc-page: #eef3fb;
    --tc-ink: #0f172a;
    --tc-ink-2: #475569;
    --tc-grid: #e2e8f0;
    --tc-series-1: #2a78d6; /* gráficos de una serie: azul */
    --tc-title-font: 'Poppins', 'Inter', 'Segoe UI', system-ui, sans-serif;
}

/* ---------- Fondo y títulos ---------- */
body.tc-app {
    background: var(--tc-page);
}

.tc-page-title {
    font-family: var(--tc-title-font);
    font-size: 1.5rem;
    line-height: 1.25;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--tc-blue-900);
}

.tc-page-title::after {
    content: '';
    display: block;
    width: 3rem;
    height: 4px;
    margin-top: 0.4rem;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--tc-blue-600), #22d3ee);
}

.tc-card-title {
    font-family: var(--tc-title-font);
    font-weight: 600;
    color: var(--tc-blue-900);
}

.tc-card-head {
    background: linear-gradient(90deg, var(--tc-blue-50), #ffffff 70%);
    border-top-left-radius: 0.75rem;
    border-top-right-radius: 0.75rem;
}

.tc-section-title {
    font-family: var(--tc-title-font);
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--tc-blue-900);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.tc-section-title::before {
    content: '';
    width: 6px;
    height: 1.1rem;
    border-radius: 999px;
    background: linear-gradient(180deg, var(--tc-blue-600), #22d3ee);
}

/* Encabezados de las tablas */
.tc-app thead {
    background: var(--tc-blue-50);
}

.tc-app thead th {
    color: var(--tc-blue-800);
}

/* ---------- Barra lateral ---------- */
.tc-sidebar {
    background: linear-gradient(180deg, var(--tc-blue-950) 0%, #12358a 55%, var(--tc-blue-700) 100%);
    color: #dbe7ff;
}

.tc-brand {
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.tc-brand-name {
    font-family: var(--tc-title-font);
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.01em;
}

.tc-brand-sub {
    color: #a9c3f7;
}

.tc-brand-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    flex-shrink: 0;
    overflow: hidden;
    border-radius: 0.6rem;
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(4, 15, 45, 0.35);
}

.tc-brand-logo img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.tc-brand-letter {
    font-family: var(--tc-title-font);
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--tc-blue-700);
}

.tc-nav-group {
    color: #8fb0f2;
    letter-spacing: 0.08em;
}

.tc-nav-link {
    color: #dbe7ff;
    font-weight: 500;
    transition: background-color 0.15s, color 0.15s;
}

.tc-nav-link:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

.tc-nav-link.is-active {
    background: #ffffff;
    color: var(--tc-blue-700);
    font-weight: 700;
    box-shadow: 0 6px 14px rgba(4, 15, 45, 0.3);
}

/* ---------- Barra superior ---------- */
.tc-header {
    border-bottom: 3px solid var(--tc-blue-600);
    box-shadow: 0 2px 10px rgba(16, 42, 107, 0.06);
}

.tc-header-company {
    font-family: var(--tc-title-font);
    font-weight: 600;
    color: var(--tc-blue-900);
}

/* ---------- Botón principal ---------- */
.tc-btn-primary {
    background: linear-gradient(135deg, var(--tc-blue-700), var(--tc-blue-500));
    color: #ffffff;
}

.tc-btn-primary:hover {
    background: linear-gradient(135deg, var(--tc-blue-800), var(--tc-blue-600));
}

/* ---------- Indicadores (tarjetas de colores) ---------- */
.tc-stat {
    position: relative;
    overflow: hidden;
    display: block;
    border-radius: 0.9rem;
    padding: 1rem 1.1rem;
    color: #ffffff;
    box-shadow: 0 8px 18px -8px rgba(15, 23, 42, 0.45);
    transition: transform 0.15s, box-shadow 0.15s;
}

a.tc-stat:hover,
a.tc-stat:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 14px 24px -10px rgba(15, 23, 42, 0.55);
    outline: none;
}

/* Círculo decorativo */
.tc-stat::before {
    content: '';
    position: absolute;
    right: -1.75rem;
    bottom: -2.25rem;
    width: 6.5rem;
    height: 6.5rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
}

/* Colores con texto blanco legible (contraste 4.5:1 o más) */
.tc-stat-slate { background: linear-gradient(135deg, #312e81, #4338ca); }
.tc-stat-blue { background: linear-gradient(135deg, #1e3a8a, #1d4ed8); }
.tc-stat-green { background: linear-gradient(135deg, #065f46, #047857); }
.tc-stat-red { background: linear-gradient(135deg, #9f1239, #be123c); }
.tc-stat-amber { background: linear-gradient(135deg, #9a3412, #b45309); }
.tc-stat-purple { background: linear-gradient(135deg, #581c87, #7e22ce); }
.tc-stat-cyan { background: linear-gradient(135deg, #155e75, #0e7490); }

.tc-stat-label {
    position: relative;
    padding-right: 2.75rem;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.92);
}

.tc-stat-value {
    position: relative;
    margin-top: 0.35rem;
    font-family: var(--tc-title-font);
    font-size: 1.65rem;
    line-height: 1.2;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.tc-stat-hint {
    position: relative;
    margin-top: 0.2rem;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.9);
}

.tc-stat-icon {
    position: absolute;
    top: 0.85rem;
    right: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 0.7rem;
    background: rgba(255, 255, 255, 0.18);
}

/* ---------- Bienvenida del panel ---------- */
.tc-hero {
    position: relative;
    overflow: hidden;
    border-radius: 1rem;
    padding: 1.4rem 1.5rem;
    margin-bottom: 1.5rem;
    color: #ffffff;
    background: linear-gradient(120deg, var(--tc-blue-950) 0%, var(--tc-blue-700) 60%, #0e7490 100%);
    box-shadow: 0 16px 30px -16px rgba(11, 31, 77, 0.7);
}

.tc-hero::after {
    content: '';
    position: absolute;
    right: -4rem;
    top: -4rem;
    width: 14rem;
    height: 14rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
}

.tc-hero-title {
    position: relative;
    font-family: var(--tc-title-font);
    font-size: 1.6rem;
    line-height: 1.2;
    font-weight: 700;
}

.tc-hero-sub {
    position: relative;
    margin-top: 0.25rem;
    color: #cfe0ff;
}

.tc-hero-actions {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.tc-hero-action {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border-radius: 999px;
    padding: 0.45rem 0.9rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--tc-blue-900);
    background: #ffffff;
    box-shadow: 0 4px 10px rgba(4, 15, 45, 0.25);
    transition: transform 0.15s;
}

.tc-hero-action:hover,
.tc-hero-action:focus-visible {
    transform: translateY(-1px);
    outline: none;
}

.tc-hero-logo {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 4rem;
    height: 4rem;
    flex-shrink: 0;
    overflow: hidden;
    border-radius: 0.9rem;
    background: #ffffff;
}

.tc-hero-logo img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

/* ---------- Gráficos de barras (una serie, sin librerías) ---------- */
.tc-chart {
    position: relative;
}

.tc-columns {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    height: 11rem;
    padding-top: 1.5rem;
    border-bottom: 1px solid var(--tc-grid);
}

.tc-column {
    position: relative;
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
    min-width: 0;
    outline: none;
}

.tc-column-bar {
    width: 100%;
    max-width: 24px;
    min-height: 2px;
    border-radius: 4px 4px 0 0;
    background: var(--tc-series-1);
}

.tc-column:hover .tc-column-bar,
.tc-column:focus-visible .tc-column-bar {
    background: var(--tc-blue-800);
}

.tc-column-value {
    margin-bottom: 0.25rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--tc-ink);
    white-space: nowrap;
}

.tc-column-labels {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.35rem;
}

.tc-column-labels span {
    flex: 1 1 0;
    min-width: 0;
    text-align: center;
    font-size: 0.72rem;
    color: var(--tc-ink-2);
    text-transform: capitalize;
}

/* Barras horizontales (ranking) */
.tc-hbars {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.tc-hbar {
    display: grid;
    grid-template-columns: minmax(6rem, 9rem) 1fr auto;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
    outline: none;
}

.tc-hbar-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--tc-ink-2);
}

.tc-hbar-track {
    height: 12px;
}

.tc-hbar-fill {
    height: 12px;
    min-width: 2px;
    border-radius: 0 4px 4px 0;
    background: var(--tc-series-1);
}

.tc-hbar-value {
    font-weight: 600;
    color: var(--tc-ink);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Ayuda al pasar el mouse o con el teclado */
[data-tip] {
    position: relative;
}

[data-tip]:hover::after,
[data-tip]:focus-visible::after {
    content: attr(data-tip);
    position: absolute;
    z-index: 20;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    padding: 0.35rem 0.55rem;
    border-radius: 0.4rem;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    color: #ffffff;
    background: var(--tc-ink);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.25);
    pointer-events: none;
}

.tc-hbar[data-tip]:hover::after,
.tc-hbar[data-tip]:focus-visible::after {
    left: auto;
    right: 0;
    transform: none;
}

.tc-table-toggle summary {
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--tc-blue-700);
}

/* ---------- Ingreso (login) ---------- */
body.tc-guest {
    background:
        radial-gradient(circle at 15% 15%, rgba(34, 211, 238, 0.25), transparent 40%),
        linear-gradient(135deg, var(--tc-blue-950), var(--tc-blue-700));
}

.tc-guest-name {
    font-family: var(--tc-title-font);
    font-weight: 700;
    color: #ffffff;
}

.tc-guest-sub {
    color: #cfe0ff;
}

.tc-guest-card {
    box-shadow: 0 24px 50px -20px rgba(4, 15, 45, 0.7);
}

/* ---------- Logotipo en la configuración ---------- */
.tc-logo-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 7rem;
    height: 7rem;
    overflow: hidden;
    border-radius: 0.9rem;
    border: 1px dashed var(--tc-blue-200);
    background: #ffffff;
}

.tc-logo-preview img {
    max-width: 92%;
    max-height: 92%;
    object-fit: contain;
}

@media (prefers-reduced-motion: reduce) {
    .tc-stat,
    .tc-hero-action,
    .tc-nav-link,
    .tc-column-bar {
        transition: none;
    }
}

.tc-hero-head {
    position: relative;
}

/* Dos gráficos lado a lado en pantallas grandes */
.tc-charts {
    display: grid;
    gap: 1rem;
}

@media (min-width: 1024px) {
    .tc-charts {
        grid-template-columns: 3fr 2fr;
    }
}

/* ---------- Vista previa de mensajes de WhatsApp ---------- */
.tc-wa-chat {
    border-radius: 0.75rem;
    padding: 0.75rem;
    background: #efeae2;
}

.tc-wa-bubble {
    position: relative;
    max-width: 30rem;
    padding: 0.5rem 0.7rem;
    border-radius: 0.6rem 0 0.6rem 0.6rem;
    margin-left: auto;
    font-size: 0.875rem;
    line-height: 1.4;
    white-space: pre-line;
    overflow-wrap: anywhere;
    color: #111b21;
    background: #d9fdd3;
    box-shadow: 0 1px 1px rgba(11, 20, 26, 0.13);
}

/* ---------- Gráficos de varias series (columnas agrupadas) ---------- */
/* Colores en orden fijo; el texto nunca usa el color de la serie. */
.tc-series-1 { --tc-series: #2a78d6; } /* azul */
.tc-series-2 { --tc-series: #eb6834; } /* naranja */
.tc-series-3 { --tc-series: #1baf7a; } /* verde agua */

.tc-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
    margin-bottom: 0.25rem;
    font-size: 0.75rem;
    color: var(--tc-ink-2);
}

.tc-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.tc-legend-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    background: var(--tc-series);
}

.tc-groups {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    height: 11rem;
    padding-top: 1.5rem;
    border-bottom: 1px solid var(--tc-grid);
}

.tc-group {
    flex: 1 1 0;
    min-width: 0;
    height: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 2px;
    outline: none;
    border-radius: 4px;
}

.tc-group:hover,
.tc-group:focus-visible {
    background: var(--tc-blue-50);
}

.tc-group-bar {
    flex: 1 1 0;
    max-width: 16px;
    min-height: 2px;
    border-radius: 4px 4px 0 0;
    background: var(--tc-series);
}

/* Barras horizontales que son enlaces */
a.tc-hbar {
    color: inherit;
    text-decoration: none;
    border-radius: 0.4rem;
}

a.tc-hbar:hover .tc-hbar-name,
a.tc-hbar:focus-visible .tc-hbar-name {
    color: var(--tc-blue-700);
    text-decoration: underline;
}

/* ---------- Alertas del panel ---------- */
.tc-alerts {
    display: grid;
    gap: 0.6rem;
}

@media (min-width: 768px) {
    .tc-alerts {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1280px) {
    .tc-alerts {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.tc-alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    border: 1px solid;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.tc-alert:hover,
.tc-alert:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px -8px rgba(15, 23, 42, 0.35);
}

.tc-alert-red { color: #9f1239; background: #fff1f2; border-color: #fecdd3; }
.tc-alert-amber { color: #92400e; background: #fffbeb; border-color: #fde68a; }
.tc-alert-blue { color: var(--tc-blue-800); background: var(--tc-blue-50); border-color: var(--tc-blue-200); }

.tc-alert-icon {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 0.55rem;
    background: rgba(255, 255, 255, 0.8);
}

.tc-alert-label {
    min-width: 0;
}

.tc-alert-count {
    margin-left: auto;
    font-family: var(--tc-title-font);
    font-size: 1.25rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* ---------- Documentos y fotos del cliente ---------- */
.tc-docs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
    gap: 0.75rem;
}

.tc-doc {
    overflow: hidden;
    border: 1px solid var(--tc-grid);
    border-radius: 0.6rem;
    background: #ffffff;
}

.tc-doc-thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 7rem;
    overflow: hidden;
    background: #f1f5f9;
}

.tc-doc-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ---------- "Más filtros" en las listas ---------- */
.tc-more-filters summary {
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--tc-blue-700);
}

@media (prefers-reduced-motion: reduce) {
    .tc-alert {
        transition: none;
    }
}

/* ---------- Mapas libres (OpenStreetMap con Leaflet) ---------- */
/* El mapa no se sube encima del menú ni de las ventanas del sistema. */
.leaflet-container {
    isolation: isolate;
    font-family: inherit;
}

.tc-map-pin,
.tc-map-house,
.tc-map-cluster,
.tc-map-node,
.tc-map-corporate,
.tc-map-nap {
    background: none;
    border: 0;
}

/* Caja NAP: cuadro verde azulado con el dibujo de una caja con sus puertos */
.tc-map-nap span {
    display: block;
    width: 22px;
    height: 22px;
    border: 2px solid #fff;
    border-radius: 6px;
    background: #0f766e url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3' y='5' width='18' height='14' rx='2' fill='none' stroke='white' stroke-width='2'/%3E%3Ccircle cx='8' cy='12' r='1.7' fill='white'/%3E%3Ccircle cx='12' cy='12' r='1.7' fill='white'/%3E%3Ccircle cx='16' cy='12' r='1.7' fill='white'/%3E%3C/svg%3E") center / 16px no-repeat;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.45);
}

/* Distancia de la casa a una caja, sobre la línea */
.tc-map-distance {
    padding: 1px 6px;
    font-size: 12px;
    font-weight: 600;
    color: #0f172a;
}

/* Mapa esperando que se toque el lugar de una caja nueva */
.leaflet-container.tc-map-adding {
    cursor: crosshair;
}

/* Casa con la ubicación ya marcada: círculo blanco con borde y casa del color de su estado (lo pone el mapa) */
.tc-map-house span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: 2px solid currentColor;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.45);
}

.tc-map-house svg {
    display: block;
    width: 16px;
    height: 16px;
}

/* Marcador en forma de gota (el color lo pone el mapa) */
.tc-map-pin span {
    display: block;
    width: 22px;
    height: 22px;
    margin: 2px;
    border: 2px solid #fff;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.45);
}

/* Grupo de casas: círculo azul con la cantidad (no usa los colores de estado) */
.tc-map-cluster span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border: 3px solid rgba(255, 255, 255, 0.9);
    border-radius: 9999px;
    background: rgba(29, 78, 216, 0.9);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.4);
}

/* Nodo: cuadrado oscuro */
.tc-map-node span {
    display: block;
    width: 16px;
    height: 16px;
    border: 2px solid #fff;
    border-radius: 3px;
    background: #0f172a;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.45);
}

/* Cliente corporativo: rombo morado */
.tc-map-corporate span {
    display: block;
    width: 14px;
    height: 14px;
    margin: 1px;
    border: 2px solid #fff;
    background: #7c3aed;
    transform: rotate(45deg);
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.45);
}

.tc-map-popup {
    min-width: 12rem;
    font-size: 0.8rem;
    line-height: 1.35;
}

.tc-map-popup strong {
    display: block;
    font-size: 0.85rem;
}

.tc-map-popup a {
    margin-right: 0.75rem;
    color: var(--tc-blue-700);
    font-weight: 500;
}

/* Soporte técnico en campo (módulo FieldService): línea de tiempo, fotos, mapa de técnicos y filas completas. */
.tc-fs-timeline { border-left: 2px solid #e2e8f0; padding-left: .75rem; }
.tc-fs-thumb { display: block; width: 100%; height: 7rem; object-fit: cover; }
.tc-fs-gallery { display: grid; gap: .75rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 640px) { .tc-fs-gallery { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tc-fs-full { grid-column: 1 / -1; }
.tc-fs-scroll { max-height: 70vh; overflow-y: auto; }
@media (min-width: 1024px) { .tc-fs-map-main { grid-column: span 3 / span 3; } }
