/* ================================================= */
/* =====     ESTILOS PROVEEDORES                 ===== */
/* =====   Variables vienen de app.css           ===== */
/* ================================================= */

/* --- CONTENIDO PRINCIPAL --- */
main.main-content, main.content { flex-grow: 1; padding: 40px 48px; overflow-y: auto; }
.content-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 40px; gap: 20px; flex-wrap: wrap;
}
.content-header h1 { font-weight: 800; color: var(--text-primary); font-size: 2.2rem; margin: 0; }
.action-button {
  background-color: var(--accent); color: white; font-weight: 600;
  padding: 0 24px; height: 44px; line-height: 44px; border-radius: 8px;
  display: inline-flex; align-items: center; box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  transition: all 0.2s ease; text-decoration: none; border: none; cursor: pointer;
}
.action-button:hover { background-color: var(--accent-hover); }
.action-button i.material-icons { margin-right: 8px; }

/* --- TABLA Y BUSCADOR --- */
.table-wrapper {
  background-color: var(--bg-card); border: 1px solid var(--border-default);
  border-radius: var(--radius-lg); padding: 24px;
}
.search-input {
  width: 100%; max-width: 400px; padding: 12px 16px;
  border-radius: 8px; border: 1px solid var(--border-default);
  font-size: 0.9rem; margin-bottom: 24px; background-color: var(--bg-input);
  color: var(--text-primary); transition: all 0.2s;
}
.search-input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-glow); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 12px 16px; text-align: left; vertical-align: middle; }
.data-table thead { border-bottom: 1px solid var(--border-default); background-color: var(--bg-table-head); }
.data-table th { font-weight: 600; font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; }
.data-table tbody tr { border-bottom: 1px solid var(--border-default); }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background-color: var(--accent-muted); }
.status-badge { display: inline-block; border-radius: 99px; padding: 4px 12px; font-size: 0.8rem; font-weight: 600; }
.status-badge.activo { background-color: rgba(16,185,129,0.15); color: var(--green); }
.status-badge.inactivo { background-color: rgba(239,68,68,0.15); color: var(--red); }
.criticidad-text { font-weight: 600; text-transform: capitalize; }
.criticidad-critico { color: var(--red); } .criticidad-alto { color: var(--orange); }
.criticidad-medio { color: var(--yellow); } .criticidad-bajo { color: var(--green); }
.table-actions button { background: none; border: none; cursor: pointer; font-weight: 600; padding: 4px; }
.table-actions .edit-btn { color: var(--accent); } .table-actions .edit-btn:hover { color: var(--accent-hover); }
.table-actions .delete-btn { color: var(--red); } .table-actions .delete-btn:hover { opacity: 0.8; }

/* --- MODAL GENERAL --- */
.modal-overlay {
  position: fixed; inset: 0; background-color: rgba(0,0,0,0.5); z-index: 50;
  display: none; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.3s ease;
}
.modal-overlay.visible { display: flex; opacity: 1; }
#app-modal { z-index: 60; }
.modal-content {
  background-color: var(--bg-card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal); transform: scale(0.95);
  transition: transform 0.3s ease;
}
.modal-overlay.visible .modal-content { transform: scale(1); }
.modal-button {
  padding: 10px 20px; border-radius: 8px; font-weight: 600;
  cursor: pointer; border: none; transition: all 0.2s ease;
}
.modal-button.primary { background-color: var(--accent); color: white; }
.modal-button.primary:hover { background-color: var(--accent-hover); }
.modal-button.secondary { background-color: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border-default); }
.modal-button.secondary:hover { background-color: var(--border-default); }
.modal-button.danger { background-color: var(--red); color: white; }
.modal-button.danger:hover { opacity: 0.9; }

