/* ==========================================================================
   POLISH LAYER — REFINAMIENTO VISUAL
   Jerarquía, uniformidad y acabados de todo el sistema de diseño.
   Se carga DESPUÉS de responsive.css como capa final de refinamiento.
   ========================================================================== */

/* ==========================================================================
   1. HIERARQUÍA DE PÁGINA — CABECERAS DE MÓDULO UNIFORMES
   ========================================================================== */
.tab-pane > .d-flex.justify-content-between.align-items-center {
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 1.25rem !important;
}

.tab-pane > .d-flex.justify-content-between.align-items-center h3 {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.15rem;
}

/* Barra de acento vertical que marca la jerarquía del módulo activo */
.tab-pane > .d-flex.justify-content-between.align-items-center h3::before {
    content: '';
    flex-shrink: 0;
    width: 4px;
    height: 1.15em;
    border-radius: 999px;
    background: linear-gradient(180deg, var(--primary) 0%, var(--azul) 100%);
    box-shadow: 0 0 12px var(--primary-glow);
}

.module-header {
    border-bottom: 1px solid var(--glass-border);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

/* ==========================================================================
   2. BADGES — PÍLDORAS TRANSLÚCIDAS UNIFORMES
   ========================================================================== */
.badge {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    line-height: 1.5;
    padding: 0.42em 0.78em;
    border-radius: 999px;
    border: 1px solid transparent;
    white-space: nowrap;
    vertical-align: middle;
}

.badge.bg-success {
    background: rgba(22, 163, 74, 0.14) !important;
    color: #86efac !important;
    border-color: rgba(22, 163, 74, 0.32) !important;
}
.badge.bg-danger {
    background: rgba(220, 38, 38, 0.14) !important;
    color: #fca5a5 !important;
    border-color: rgba(220, 38, 38, 0.32) !important;
}
.badge.bg-warning {
    background: rgba(217, 119, 6, 0.14) !important;
    color: #fcd34d !important;
    border-color: rgba(217, 119, 6, 0.32) !important;
}
.badge.bg-info {
    background: rgba(2, 132, 199, 0.14) !important;
    color: #7dd3fc !important;
    border-color: rgba(2, 132, 199, 0.32) !important;
}
.badge.bg-primary {
    background: rgba(45, 138, 110, 0.16) !important;
    color: #6ee7b7 !important;
    border-color: rgba(45, 138, 110, 0.34) !important;
}
.badge.bg-light {
    background: rgba(255, 255, 255, 0.12) !important;
    color: var(--text) !important;
    border-color: rgba(255, 255, 255, 0.22) !important;
}
.badge.bg-dark {
    background: rgba(10, 15, 20, 0.55) !important;
    color: var(--text-muted) !important;
    border-color: rgba(255, 255, 255, 0.16) !important;
}

[data-theme="light"] .badge.bg-success {
    background: rgba(22, 163, 74, 0.12) !important;
    color: #15803d !important;
    border-color: rgba(22, 163, 74, 0.30) !important;
}
[data-theme="light"] .badge.bg-danger {
    background: rgba(220, 38, 38, 0.10) !important;
    color: #b91c1c !important;
    border-color: rgba(220, 38, 38, 0.28) !important;
}
[data-theme="light"] .badge.bg-warning {
    background: rgba(217, 119, 6, 0.12) !important;
    color: #b45309 !important;
    border-color: rgba(217, 119, 6, 0.30) !important;
}
[data-theme="light"] .badge.bg-info {
    background: rgba(2, 132, 199, 0.10) !important;
    color: #0369a1 !important;
    border-color: rgba(2, 132, 199, 0.28) !important;
}
[data-theme="light"] .badge.bg-primary {
    background: rgba(45, 138, 110, 0.14) !important;
    color: #0f766e !important;
    border-color: rgba(45, 138, 110, 0.32) !important;
}
[data-theme="light"] .badge.bg-light {
    background: rgba(255, 255, 255, 0.85) !important;
    color: var(--text) !important;
    border-color: rgba(15, 23, 42, 0.12) !important;
}
[data-theme="light"] .badge.bg-dark {
    background: rgba(71, 85, 105, 0.18) !important;
    color: var(--text) !important;
    border-color: rgba(15, 23, 42, 0.16) !important;
}

/* ==========================================================================
   3. TABLAS — JERARQUÍA DE COLUMNAS Y FILAS
   ========================================================================== */
.table thead th {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.02));
    border-bottom: 1px solid var(--glass-border) !important;
    white-space: nowrap;
    padding: 0.68rem 0.75rem;
}

.table td {
    vertical-align: middle;
    padding: 0.68rem 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.table tbody tr {
    transition: background-color 0.15s ease;
}

/* Acento de lectura en la primera columna de la fila al pasar el ratón */
.table tbody tr:hover > td:first-child {
    box-shadow: inset 3px 0 0 var(--primary);
}

[data-theme="light"] .table thead th {
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.04), rgba(15, 23, 42, 0.015));
}
[data-theme="light"] .table td {
    border-bottom-color: rgba(15, 23, 42, 0.06);
}
/* ==========================================================================
   4. BOTONES — ESTADOS CONSISTENTES Y RETROALIMENTACIÓN TÁCTIL
   ========================================================================== */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.btn:active {
    transform: translateY(0) scale(0.98) !important;
}

