/* ============================================================
   iSecure Society — UI Components
   Reusable component styles for the entire application
   ============================================================ */

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.625rem 1.25rem;
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1;
  border-radius: var(--radius-lg);
  transition: all var(--duration-normal) var(--ease-out);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}
.btn:active { transform: scale(0.97); }
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.btn svg, .btn i { width: 18px; height: 18px; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
  color: #fff;
  box-shadow: 0 2px 10px rgba(6, 182, 212, 0.25);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-400), var(--primary-500));
  box-shadow: 0 4px 20px rgba(6, 182, 212, 0.35);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--neutral-800);
  color: var(--text-primary);
  border: 1px solid var(--neutral-700);
}
.btn-secondary:hover {
  background: var(--neutral-700);
  border-color: var(--neutral-600);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger-500), var(--danger-600));
  color: #fff;
}
.btn-danger:hover {
  background: linear-gradient(135deg, var(--danger-400), var(--danger-500));
}

.btn-success {
  background: linear-gradient(135deg, var(--accent-500), var(--accent-600));
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
}
.btn-ghost:hover {
  background: var(--neutral-800);
  color: var(--text-primary);
}

.btn-outline {
  background: transparent;
  color: var(--primary-400);
  border: 1px solid var(--primary-500);
}
.btn-outline:hover {
  background: rgba(6, 182, 212, 0.1);
}

.btn-icon {
  width: 40px; height: 40px;
  padding: 0;
  border-radius: var(--radius-lg);
}

.btn-sm { padding: 0.4rem 0.8rem; font-size: var(--text-xs); }
.btn-lg { padding: 0.8rem 1.75rem; font-size: var(--text-base); }
.btn-xl { padding: 1rem 2.25rem; font-size: var(--text-lg); }

/* === CARDS === */
.card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  transition: all var(--duration-normal) var(--ease-out);
}
.card:hover {
  border-color: rgba(148, 163, 184, 0.2);
  box-shadow: var(--shadow-lg);
}

.card-solid {
  background: var(--bg-surface);
  border: 1px solid var(--neutral-800);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--glass-border);
}
.card-header h3 {
  font-size: var(--text-lg);
  font-weight: 600;
}

.card-body { flex: 1; }

/* Stat Card */
.stat-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  transition: all var(--duration-normal) var(--ease-out);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
  border-radius: var(--radius-full);
}
.stat-card.cyan::before    { background: var(--primary-400); }
.stat-card.green::before   { background: var(--accent-400); }
.stat-card.amber::before   { background: var(--warning-400); }
.stat-card.red::before     { background: var(--danger-400); }

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon.cyan  { background: rgba(6, 182, 212, 0.15); color: var(--primary-400); }
.stat-icon.green { background: rgba(16, 185, 129, 0.15); color: var(--accent-400); }
.stat-icon.amber { background: rgba(245, 158, 11, 0.15); color: var(--warning-400); }
.stat-icon.red   { background: rgba(244, 63, 94, 0.15); color: var(--danger-400); }

.stat-info { flex: 1; }
.stat-label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-1);
}
.stat-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-primary);
}
.stat-change {
  font-size: var(--text-xs);
  margin-top: var(--space-1);
}
.stat-change.up { color: var(--accent-400); }
.stat-change.down { color: var(--danger-400); }

/* === FORMS === */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--neutral-900);
  border: 1px solid var(--neutral-700);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: var(--text-sm);
  transition: all var(--duration-fast) var(--ease-out);
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.1);
}
.form-input::placeholder { color: var(--text-muted); }
.form-input.error { border-color: var(--danger-500); }
.form-textarea { resize: vertical; min-height: 100px; }

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.form-error {
  font-size: var(--text-xs);
  color: var(--danger-400);
}

