/* NT Identity Connect — Portal
   Paleta NT oficial: Indigo #4f46e5, Violeta #7c3aed, Cyan #06b6d4
   Tipografia: Inter (equivalente web de Gotham)
   Iconos: Lucide Icons
   ──────────────────────────────────────────────────────── */

/* -- Variables de marca ---------------------------------------------------- */
:root {
    --brand: #4f46e5;
    --brand-dark: #4338ca;
    --brand-light: #eef2ff;
    --brand-muted: #818cf8;
    --accent: #06b6d4;
    --accent-light: #ecfeff;
    --violet: #7c3aed;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-dark: #0f172a;
    --surface: #f8fafc;
    --surface-secondary: #f1f5f9;
    --border: #e2e8f0;
}

/* -- Tipografia ------------------------------------------------------------ */
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* -- Utilidades de color de marca ------------------------------------------ */
.bg-brand { background-color: var(--brand); }
.bg-brand-dark { background-color: var(--brand-dark); }
.bg-brand-light { background-color: var(--brand-light); }
.bg-surface { background-color: var(--surface); }
.text-brand { color: var(--brand); }
.text-brand-dark { color: var(--brand-dark); }
.text-brand-muted { color: var(--brand-muted); }

/* -- Lucide Icons ---------------------------------------------------------- */
[data-lucide] {
    width: 18px;
    height: 18px;
    stroke-width: 1.75;
}

/* -- Sidebar --------------------------------------------------------------- */
.sidebar-link {
    transition: all 0.15s ease;
}
.sidebar-link:hover {
    background: rgba(79, 70, 229, 0.04);
}
.sidebar-link.active {
    background: rgba(79, 70, 229, 0.06);
    color: var(--brand);
}
.sidebar-link.active [data-lucide] {
    color: var(--brand);
}

/* -- Cards ----------------------------------------------------------------- */
.card {
    background: #fff;
    border: 1px solid #f0f0f0;
    border-radius: 10px;
    transition: border-color 0.2s;
}
.card:hover {
    border-color: #e0e0e0;
}

/* -- Metricas -------------------------------------------------------------- */
.metric-value {
    font-variant-numeric: tabular-nums;
}

/* -- Badges ---------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
}
.badge-active {
    background: #d1fae5;
    color: #065f46;
}
.badge-pending {
    background: #f3f4f6;
    color: #6b7280;
}
.badge-phase {
    background: #eef2ff;
    color: #4f46e5;
}
.badge-phase2 {
    background: #f5f3ff;
    color: #7c3aed;
}
.badge-alert {
    background: #fef3c7;
    color: #92400e;
}
.badge-error {
    background: #fee2e2;
    color: #991b1b;
}

/* -- Tablas ---------------------------------------------------------------- */
.table-row {
    transition: background 0.15s;
}
.table-row:hover {
    background: #fafbfc;
}

/* -- Upload zone ----------------------------------------------------------- */
.upload-zone {
    border: 2px dashed #e5e7eb;
    transition: all 0.2s;
    cursor: pointer;
}
.upload-zone:hover {
    border-color: var(--brand);
    background: var(--brand-light);
}

/* -- Tabs ------------------------------------------------------------------ */
.tab {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #9ca3af;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
}
.tab:hover {
    color: #6b7280;
}
.tab.active {
    color: var(--brand-dark);
    border-bottom-color: var(--brand-dark);
}

/* -- Inputs ---------------------------------------------------------------- */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="search"],
textarea {
    font-size: 13px;
    font-family: 'Inter', system-ui, sans-serif;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 9px 12px;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    width: 100%;
    background-color: #fff;
    color: #1f2937;
    line-height: 1.4;
}
input::placeholder,
textarea::placeholder {
    color: #c0c5cc;
}
input:focus,
textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* -- Select profesional ---------------------------------------------------- */
select {
    font-size: 13px;
    font-family: 'Inter', system-ui, sans-serif;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 100%;
    padding: 9px 40px 9px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background-color: #fff;
    color: #1f2937;
    line-height: 1.4;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.15s;
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 20px;
}
select:hover {
    border-color: #d1d5db;
    background-color: #fafbfc;
}
select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    background-color: #fff;
}
select option {
    padding: 10px 12px;
    font-size: 13px;
    color: #1f2937;
    background: #fff;
}
select option:checked {
    background: var(--brand-light);
    color: var(--brand);
}
select:disabled {
    background-color: #f9fafb;
    color: #9ca3af;
    cursor: not-allowed;
    border-color: #f0f0f0;
}
/* Select con placeholder (primer option vacia) */
select:invalid,
select option[value=""] {
    color: #9ca3af;
}

/* -- Custom Select (nt-select) --------------------------------------------- */
.nt-select-wrapper {
    position: relative;
    width: 100%;
}
.nt-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 9px 12px;
    font-size: 13px;
    font-family: 'Inter', system-ui, sans-serif;
    color: #1f2937;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    text-align: left;
    line-height: 1.4;
}
.nt-select-trigger:hover {
    border-color: #d1d5db;
    background: #fafbfc;
}
.nt-select-trigger.nt-select-open {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}
.nt-select-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.nt-select-placeholder {
    color: #9ca3af;
}
.nt-select-arrow {
    flex-shrink: 0;
    color: #9ca3af;
    transition: transform 0.2s;
    margin-left: 8px;
}
.nt-select-open .nt-select-arrow {
    transform: rotate(180deg);
}

