﻿/* ============================================
   MARN/Usuarios — estilos compartidos
   ============================================ */

.page-header {
    margin-bottom: 1.5rem;
}

.page-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.page-header h1 {
    font-size: 22px;
    font-weight: 500;
    margin: 0 0 4px;
    color: #1f2937;
}

.page-header .subtitulo {
    font-size: 13px;
    color: #6b7280;
    margin: 0;
}

.link-volver {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: #185FA5;
    text-decoration: none;
    margin-bottom: 1rem;
    margin-left: 0; /* alineado con el card */
}

    .link-volver:hover {
        text-decoration: underline;
    }

/* ============================================
   Card
   ============================================ */
.card {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    max-width: 960px; /* o 880px si quieres más densidad */
    margin: 0 auto; /* centrar */
}

.card-body {
    padding: 1.5rem;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

    .card-header h2 {
        font-size: 17px;
        font-weight: 500;
        margin: 0 0 2px;
        color: #1f2937;
    }

    .card-header .subtitulo {
        font-size: 13px;
        color: #6b7280;
        margin: 0;
    }

/* ============================================
   Toolbar (búsqueda + contador)
   ============================================ */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
}

.search-wrapper {
    position: relative;
    flex: 1;
    max-width: 380px;
}

    .search-wrapper svg {
        position: absolute;
        left: 12px;
        top: 50%;
        transform: translateY(-50%);
        color: #9ca3af;
    }

.search-input {
    width: 100%;
    padding: 9px 12px 9px 34px;
    font-size: 13px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    background: #ffffff;
}

    .search-input:focus {
        outline: none;
        border-color: #BA7517;
        box-shadow: 0 0 0 3px rgba(186, 117, 23, 0.12);
    }

.contador {
    font-size: 12px;
    color: #6b7280;
    white-space: nowrap;
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: -0.25rem 0 1rem;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 32px;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 600;
    color: #4b5563;
    background: #ffffff;
    border: 1px solid rgba(31, 41, 55, 0.14);
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

    .filter-chip:hover {
        background: #f8fafc;
        border-color: rgba(31, 41, 55, 0.28);
        color: #1f2937;
    }

    .filter-chip.active {
        background: #263238;
        border-color: #263238;
        color: #ffffff;
        box-shadow: 0 1px 2px rgba(31, 41, 55, 0.16);
    }

.chip-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 20px;
    padding: 0 6px;
    font-size: 11px;
    color: #6b7280;
    background: #eef2f6;
    border-radius: 999px;
}

    .filter-chip.active .chip-count {
        color: #263238;
        background: #ffffff;
    }

/* ============================================
   Form (rows + campos)
   ============================================ */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.875rem;
    margin-bottom: 0.25rem; /* antes era más */
}

.campo {
    margin-bottom: 0.875rem;
}

    .campo label {
        display: block;
        font-size: 13px;
        font-weight: 500;
        margin-bottom: 6px;
        color: #374151;
    }

    .campo .form-control {
        width: 100%;
        padding: 10px 12px;
        font-size: 14px;
        border: 1px solid rgba(0, 0, 0, 0.15);
        border-radius: 8px;
        background: #ffffff;
        transition: border-color 0.15s, box-shadow 0.15s;
    }

        .campo .form-control:focus {
            outline: none;
            border-color: #BA7517;
            box-shadow: 0 0 0 3px rgba(186, 117, 23, 0.12);
        }

    .campo .hint {
        font-weight: 400;
        font-size: 12px;
        color: #9ca3af;
        margin-left: 4px;
    }

    .campo .ayuda {
        font-size: 12px;
        color: #6b7280;
    }

/* ============================================
   Acciones (botones del form)
   ============================================ */
