/* ═════════════════════════════════════════════════════════════════ */
/* COMPONENTES - VERSIÓN MEJORADA                                   */
/* ═════════════════════════════════════════════════════════════════ */

/* ANIMACIONES */
@keyframes slideInRight {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(400px);
    opacity: 0;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* TOAST / NOTIFICACIONES */
.toast {
  position: fixed;
  bottom: var(--xl);
  right: var(--xl);
  padding: var(--lg) var(--xl);
  border-radius: var(--rL);
  font-size: 12px;
  max-width: 400px;
  z-index: var(--zToast);
  animation: slideInRight 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4);
  border: 1px solid;
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  gap: var(--md);
}

.toast.success {
  background-color: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.35);
  color: #4ade80;
}

.toast.error {
  background-color: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--nova);
}

.toast.warning {
  background-color: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.4);
  color: var(--solar);
}

.toast.info {
  background-color: rgba(34, 197, 94, 0.10);
  border-color: rgba(34, 197, 94, 0.30);
  color: var(--orbit);
}

.toast.hide {
  animation: slideOutRight 0.3s ease forwards;
}

/* DROPDOWN */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--panel);
  border: 1px solid var(--rim);
  border-radius: var(--rL);
  min-width: 200px;
  z-index: var(--zDropdown);
  display: none;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
  animation: fadeInUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  margin-top: var(--md);
  overflow: hidden;
}

.dropdown-menu.active {
  display: block;
}

.dropdown-item {
  padding: var(--md) var(--lg);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  border-bottom: 1px solid var(--rim);
  color: var(--txt);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: var(--md);
}

.dropdown-item:last-child {
  border-bottom: none;
}

.dropdown-item:hover {
  background-color: rgba(34, 197, 94, 0.08);
  color: var(--orbit);
}

/* PROGRESS BAR */
.progress-bar {
  width: 100%;
  height: 8px;
  background-color: var(--rim);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--orbit);
  transition: width 0.4s ease;
  border-radius: 4px;
}

/* SKELETON LOADER */
.skeleton {
  background: linear-gradient(90deg, var(--rim) 25%, var(--hover) 50%, var(--rim) 75%);
  background-size: 200% 100%;
  animation: loading 2s infinite;
  border-radius: var(--r);
}

@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* TOOLTIP */
.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip .tooltip-text {
  visibility: hidden;
  background-color: var(--charcoal);
  color: var(--txt);
  text-align: center;
  border-radius: var(--r);
  padding: var(--md) var(--lg);
  position: absolute;
  z-index: 1;
  bottom: 125%;
  left: 50%;
  margin-left: -80px;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-size: 11px;
  white-space: nowrap;
  border: 1px solid var(--rim);
}

.tooltip:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
  transform: translateY(-4px);
}

/* CHECKBOXES */
.checkbox {
  position: relative;
  display: inline-block;
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.checkbox input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.checkbox input[type="checkbox"]:checked + .checkmark {
  background: var(--orbit);
  border-color: var(--orbit);
}

.checkmark {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  background-color: var(--hover);
  border: 1px solid var(--rim);
  border-radius: 4px;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.checkbox input[type="checkbox"]:checked + .checkmark:after {
  content: '';
  position: absolute;
  display: block;
  left: 5px;
  top: 2px;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* AVATAR GROUP */
.avatar-group {
  display: flex;
  gap: -8px;
  align-items: center;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--orbit);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  color: white;
  border: 2px solid var(--panel);
  margin-right: -8px;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.avatar:hover {
  opacity: 0.85;
}

.avatar:last-child {
  margin-right: 0;
}

/* CARD */
.card {
  background: var(--panel);
  border: 1px solid var(--rim);
  border-radius: var(--rL);
  padding: var(--lg);
  animation: fadeInUp 0.4s ease-out;
  transition: background-color 0.15s ease;
}

.card:hover {
  background-color: #141414;
}

.card-header {
  margin-bottom: var(--lg);
  padding-bottom: var(--lg);
  border-bottom: 1px solid var(--rim);
}

.card-body {
  margin-bottom: var(--lg);
}

.card-footer {
  padding-top: var(--lg);
  border-top: 1px solid var(--rim);
}

/* STAT CARD */
.stat-card {
  background: var(--panel);
  border: 1px solid var(--rim);
  border-radius: var(--r);
  padding: var(--lg);
  text-align: center;
  cursor: pointer;
  transition: background-color 0.15s ease;
  animation: scaleIn 0.4s ease-out;
}

.stat-card:hover {
  background-color: #141414;
}

.stat-value {
  font-family: var(--fd);
  font-size: 28px;
  font-weight: 800;
  color: var(--txt);
  margin-bottom: var(--sm);
}

.stat-label {
  font-size: 11px;
  color: var(--txtM);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* LIST ITEM */
.list-item {
  padding: var(--md) 0;
  border-bottom: 1px solid var(--rim);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.3s ease;
  animation: fadeInUp 0.5s ease-out;
}

.list-item:hover {
  background-color: #141414;
  padding-left: var(--md);
  padding-right: var(--md);
}

.list-item:last-child {
  border-bottom: none;
}

.list-item-title {
  font-weight: 600;
  color: var(--txt);
  font-size: 12px;
}

.list-item-desc {
  font-size: 11px;
  color: var(--txtM);
  margin-top: 2px;
}

/* EMPTY STATE */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--xxl);
  text-align: center;
  animation: fadeInUp 0.5s ease-out;
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: var(--lg);
  opacity: 0.4;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
}

.empty-state-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--txt);
  margin-bottom: var(--sm);
}