/* Toggle Switch */
.toggle {
  position: relative;
  width: 44px; height: 24px;
  cursor: pointer;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--neutral-700);
  border-radius: var(--radius-full);
  transition: var(--duration-normal) var(--ease-out);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: var(--duration-normal) var(--ease-out);
}
.toggle input:checked + .toggle-slider { background: var(--primary-500); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* === BADGES & TAGS === */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.2rem 0.6rem;
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  line-height: 1.4;
}
.badge-cyan    { background: rgba(6, 182, 212, 0.15); color: var(--primary-300); }
.badge-green   { background: rgba(16, 185, 129, 0.15); color: var(--accent-400); }
.badge-amber   { background: rgba(245, 158, 11, 0.15); color: var(--warning-400); }
.badge-red     { background: rgba(244, 63, 94, 0.15); color: var(--danger-400); }
.badge-neutral { background: rgba(100, 116, 139, 0.15); color: var(--neutral-400); }

/* Status Dot */
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.status-dot.online  { background: var(--accent-400); box-shadow: 0 0 6px var(--accent-400); }
.status-dot.offline { background: var(--neutral-500); }
.status-dot.alert   { background: var(--danger-400); box-shadow: 0 0 6px var(--danger-400); animation: pulse 2s infinite; }
.status-dot.warning { background: var(--warning-400); }

/* === TABLE === */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-xl);
  border: 1px solid var(--glass-border);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.data-table thead { background: var(--neutral-900); }
.data-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--glass-border);
  white-space: nowrap;
}

.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.06);
  color: var(--text-primary);
}
.data-table tbody tr {
  transition: background var(--duration-fast);
}
.data-table tbody tr:hover {
  background: rgba(148, 163, 184, 0.04);
}

/* === MODAL === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  opacity: 0;
  visibility: hidden;
  transition: all var(--duration-normal) var(--ease-out);
}
.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--neutral-800);
  border-radius: var(--radius-2xl);
  padding: var(--space-8);
  width: 90%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--duration-normal) var(--ease-spring);
  box-shadow: var(--shadow-2xl);
}
.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}
.modal-header h2 { font-size: var(--text-xl); font-weight: 700; }
.modal-close {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-lg);
  color: var(--text-muted);
  transition: all var(--duration-fast);
}
.modal-close:hover { background: var(--neutral-800); color: var(--text-primary); }

.modal-footer {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  margin-top: var(--space-6);
  padding-top: var(--space-6);
  border-top: 1px solid var(--neutral-800);
}

/* === TOAST NOTIFICATIONS === */
.toast-container {
  position: fixed;
  top: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--neutral-800);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  min-width: 320px;
  max-width: 420px;
  animation: fadeInRight var(--duration-normal) var(--ease-spring) both;
  position: relative;
  overflow: hidden;
}
.toast::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
}
.toast.success::before { background: var(--accent-400); }
.toast.error::before   { background: var(--danger-400); }
.toast.warning::before { background: var(--warning-400); }
.toast.info::before    { background: var(--primary-400); }

.toast-icon { font-size: 1.25rem; flex-shrink: 0; margin-top: 1px; }
.toast-content { flex: 1; }
.toast-title { font-size: var(--text-sm); font-weight: 600; margin-bottom: 2px; }
.toast-message { font-size: var(--text-xs); color: var(--text-secondary); }
.toast-close {
  color: var(--text-muted);
  flex-shrink: 0;
  cursor: pointer;
  padding: 2px;
}
.toast-close:hover { color: var(--text-primary); }

.toast.removing { animation: fadeInRight var(--duration-normal) var(--ease-out) reverse both; }

/* Toast Progress Bar */
.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  animation: progress-bar 4s linear forwards;
}
.toast.success .toast-progress { background: var(--accent-400); }
.toast.error .toast-progress { background: var(--danger-400); }
.toast.warning .toast-progress { background: var(--warning-400); }
.toast.info .toast-progress { background: var(--primary-400); }

/* === SIDEBAR === */
.sidebar {
  position: fixed;
  left: 0; top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  z-index: var(--z-fixed);
  transition: width var(--duration-normal) var(--ease-out);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5);
  border-bottom: 1px solid var(--glass-border);
}
.sidebar-logo img { width: 36px; height: 36px; border-radius: var(--radius-md); }
.sidebar-logo h2 { font-size: var(--text-lg); font-weight: 700; white-space: nowrap; }