/* --- MODAL DE FORMULARIO DE PROVEEDOR --- */
#proveedor-modal .modal-content { width: 100%; max-width: 800px; margin: 0 16px; }
#proveedor-modal .modal-body { padding: 32px; max-height: 90vh; overflow-y: auto; }
#proveedor-modal #modal-title { font-size: 1.75rem; font-weight: 700; margin-bottom: 24px; color: var(--text-primary); }
.form-section { border-bottom: 1px solid var(--border-default); padding-bottom: 24px; margin-bottom: 24px; }
.form-section:last-of-type { border-bottom: none; }
.form-section-title { font-size: 1.1rem; font-weight: 600; color: var(--text-primary); margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.form-grid .grid-col-span-2 { grid-column: span 2; }
.form-group label {
  display: block; font-size: 0.9rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px;
}
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border-default);
  border-radius: 8px; background-color: var(--bg-input); color: var(--text-primary);
  transition: all 0.2s; box-sizing: border-box;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-textarea { resize: vertical; }

.help-text { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 8px; }
.risk-option-group { display: grid; gap: 8px; }
.risk-option { display: flex; align-items: center; gap: 8px; font-size: 0.88rem; color: var(--text-secondary); }

.program-evaluation {
  margin-top: 12px; border: 1px solid var(--border-default);
  border-radius: 12px; background-color: var(--bg-card);
  display: grid; gap: 16px; padding: 20px 22px;
}
.program-evaluation header { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.program-evaluation h5 { margin: 0; font-size: 1rem; font-weight: 600; color: var(--text-primary); }
.program-evaluation p { margin: 4px 0 0; font-size: 0.85rem; color: var(--text-muted); }

.link-button {
  border: none; background: none; color: var(--accent); font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
}
.link-button .material-icons { font-size: 1rem; }
.program-evaluation-body { display: grid; gap: 18px; }

.suggested-level { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.suggested-level .label { font-size: 0.85rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }

.criticidad-pill {
  padding: 6px 16px; border-radius: 999px; border: 1px solid var(--border-strong);
  text-transform: uppercase; font-weight: 700; font-size: 0.9rem; letter-spacing: 0.06em;
  color: var(--text-primary); background: var(--bg-card);
}
.criticidad-pill.criticidad-bajo { border-color: rgba(22,163,74,0.4); color: var(--green); }
.criticidad-pill.criticidad-medio { border-color: rgba(245,158,11,0.4); color: var(--yellow); }
.criticidad-pill.criticidad-alto { border-color: rgba(249,115,22,0.4); color: var(--orange); }
.criticidad-pill.criticidad-critico { border-color: rgba(220,38,38,0.5); color: var(--red); }

.factor-list-container h6 { margin: 0 0 8px; font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); }
.factor-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.factor-item { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--text-muted); }
.factor-item.active { color: var(--text-secondary); font-weight: 500; }
.factor-item.warning { color: var(--red); font-weight: 600; }
.factor-dot { width: 10px; height: 10px; border-radius: 999px; background-color: currentColor; }

.program-evaluation footer { display: flex; justify-content: flex-end; }

.ghost-button {
  border: 1px solid var(--border-default); background: var(--bg-card); padding: 8px 16px;
  border-radius: 8px; font-weight: 600; color: var(--text-secondary);
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
}
.ghost-button:hover { border-color: var(--accent); color: var(--accent); }

.program-evaluation--disabled { opacity: 0.6; }

.final-criticidad-box {
  margin-top: 16px; padding: 18px; border: 1px dashed var(--border-default);
  border-radius: 12px; background: var(--bg-body); display: grid; gap: 10px;
}
.final-note { font-size: 0.82rem; color: var(--text-muted); margin: 0; }

.modal-form-actions { margin-top: 32px; display: flex; justify-content: flex-end; gap: 12px; }

/* --- MEDIA QUERY RESPONSIVA --- */
@media (max-width: 768px) {
  main.content { padding: 24px; }
  .content-header h1 { font-size: 1.8rem; }
  .form-grid { grid-template-columns: 1fr; gap: 16px; }
  .form-grid .grid-col-span-2 { grid-column: span 1; }
  #proveedor-modal .modal-body { padding: 24px; }
}

/* ============================================
   VENDOR DETAIL DRAWER
   ============================================ */