.btn-primary:active,
.btn-primary:focus {
    box-shadow: 0 0 0 3px var(--primary-glow), 0 3px 10px rgba(45, 138, 110, 0.15) !important;
}

.btn-outline-primary,
.btn-outline-success,
.btn-outline-danger,
.btn-outline-warning,
.btn-outline-info,
.btn-outline-secondary {
    border-width: 1px;
    transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-outline-primary:hover {
    background: var(--primary-glow);
    border-color: var(--primary);
    color: #ffffff;
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.btn-outline-success:hover {
    background: var(--success-glow);
    border-color: var(--success);
    color: #ffffff;
    box-shadow: 0 0 0 3px var(--success-glow);
}
.btn-outline-danger:hover {
    background: rgba(220, 38, 38, 0.12);
    border-color: var(--danger);
    color: #ffffff;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}
.btn-outline-warning:hover {
    background: rgba(217, 119, 6, 0.12);
    border-color: var(--warning);
    color: #ffffff;
    box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.12);
}
.btn-outline-info:hover {
    background: rgba(2, 132, 199, 0.14);
    border-color: var(--info);
    color: #ffffff;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.14);
}
.btn-outline-secondary:hover {
    background: rgba(255, 255, 255, 0.10);
    border-color: rgba(255, 255, 255, 0.28);
    color: #ffffff;
}

[data-theme="light"] .btn-outline-primary:hover,
[data-theme="light"] .btn-outline-success:hover,
[data-theme="light"] .btn-outline-danger:hover,
[data-theme="light"] .btn-outline-warning:hover,
[data-theme="light"] .btn-outline-info:hover,
[data-theme="light"] .btn-outline-secondary:hover {
    color: var(--text);
}

.card-header .btn-group > .btn,
.btn-group > .btn:not(:first-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* ==========================================================================
   5. FORMULARIOS — ALTURAS UNIFORMES Y FOCOS REFINADOS
   ========================================================================== */
.form-control,
.form-select {
    min-height: 40px;
    border-radius: 10px;
}

.form-control-sm,
.form-select-sm {
    min-height: 34px;
    border-radius: 8px;
}

.form-control.is-invalid,
.form-select.is-invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.14);
}
.form-control.is-valid,
.form-select.is-valid {
    border-color: var(--success);
    box-shadow: 0 0 0 3px var(--success-glow);
}

/* Autorelleno (autofill) coherente con el tema oscuro */
.form-control:-webkit-autofill,
.form-control:-webkit-autofill:hover,
.form-control:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text);
    -webkit-box-shadow: 0 0 0 1000px #182026 inset;
    transition: background-color 9999s ease-in-out 0s;
}
[data-theme="light"] .form-control:-webkit-autofill,
[data-theme="light"] .form-control:-webkit-autofill:hover,
[data-theme="light"] .form-control:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px #ffffff inset;
}

.form-check-input {
    width: 1.15em;
    height: 1.15em;
    margin-top: 0.22em;
}
.form-check-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.25rem var(--primary-glow);
}

/* Acento de foco en grupos de búsqueda */
.input-group:focus-within {
    box-shadow: 0 0 0 3px var(--primary-glow);
    border-radius: 10px;
}

/* ==========================================================================
   6. TOASTS — REFINADOS CON ACENTO LATERAL DE ESTADO
   ========================================================================== */
.toast {
    border-radius: var(--radius-lg);
    border-left: 3px solid var(--glass-border);
    background: linear-gradient(135deg, rgba(20, 25, 30, 0.78), rgba(20, 25, 30, 0.62));
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35), var(--shadow-glass);
    padding: 12px 16px;
}

.toast i {
    font-size: 1.15rem;
    flex-shrink: 0;
}

.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error { border-left-color: var(--danger); }
.toast.toast-warning { border-left-color: var(--warning); }
.toast.toast-info { border-left-color: var(--info); }

[data-theme="light"] .toast {
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
}

@keyframes slideIn {
    from { transform: translateX(110%) scale(0.97); opacity: 0; }
    to { transform: translateX(0) scale(1); opacity: 1; }
}
@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(110%) scale(0.97); opacity: 0; }
}
/* ==========================================================================
   7. SIDEBAR — ALINEACIÓN, AIRES Y ALCANCES
   ========================================================================== */
.sidebar .nav-link i {
    width: 1.55rem;
    text-align: center;
    font-size: 1.1rem;
}

.sidebar-brand {
    letter-spacing: 0.02em;
}

.sidebar .nav-header {
    padding-left: 0.35rem;
}

/* ==========================================================================
   8. DROPDOWNS — ELEMENTOS CÓMODOS Y JERARQUIZADOS
   ========================================================================== */