.sidebar-nav {
  flex: 1;
  padding: var(--space-4) var(--space-3);
  overflow-y: auto;
}

.nav-section {
  margin-bottom: var(--space-6);
}
.nav-section-title {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 var(--space-3);
  margin-bottom: var(--space-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0.6rem var(--space-3);
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: all var(--duration-fast) var(--ease-out);
  text-decoration: none;
  position: relative;
}
.nav-item:hover {
  background: rgba(148, 163, 184, 0.06);
  color: var(--text-primary);
}
.nav-item.active {
  background: rgba(6, 182, 212, 0.1);
  color: var(--primary-400);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -12px;
  width: 3px; height: 24px;
  background: var(--primary-400);
  border-radius: var(--radius-full);
}
.nav-item svg, .nav-item i { width: 20px; height: 20px; flex-shrink: 0; }

.nav-badge {
  margin-left: auto;
  background: var(--danger-500);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 18px; height: 18px;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
}

.sidebar-footer {
  padding: var(--space-4);
  border-top: 1px solid var(--glass-border);
}

/* === MAIN CONTENT AREA === */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left var(--duration-normal) var(--ease-out);
}

.top-bar {
  position: sticky;
  top: 0;
  height: var(--header-height);
  background: rgba(3, 7, 18, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  z-index: var(--z-sticky);
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.page-content {
  padding: var(--space-6);
}

/* === AVATAR === */
.avatar {
  width: 40px; height: 40px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 2px solid var(--glass-border);
}
.avatar-sm { width: 32px; height: 32px; }
.avatar-lg { width: 56px; height: 56px; }

.avatar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-800);
  color: var(--primary-300);
  font-weight: 600;
  font-size: var(--text-sm);
}

/* === LOADING STATES === */
.skeleton {
  background: linear-gradient(90deg, var(--neutral-800) 25%, var(--neutral-700) 50%, var(--neutral-800) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--neutral-700);
  border-top-color: var(--primary-400);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.spinner-sm { width: 16px; height: 16px; border-width: 2px; }
.spinner-lg { width: 40px; height: 40px; border-width: 4px; }

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(3, 7, 18, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  z-index: var(--z-base);
}

/* === EMPTY STATE === */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--text-muted);
}
.empty-state svg { width: 64px; height: 64px; margin: 0 auto var(--space-4); opacity: 0.3; }
.empty-state h3 { font-size: var(--text-lg); font-weight: 600; color: var(--text-secondary); margin-bottom: var(--space-2); }
.empty-state p { font-size: var(--text-sm); max-width: 360px; margin: 0 auto; }

/* === DIVIDER === */
.divider {
  height: 1px;
  background: var(--glass-border);
  margin: var(--space-6) 0;
}

/* === DROPDOWN MENU === */
.dropdown {
  position: relative;
}
.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--bg-surface);
  border: 1px solid var(--neutral-800);
  border-radius: var(--radius-xl);
  padding: var(--space-2);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-dropdown);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: all var(--duration-fast) var(--ease-out);
}
.dropdown.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0.5rem var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  transition: all var(--duration-fast);
  cursor: pointer;
}
.dropdown-item:hover {
  background: var(--neutral-800);
  color: var(--text-primary);
}
.dropdown-divider {
  height: 1px;
  background: var(--neutral-800);
  margin: var(--space-2) 0;
}

/* === RESPONSIVE SIDEBAR === */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: 280px;
    z-index: var(--z-modal);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: calc(var(--z-modal) - 1);
    opacity: 0;
    visibility: hidden;
    transition: all var(--duration-normal);
  }
  .sidebar-backdrop.active { opacity: 1; visibility: visible; }
  .toast-container { left: var(--space-4); right: var(--space-4); }
  .toast { min-width: auto; }
}