/* Overlay */
.drawer-overlay {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(0, 0, 0, 0.4);
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.drawer-overlay.visible {
    display: block;
    opacity: 1;
}

/* Panel */
.drawer-panel {
    position: fixed;
    top: 0;
    right: -480px;
    width: 460px;
    height: 100vh;
    background: var(--bg-card);
    border-left: 1px solid var(--border-default);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    z-index: 61;
    overflow: hidden;
}
.drawer-overlay.visible .drawer-panel {
    right: 0;
}

/* Header */
.drawer-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-default);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex-shrink: 0;
}
.drawer-header-info {
    flex: 1;
    min-width: 0;
}
.drawer-header-name {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.drawer-header-website {
    font-size: 0.82rem;
    color: var(--accent);
    text-decoration: none;
    display: block;
    margin-top: 2px;
}
.drawer-header-website:hover {
    text-decoration: underline;
}
.drawer-header-badges {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
}
.drawer-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.15s ease;
    flex-shrink: 0;
}
.drawer-close-btn:hover {
    background: var(--accent-muted);
    color: var(--text-primary);
}

/* Tabs */
.drawer-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-default);
    padding: 0 24px;
    flex-shrink: 0;
    overflow-x: auto;
}
.drawer-tab {
    padding: 12px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}
.drawer-tab:hover {
    color: var(--text-primary);
}
.drawer-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Body */
.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}
.drawer-tab-content {
    display: none;
    padding: 24px;
}
.drawer-tab-content.active {
    display: block;
}

/* Section headers inside drawer */
.drawer-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin: 20px 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-default);
}
.drawer-section-title:first-child {
    margin-top: 0;
}

/* ============================================
   INLINE-EDITABLE FIELDS
   ============================================ */
.drawer-field {
    margin-bottom: 14px;
}
.drawer-field-label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 4px;
    display: block;
}
.drawer-field-value {
    font-size: 0.9rem;
    color: var(--text-primary);
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease;
    min-height: 32px;
    display: flex;
    align-items: center;
    border: 1px solid transparent;
}
.drawer-field-value:hover {
    background: var(--accent-muted);
    border-color: var(--border-default);
}
.drawer-field-value.empty {
    color: var(--text-muted);
    font-style: italic;
}
.drawer-field-value .material-icons {
    font-size: 16px;
    margin-right: 6px;
    color: var(--text-muted);
}

/* Editing state */
.drawer-field-input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--accent);
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb, 56, 136, 249), 0.15);
}
.drawer-field-input:focus {
    border-color: var(--accent);
}
select.drawer-field-input {
    cursor: pointer;
}

/* Read-only field */
.drawer-field-readonly {
    font-size: 0.9rem;
    color: var(--text-muted);
    padding: 6px 8px;
    min-height: 32px;
    display: flex;
    align-items: center;
}

/* ============================================
   HUB CHIPS
   ============================================ */
.hub-chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.hub-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    transition: all 0.15s ease;
}
.hub-chip .remove-chip {
    cursor: pointer;
    font-size: 14px;
    opacity: 0.6;
    transition: opacity 0.15s ease;
    line-height: 1;
}
.hub-chip .remove-chip:hover {
    opacity: 1;
}
.hub-chip-add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 99px;
    border: 1px dashed var(--border-default);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 16px;
    background: none;
}
.hub-chip-add:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-muted);
}

/* Hub dropdown */
.hub-dropdown {
    position: fixed;
    min-width: 200px;
    max-height: 200px;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 10000;
    display: none;
}
.hub-dropdown.visible {
    display: block;
}
.hub-dropdown-item {
    padding: 8px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.15s ease;
    color: var(--text-primary);
}
.hub-dropdown-item:hover {
    background: var(--accent-muted);
}
.hub-dropdown-item .hub-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Hub badges in table */
.table-hub-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}
.table-hub-badge {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 1px 8px;
    border-radius: 99px;
    white-space: nowrap;
}

/* ============================================
   TAG / ETIQUETA PILLS
   ============================================ */
.tag-input-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    padding: 6px 8px;
    border: 1px solid var(--border-default);
    border-radius: 8px;
    min-height: 38px;
    cursor: text;
    transition: border-color 0.15s ease;
    position: relative;
}
.tag-input-container:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb, 56, 136, 249), 0.15);
}
.tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}
.tag-pill .remove-tag {
    cursor: pointer;
    font-size: 13px;
    opacity: 0.6;
    transition: opacity 0.15s ease;
    line-height: 1;
}
.tag-pill .remove-tag:hover {
    opacity: 1;
}
.tag-text-input {
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.82rem;
    color: var(--text-primary);
    min-width: 80px;
    flex: 1;
    padding: 2px 0;
    font-family: inherit;
}
.tag-text-input::placeholder {
    color: var(--text-muted);
}