.empty-state-desc {
  font-size: 13px;
  color: var(--txtM);
  margin-bottom: var(--lg);
}

/* LOADING SPINNER */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--rim);
  border-radius: 50%;
  border-top-color: var(--orbit);
  border-right-color: var(--pulse);
  animation: spin 1s cubic-bezier(0.6, 0.2, 0.25, 0.75) infinite;
}

/* BREADCRUMB */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--md);
  font-size: 12px;
  animation: fadeInUp 0.4s ease-out;
}

.breadcrumb-item {
  color: var(--txtM);
  transition: color 0.3s ease;
  cursor: pointer;
}

.breadcrumb-item:hover {
  color: var(--orbit);
}

.breadcrumb-item.active {
  color: var(--txt);
  font-weight: 600;
}

.breadcrumb-separator {
  color: var(--txtD);
}

/* DIVIDER */
.divider {
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--rim), transparent);
  margin: var(--md) 0;
}

/* BADGE DOT */
.badge-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--orbit);
  margin-right: var(--sm);
  animation: pulse-animation 2s ease-in-out infinite;
}

@keyframes pulse-animation {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.2); }
}

.badge-dot.success {
  background-color: var(--pulse);
}

.badge-dot.warning {
  background-color: var(--solar);
}

.badge-dot.danger {
  background-color: var(--nova);
}

/* ════════════ ISO 27001 CONTROLS ════════════ */

.iso-control-panel {
  background-color: var(--panel);
  border: 1px solid var(--rim);
  border-radius: var(--rL);
  padding: var(--lg);
  margin-bottom: var(--md);
  transition: all 0.2s ease;
  cursor: pointer;
}

.iso-control-panel:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  background-color: var(--hover);
}

.iso-control-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--md);
}

.iso-control-code {
  font-family: var(--fd);
  font-weight: 700;
  font-size: 13px;
  color: var(--orbit);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: var(--sm);
}

.iso-control-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--txt);
  line-height: 1.4;
}

.iso-control-desc {
  font-size: 11px;
  color: var(--txtM);
  line-height: 1.5;
  margin-bottom: var(--md);
  padding: var(--sm);
  background-color: var(--hover);
  border-radius: var(--r);
  border-left: 2px solid var(--orbit);
}

.iso-control-actions {
  display: flex;
  gap: var(--sm);
}

.iso-control-status-bar {
  display: flex;
  align-items: center;
  gap: var(--md);
  margin-bottom: var(--md);
}

.progress-container {
  flex: 1;
  height: 8px;
  background-color: var(--rim);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--orbit) 0%, var(--pulse) 100%);
  transition: width 0.3s ease;
  border-radius: 4px;
}

.progress-text {
  font-family: var(--fd);
  font-weight: 700;
  font-size: 11px;
  color: var(--orbit);
  min-width: 35px;
  text-align: right;
}

.iso-control-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: var(--md);
  border-top: 1px solid var(--rim);
  font-size: 11px;
  color: var(--txtM);
}

.iso-status-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  border: 1px solid;
  letter-spacing: 0.3px;
}

.iso-tasks-preview {
  background-color: var(--hover);
  padding: var(--md);
  border-radius: var(--r);
  border-left: 2px solid var(--solar);
}

.iso-task-badge {
  display: inline-block;
  padding: 4px 8px;
  background-color: var(--rim);
  border-radius: 4px;
  font-size: 9px;
  color: var(--txt);
  font-weight: 500;
}

.iso-group-btn {
  display: inline-block;
  padding: var(--md) var(--lg);
  margin-right: var(--md);
  margin-bottom: var(--md);
  background-color: var(--panel);
  border: 1px solid var(--rim);
  border-radius: var(--rL);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.iso-group-btn:hover {
  background-color: var(--hover);
  border-color: var(--orbit);
}

.iso-group-btn::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: var(--completion, 0%);
  background: linear-gradient(90deg, var(--orbit), var(--pulse));
  transition: width 0.3s ease;
}