.dropdown-menu {
    padding: 0.4rem;
    min-width: 12rem;
}

.dropdown-item {
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.dropdown-header {
    text-transform: uppercase;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.dropdown-divider {
    border-color: var(--glass-border);
}

/* ==========================================================================
   9. ALERTAS — INTEGRADAS CON EL TEMA TRANSLÚCIDO
   ========================================================================== */
.alert {
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
}

.alert-warning {
    background: rgba(217, 119, 6, 0.12);
    border-color: rgba(217, 119, 6, 0.28);
    color: #fcd34d;
}
.alert-danger {
    background: rgba(220, 38, 38, 0.12);
    border-color: rgba(220, 38, 38, 0.28);
    color: #fca5a5;
}
.alert-success {
    background: rgba(22, 163, 74, 0.12);
    border-color: rgba(22, 163, 74, 0.28);
    color: #86efac;
}
.alert-info {
    background: rgba(2, 132, 199, 0.13);
    border-color: rgba(2, 132, 199, 0.28);
    color: #7dd3fc;
}
.alert-primary {
    background: rgba(45, 138, 110, 0.14);
    border-color: rgba(45, 138, 110, 0.32);
    color: #6ee7b7;
}

[data-theme="light"] .alert-warning { color: #b45309; }
[data-theme="light"] .alert-danger { color: #b91c1c; }
[data-theme="light"] .alert-success { color: #15803d; }
[data-theme="light"] .alert-info { color: #0369a1; }
[data-theme="light"] .alert-primary { color: #0f766e; }

/* ==========================================================================
   10. BARRAS DE PROGRESO — PISTA DE CRISTAL Y RELLENO GRADIENTE
   ========================================================================== */
.progress {
    background: var(--track-bg);
    border-radius: 999px;
    height: 0.65rem;
    overflow: hidden;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.progress-bar {
    background: linear-gradient(90deg, var(--primary) 0%, var(--azul) 100%);
    border-radius: 999px;
    box-shadow: 0 0 8px var(--primary-glow);
}
/* ==========================================================================
   11. SUPERFICIES — JERARQUÍA DE CONTENEDORES Y CURSOR CORRECTO
   ========================================================================== */
/* Los contenedores genéricos no son interactivos: cursor por defecto */
.glass-card {
    cursor: default;
}

/* Solo las tarjetas de acción e interactivas muestran la mano */
.kanban-card,
.account-card,
.service-card,
.info-card,
.kpi-card,
.deployment-card,
.hosting-option-card,
#services-grid .glass-card,
.glass-card[onclick] {
    cursor: pointer;
}

/* Fondo ligeramente más legible para paneles grandes en modo oscuro */
.glass-card {
    background: rgba(14, 20, 26, 0.30) !important;
}
[data-theme="light"] .glass-card {
    background: rgba(255, 255, 255, 0.72) !important;
}

.card-body {
    padding: 1.25rem;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--glass-border);
}

/* ==========================================================================
   12. TABS & PILLS — TRANSICIONES SUAVES Y HOVERS CLAROS
   (Limitado al contenido principal para no interferir con el sidebar)
   ========================================================================== */
.main-content .nav-tabs .nav-link,
.main-content .nav-pills .nav-link {
    transition: color 0.2s ease, background-color 0.2s ease,
                border-color 0.2s ease, box-shadow 0.2s ease;
}

.main-content .nav-tabs .nav-link:hover:not(.active),
.main-content .nav-pills .nav-link:hover:not(.active) {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
}
[data-theme="light"] .main-content .nav-tabs .nav-link:hover:not(.active),
[data-theme="light"] .main-content .nav-pills .nav-link:hover:not(.active) {
    color: var(--text);
    background: rgba(15, 23, 42, 0.05);
}

/* ==========================================================================
   13. MICRO-INTERACCIONES — ENTRADA DE PANELES Y RESPETO A REDUCED-MOTION
   ========================================================================== */
.tab-pane.fade {
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.tab-pane.fade:not(.show) {
    transform: translateY(8px);
}
.tab-pane.fade.show {
    transform: translateY(0);
}

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}

.btn:focus-visible,
.nav-link:focus-visible,
.dropdown-item:focus-visible {
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ==========================================================================
   14. SCROLLBARS — MÁS FINAS Y CON ACENTO DE TEMA
   ========================================================================== */
::-webkit-scrollbar {
    width: 9px;
    height: 9px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.16);
    border: 2px solid transparent;
    background-clip: content-box;
    border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
    background-color: var(--primary);
    background-clip: content-box;
}
[data-theme="light"] ::-webkit-scrollbar-thumb {
    background-color: rgba(15, 23, 42, 0.22);
    background-clip: content-box;
}

/* ==========================================================================
   15. MÓVIL — RENDIMIENTO Y AJUSTES FINOS
   ========================================================================== */
@media (max-width: 991.98px) {
    /* Evita el parpadeo/consumo del fondo fijo en móvil */
    body,
    #login-screen {
        background-attachment: scroll;
    }
}