/* Dropdown */
.nt-select-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04);
    z-index: 50;
    overflow: hidden;
    animation: ntSelectIn 0.15s ease;
}
@keyframes ntSelectIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Busqueda */
.nt-select-search-wrap {
    padding: 8px 8px 4px;
    border-bottom: 1px solid #f3f4f6;
}
.nt-select-search {
    width: 100% !important;
    padding: 7px 10px !important;
    font-size: 12px !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 6px !important;
    outline: none !important;
    background: #f9fafb !important;
}
.nt-select-search:focus {
    border-color: var(--brand) !important;
    background: #fff !important;
    box-shadow: none !important;
}

/* Lista opciones */
.nt-select-list {
    max-height: 220px;
    overflow-y: auto;
    padding: 4px;
}
.nt-select-option {
    padding: 8px 10px;
    font-size: 13px;
    color: #374151;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.1s;
    line-height: 1.4;
}
.nt-select-option:hover {
    background: #f3f4f6;
}
.nt-select-option-active {
    background: var(--brand-light);
    color: var(--brand);
    font-weight: 500;
}
.nt-select-option-active:hover {
    background: #e0e7ff;
}
.nt-select-empty {
    padding: 16px 10px;
    text-align: center;
    font-size: 12px;
    color: #9ca3af;
}

/* Scrollbar del dropdown */
.nt-select-list::-webkit-scrollbar {
    width: 6px;
}
.nt-select-list::-webkit-scrollbar-track {
    background: transparent;
}
.nt-select-list::-webkit-scrollbar-thumb {
    background: #e5e7eb;
    border-radius: 3px;
}
.nt-select-list::-webkit-scrollbar-thumb:hover {
    background: #d1d5db;
}

/* -- Botones --------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.15s;
    cursor: pointer;
    border: none;
}
.btn-primary {
    background: var(--brand);
    color: white;
}
.btn-primary:hover {
    background: var(--brand-dark);
    box-shadow: 0 1px 3px rgba(79, 70, 229, 0.3);
}
.btn-secondary {
    background: var(--brand-light);
    color: var(--brand);
}
.btn-secondary:hover {
    background: #e0e7ff;
}
.btn-ghost {
    background: transparent;
    color: #6b7280;
    border: 1px solid #e5e7eb;
}
.btn-ghost:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

/* -- htmx indicator -------------------------------------------------------- */
.htmx-indicator {
    display: none;
}
.htmx-request .htmx-indicator {
    display: inline-block;
}
.htmx-request.htmx-indicator {
    display: inline-block;
}

/* -- Responsivo ------------------------------------------------------------ */

/* Sidebar mobile: oculta por defecto, se muestra con .sidebar-open en body */
@media (max-width: 1023px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 50;
    }
    .sidebar-open .sidebar {
        transform: translateX(0);
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.3);
        z-index: 45;
    }
    .sidebar-open .sidebar-overlay {
        display: block;
    }
    .main-content {
        margin-left: 0 !important;
    }
    .mobile-header {
        display: flex !important;
    }
}
@media (min-width: 1024px) {
    .sidebar {
        transform: translateX(0);
    }
    .mobile-header {
        display: none !important;
    }
    .sidebar-overlay {
        display: none !important;
    }
}

/* Tablas responsivas */
@media (max-width: 767px) {
    .responsive-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .responsive-table table {
        min-width: 640px;
    }
    /* Grids de KPIs: 2 columnas en mobile */
    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    /* Cards en una columna */
    .md\:grid-cols-2,
    .md\:grid-cols-3,
    .md\:grid-cols-4 {
        grid-template-columns: 1fr !important;
    }
    /* Wizard step indicators: compactos */
    .step-label {
        display: none;
    }
    .step-number {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
}

/* iPad/tablet */
@media (min-width: 768px) and (max-width: 1023px) {
    .md\:grid-cols-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Touch targets: minimo 44px en mobile */
@media (max-width: 1023px) {
    .sidebar-link {
        padding: 10px 12px;
        min-height: 44px;
    }
    .btn {
        min-height: 44px;
        padding: 10px 18px;
    }
    input, select, textarea {
        min-height: 44px;
        font-size: 16px !important; /* previene zoom en iOS */
    }
}

/* -- Driver.js Tour Customization ------------------------------------------ */
.driver-popover.edce-tour-popover {
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    max-width: 360px;
    font-family: 'Inter', sans-serif;
}

.driver-popover.edce-tour-popover .driver-popover-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.driver-popover.edce-tour-popover .driver-popover-description {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.driver-popover.edce-tour-popover .driver-popover-progress-text {
    font-size: 11px;
    color: var(--text-secondary);
}

.driver-popover.edce-tour-popover button.driver-popover-next-btn {
    background: var(--brand);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    padding: 6px 14px;
    font-family: 'Inter', sans-serif;
}

.driver-popover.edce-tour-popover button.driver-popover-prev-btn {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    padding: 6px 14px;
    font-family: 'Inter', sans-serif;
}