.iso-group-label {
  font-weight: 600;
  font-size: 12px;
  color: var(--txt);
}

.iso-group-completion {
  font-family: var(--fd);
  font-size: 11px;
  color: var(--orbit);
  font-weight: 700;
}

.iso-breadcrumb {
  display: flex;
  gap: var(--md);
  margin-bottom: var(--lg);
  padding: var(--md);
  background-color: var(--hover);
  border-radius: var(--r);
  font-size: 11px;
}

.iso-breadcrumb-item {
  color: var(--txtM);
  cursor: pointer;
}

.iso-breadcrumb-item:hover {
  color: var(--orbit);
}

.iso-breadcrumb-item.active {
  color: var(--txt);
  font-weight: 600;
}

/* ══════════════════════════════════════════════════════════════════ */

/* ----------------------------------------------------------------- */
/* ISO 27001 ANNEXES - BLOQUES MEJORADOS                            */
/* ----------------------------------------------------------------- */

.iso-annex-block {
  animation: fadeInUp 0.3s ease-out;
}

.iso-annex-header {
  user-select: none;
  transition: all 0.2s ease;
}

.iso-annex-header:hover {
  box-shadow: inset 0 1px 3px rgba(255, 255, 255, 0.1);
}

.iso-annex-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
}

.iso-annex-body {
  transition: max-height 0.3s ease, opacity 0.2s ease;
  overflow: hidden;
}

.iso-control-row {
  position: relative;
  animation: fadeInUp 0.2s ease-out;
}

.iso-control-row::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, transparent, rgba(34, 197, 94, 0.25));
  border-radius: 0 2px 2px 0;
}

.iso-annex-stats {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.iso-annex-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.iso-annex-stat-value {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

.iso-annex-stat-label {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Estilos para los diferentes anexos */
.iso-annex-A5 {
  border-color: rgba(59, 130, 246, 0.4);
}

.iso-annex-A6 {
  border-color: rgba(236, 72, 153, 0.4);
}

.iso-annex-A7 {
  border-color: rgba(168, 85, 247, 0.4);
}

.iso-annex-A8 {
  border-color: rgba(34, 197, 94, 0.4);
}

.iso-annex-A9 {
  border-color: rgba(245, 158, 11, 0.4);
}

.iso-annex-A10 {
  border-color: rgba(34, 197, 94, 0.4);
}

.iso-annex-A11 {
  border-color: rgba(139, 92, 246, 0.4);
}

.iso-annex-A12 {
  border-color: rgba(239, 68, 68, 0.4);
}

.iso-annex-A13 {
  border-color: rgba(34, 197, 94, 0.4);
}

.iso-annex-A14 {
  border-color: rgba(249, 115, 22, 0.4);
}

.iso-annex-A15 {
  border-color: rgba(96, 165, 250, 0.4);
}

.iso-annex-A16 {
  border-color: rgba(167, 139, 250, 0.4);
}

.iso-annex-A17 {
  border-color: rgba(52, 211, 153, 0.4);
}

.iso-annex-A18 {
  border-color: rgba(251, 191, 36, 0.4);
}

/* ----------------------------------------------------------------- */
/* ISO 27001 VISTA MEJORADA - CONTROLES                            */
/* ----------------------------------------------------------------- */

.iso-controls-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding: 20px;
  background: rgba(34, 197, 94, 0.04);
  border-radius: 12px;
  border: 1px solid rgba(34, 197, 94, 0.15);
}

.iso-controls-title h2 {
  margin: 0 0 4px 0;
  font-size: 20px;
  color: #fff;
}

.iso-controls-title p {
  margin: 0;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
}

.iso-view-toggle {
  display: flex;
  gap: 8px;
  align-items: center;
}

.iso-view-toggle .view-btn {
  transition: all 0.2s ease;
  opacity: 0.6;
}

.iso-view-toggle .view-btn.active {
  opacity: 1;
}

.iso-view-toggle .view-btn.active:hover {
  transform: scale(1.05);
}

.iso-filter-panel {
  margin-bottom: 16px;
}

.filter-header {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.iso-filter-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.iso-filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(34, 197, 94, 0.12);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.30);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.iso-filter-tag button {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  padding: 0;
  font-size: 12px;
  transition: color 0.2s ease;
}

.iso-filter-tag button:hover {
  color: #fff;
}

.iso-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.iso-stat-card {
  animation: fadeInUp 0.3s ease-out;
}

@media (max-width: 1200px) {
  .iso-stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }
}

@media (max-width: 768px) {
  .iso-controls-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .filter-header {
    flex-direction: column;
  }
  
  .filter-header > * {
    width: 100%;
  }
  
  .iso-stats-grid {
    grid-template-columns: 1fr;
  }
}