/* Tag autocomplete dropdown */
.tag-autocomplete {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 160px;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 70;
    display: none;
}
.tag-autocomplete.visible {
    display: block;
}
.tag-autocomplete-item {
    padding: 8px 12px;
    font-size: 0.82rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.15s ease;
    color: var(--text-primary);
}
.tag-autocomplete-item:hover,
.tag-autocomplete-item.highlighted {
    background: var(--accent-muted);
}
.tag-autocomplete-item .tag-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.tag-autocomplete-create {
    border-top: 1px solid var(--border-default);
    color: var(--accent);
    font-weight: 500;
}

/* Tag badges in table */
.table-tag-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: 2px;
}
.table-tag-badge {
    font-size: 0.65rem;
    font-weight: 500;
    padding: 1px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

/* ============================================
   LIFECYCLE STATUS BADGES
   ============================================ */
.lifecycle-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}
.lifecycle-badge.onboarding {
    background: rgba(37, 99, 235, 0.1);
    color: #2563eb;
}
.lifecycle-badge.active {
    background: rgba(34, 197, 94, 0.1);
    color: #16a34a;
}
.lifecycle-badge.under_review {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}
.lifecycle-badge.offboarding {
    background: rgba(249, 115, 22, 0.1);
    color: #ea580c;
}
.lifecycle-badge.terminated {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

/* ============================================
   EVALUACIONES LIST IN DRAWER
   ============================================ */
.drawer-eval-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.drawer-eval-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    gap: 12px;
}
.drawer-eval-item:last-child {
    border-bottom: none;
}
.drawer-eval-info {
    flex: 1;
    min-width: 0;
}
.drawer-eval-name {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.drawer-eval-date {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
}
.drawer-eval-score {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--accent);
}
.drawer-eval-link {
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: color 0.15s ease;
}
.drawer-eval-link:hover {
    color: var(--accent);
}

/* Empty state */
.drawer-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted);
}
.drawer-empty .material-icons {
    font-size: 40px;
    opacity: 0.3;
    display: block;
    margin-bottom: 8px;
}

/* ============================================
   CONTACT CARDS IN DRAWER
   ============================================ */
.drawer-contact-card {
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 12px;
}
.drawer-contact-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.drawer-contact-role {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.drawer-contact-detail {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.drawer-contact-detail .material-icons {
    font-size: 16px;
    color: var(--text-muted);
}
.drawer-contact-detail a {
    color: var(--accent);
    text-decoration: none;
}
.drawer-contact-detail a:hover {
    text-decoration: underline;
}

/* ============================================
   AUDIT TIMELINE IN DRAWER
   ============================================ */
.drawer-timeline {
    list-style: none;
    padding: 0;
    margin: 0;
}
.drawer-timeline-item {
    padding: 10px 0 10px 20px;
    border-left: 2px solid var(--border-default);
    position: relative;
    margin-left: 4px;
}
.drawer-timeline-item::before {
    content: '';
    position: absolute;
    left: -5px;
    top: 14px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
}
.drawer-timeline-action {
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 500;
}
.drawer-timeline-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ============================================
   TABLE ENHANCEMENTS
   ============================================ */
.proveedores-table tbody tr {
    cursor: pointer;
}
.proveedores-table tbody tr:hover {
    background: var(--accent-muted);
}
.proveedor-name-cell {
    display: flex;
    flex-direction: column;
}
.proveedor-sub-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: 4px;
}

/* Hub filter in filter bar */
.filter-hub-select {
    padding: 8px 12px;
    border: 1px solid var(--border-default);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.88rem;
    font-family: inherit;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .drawer-panel {
        width: 100vw;
        right: -100vw;
    }
    .drawer-tabs {
        padding: 0 16px;
    }
    .drawer-tab {
        padding: 10px 12px;
        font-size: 0.8rem;
    }
    .drawer-tab-content {
        padding: 16px;
    }
    .drawer-header {
        padding: 16px;
    }
}