.acciones {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.btn-primario {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    font-size: 13px;
    font-weight: 500;
    background: #2C2C2A;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}

    .btn-primario:hover {
        background: #444441;
        color: #ffffff;
    }

    .btn-primario:disabled {
        background: #9ca3af;
        cursor: not-allowed;
    }

.btn-secundario {
    padding: 9px 18px;
    font-size: 13px;
    font-weight: 500;
    background: transparent;
    color: #374151;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

    .btn-secundario:hover {
        background: #f9fafb;
    }

/* ============================================
   Badges (rol y estado)
   ============================================ */
.badge-rol {
    display: inline-block;
    padding: 3px 10px;
    font-size: 12px;
    background: #F0EBE0;
    color: #6B5728;
    border-radius: 12px;
    font-weight: 500;
}

.badge-estado {
    display: inline-block;
    padding: 3px 10px;
    font-size: 11px;
    border-radius: 12px;
    font-weight: 500;
}

    .badge-estado.verificado {
        background: #E1F5EE;
        color: #0F6E56;
    }

    .badge-estado.pendiente {
        background: #FAEEDA;
        color: #854F0B;
    }

/* ============================================
   Botones de icono (acciones del grid)
   ============================================ */
.action-buttons {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin: 0;
    background: #ffffff;
    color: #6b7280;
    border: 1px solid rgba(31, 41, 55, 0.10);
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

    .icon-btn:hover {
        background: #f8fafc;
        border-color: rgba(31, 41, 55, 0.24);
        color: #1f2937;
        box-shadow: 0 1px 2px rgba(31, 41, 55, 0.08);
    }

.icon-btn-role:hover {
    background: #E7F0F8;
    color: #17496D;
    border-color: #B8D5EA;
}

.icon-btn-edit:hover {
    background: #F3F4F6;
    color: #374151;
    border-color: #D1D5DB;
}

.icon-btn-danger:hover {
    background: #FCEBEB;
    color: #A32D2D;
    border-color: #F0BBBB;
}

/* ============================================
   Estados (cargando, vacío)
   ============================================ */
.estado-centrado {
    text-align: center;
    padding: 3rem 1rem;
}

    .estado-centrado h3 {
        font-size: 16px;
        font-weight: 500;
        margin: 1rem 0 4px;
        color: #1f2937;
    }

    .estado-centrado p {
        color: #6b7280;
        font-size: 13px;
        margin: 0 0 1rem;
    }

.spinner {
    width: 32px;
    height: 32px;
    margin: 0 auto 1rem;
    border: 3px solid #f0f0ed;
    border-top-color: #BA7517;
    border-radius: 50%;
    animation: marn-spin 1s linear infinite;
}

@keyframes marn-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 700px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .page-header-flex {
        flex-direction: column;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-wrapper {
        max-width: none;
    }
}

/* ============================================
   Dropdown del rol (template + descripción)
   ============================================ */

/* Items dentro de la lista desplegable */
.rol-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 4px 0;
    width: 100%;
}

.rol-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rol-nombre {
    font-weight: 500;
    font-size: 13px;
    color: #1f2937;
}

.rol-codigo {
    font-family: ui-monospace, "Cascadia Mono", "Source Code Pro", monospace;
    font-size: 10px;
    padding: 2px 6px;
    background: #F0EBE0;
    color: #6B5728;
    border-radius: 4px;
    letter-spacing: 0.3px;
    line-height: 1.2;
    display: inline-flex;
    align-items: center;
    height: 18px; /* altura fija para que no dependa del padding vertical */
}

.rol-descripcion {
    font-size: 11px;
    color: #6b7280;
    line-height: 1.4;
    white-space: normal;
    /* Limitar a 2 líneas para no romper el dropdown */
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* El dropdown cerrado solo muestra el `name` (TextProperty) — eso es manejado por Radzen */
.rol-dropdown {
    width: 100%;
    min-height: 48px; /* asegura altura suficiente para descensores */
}
    /* El input interno de Radzen */
    .rol-dropdown .rz-dropdown-label,
    .rol-dropdown .rz-inputtext {
        line-height: 1.5 !important;
        padding-top: 4px;
        padding-bottom: 4px;
    }

/* Descripción del rol seleccionado, debajo del campo */
.rol-info-seleccionado {
    background: #F5F5F3; /* gris cálido en vez de #F8F6F1 */
    border-left: 2px solid #9ca3af; /* gris en vez de naranja */
    padding: 6px 10px;
    margin-top: 6px;
    font-size: 11px;
    color: #6b7280;
    line-height: 1.4;
    display: flex;
    align-items: flex-start;
    gap: 6px;
    border-radius: 4px;
}

    .rol-info-seleccionado svg {
        flex-shrink: 0;
        margin-top: 2px;
        color: #6b7280; /* en vez de #9ca3af */
    }

/* ============================================
   Asignar rol
   ============================================ */
.asignar-rol-card {
    max-width: 1020px;
}

.badge-estado.fuente {
    background: #E7F0F8;
    color: #17496D;
    border-radius: 6px;
}

.usuario-resumen {
    display: grid;
    grid-template-columns: 160px 1fr 1.4fr;
    gap: 12px;
    padding: 12px;
    margin-bottom: 1rem;
    background: #F8FAFC;
    border: 1px solid rgba(31, 41, 55, 0.08);
    border-radius: 8px;
}

.usuario-resumen strong {
    display: block;
    min-width: 0;
    font-size: 13px;
    color: #1f2937;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.resumen-label {
    display: block;
    margin-bottom: 3px;
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
}

.roles-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.roles-seleccionados {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 0.75rem;
}

.roles-list {
    display: grid;
    gap: 8px;
    max-height: min(52vh, 385px);
    overflow-y: auto;
    padding-right: 4px;
}

.role-option {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    gap: 10px;
    align-items: flex-start;
    padding: 10px 12px;
    background: #ffffff;
    border: 1px solid rgba(31, 41, 55, 0.12);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.role-option:hover {
    background: #F8FAFC;
    border-color: rgba(31, 41, 55, 0.22);
}

.role-option.selected {
    background: #EFF8F4;
    border-color: #0F6E56;
    box-shadow: inset 3px 0 0 #0F6E56;
}

.role-option input {
    width: 16px;
    height: 16px;
    margin-top: 2px;
    accent-color: #0F6E56;
}

.role-option-main {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.role-option-header {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.role-option .rol-nombre {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.role-option .rol-codigo {
    flex-shrink: 0;
}

.role-option .rol-descripcion {
    max-width: 100%;
}

.estado-vacio-compacto {
    padding: 1rem;
    font-size: 13px;
    color: #6b7280;
    text-align: center;
    background: #F8FAFC;
    border: 1px dashed rgba(31, 41, 55, 0.18);
    border-radius: 8px;
}

.asignar-rol-card .acciones .btn-secundario,
.asignar-rol-card .acciones .btn-primario {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
}

@media (max-width: 760px) {
    .usuario-resumen {
        grid-template-columns: 1fr;
    }

    .roles-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .roles-list {
        max-height: none;
    }

    .asignar-rol-card .acciones {
        flex-direction: column-reverse;
        align-items: stretch;
    }
}

/* ============================================
   MARN / Estaciones
   ============================================ */
.estaciones-lista-card {
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
}

.marn-estacion-form-card {
    max-width: 1120px;
}

.marn-form-section {
    padding-bottom: 1.25rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid rgba(31, 41, 55, 0.08);
}

.marn-form-section:last-of-type {
    margin-bottom: 0;
}

.marn-form-section-header {
    margin-bottom: 0.9rem;
}

.marn-form-section-header h3 {
    margin: 0 0 3px;
    font-size: 15px;
    font-weight: 600;
    color: #1f2937;
}

.marn-form-section-header p {
    margin: 0;
    font-size: 12px;
    color: #6b7280;
}

.form-row-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.marn-threshold-heading,
.marn-threshold-row {
    display: grid;
    grid-template-columns: minmax(76px, 0.8fr) minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
    align-items: center;
}

.marn-threshold-heading {
    margin-bottom: 6px;
    font-size: 11px;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
}

.marn-threshold-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 14px;
}

.marn-threshold-row span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    font-weight: 700;
    color: #374151;
}

.estacion-coordenadas {
    font-family: ui-monospace, "Cascadia Mono", "Source Code Pro", monospace;
    font-size: 12px;
    color: #4b5563;
}

.badge-registro {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 94px;
    padding: 4px 9px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
}

.registro-dot {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: currentColor;
    box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 16%, transparent);
}

.badge-registro-manual {
    background: #fff7ed;
    border-color: #fed7aa;
    color: #9a3412;
}

.badge-registro-automatico {
    background: #ecfdf5;
    border-color: #bbf7d0;
    color: #047857;
}

.badge-estado.estacion-online {
    background: #E1F5EE;
    color: #0F6E56;
}

.badge-estado.estacion-offline {
    background: #FCEBEB;
    color: #A32D2D;
}

.badge-estado.estacion-unknown {
    background: #EEF2F6;
    color: #4b5563;
}

@media (max-width: 900px) {
    .form-row-3,
    .marn-threshold-grid {
        grid-template-columns: 1fr;
    }
}
