*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #17153a;
  --bg-secondary: #1e2832;
  --bg-card: #1e2832;
  --bg-card-hover: #263340;
  --bg-glass: rgba(23, 21, 58, 0.88);
  --border-color: rgba(255, 222, 89, 0.12);
  --border-glow: rgba(255, 222, 89, 0.3);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-primary: #ffde59;
  --accent-hover: #ffe57a;
  --accent-glow: rgba(255, 222, 89, 0.2);
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.12);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.12);
  --info: #3b82f6;
  --info-bg: rgba(59, 130, 246, 0.12);
  --gradient-primary: linear-gradient(135deg, #ffde59, #ffc107);
  --gradient-accent: linear-gradient(135deg, #ffde59 0%, #f0c030 100%);
  --gradient-success: linear-gradient(135deg, #22c55e, #16a34a);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px var(--accent-glow);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ========== LOGIN PAGE ========== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 30% 40%, rgba(255, 222, 89, 0.06) 0%, transparent 50%),
              radial-gradient(circle at 70% 60%, rgba(255, 193, 7, 0.04) 0%, transparent 50%),
              radial-gradient(circle at 50% 80%, rgba(30, 40, 50, 0.08) 0%, transparent 40%);
  animation: bgPulse 15s ease-in-out infinite alternate;
}

@keyframes bgPulse {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-5%, -3%) scale(1.05); }
}

.login-container {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: 0 24px;
  z-index: 1;
}

.login-card {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-logo {
  text-align: center;
  margin-bottom: 36px;
}

.login-logo-img {
  max-width: 200px;
  height: auto;
  margin: 0 auto 16px;
  display: block;
  filter: drop-shadow(0 4px 12px rgba(255, 222, 89, 0.25));
}

.login-logo p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 6px;
}

.sidebar-logo-img {
  max-width: 110px;
  height: auto;
  flex-shrink: 0;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: var(--transition);
  outline: none;
}

.form-group input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.btn {
  width: 100%;
  padding: 13px;
  background: var(--gradient-primary);
  color: #17153a;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px var(--accent-glow);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
}

.btn-sm {
  width: auto;
  padding: 8px 16px;
  font-size: 13px;
}

.login-error {
  background: var(--error-bg);
  color: var(--error);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid rgba(239, 68, 68, 0.2);
  display: none;
}

.login-footer {
  text-align: center;
  margin-top: 28px;
  animation: slideUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both;
}

.login-footer p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.8;
}

.login-footer-credit {
  font-size: 11px !important;
  margin-top: 2px;
}

.login-footer-credit a {
  color: var(--accent-hover);
  text-decoration: none;
  font-weight: 600;
  transition: var(--transition);
}

.login-footer-credit a:hover {
  color: var(--accent-primary);
  text-decoration: underline;
}

.login-footer .heart {
  display: inline-block;
  animation: heartbeat 1.4s ease-in-out infinite;
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  14% { transform: scale(1.2); }
  28% { transform: scale(1); }
  42% { transform: scale(1.15); }
  56% { transform: scale(1); }
}


/* ========== DASHBOARD LAYOUT ========== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: var(--transition);
}

.sidebar-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-header .logo-icon {
  width: 36px;
  height: 36px;
  background: var(--gradient-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-header h2 {
  font-size: 16px;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-header span {
  font-size: 11px;
  color: var(--text-muted);
}

.sidebar-nav {
  padding: 16px 12px;
  flex: 1;
  overflow-y: auto;
}

.sidebar-nav .nav-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  padding: 8px 12px 8px;
  margin-top: 12px;
}

.sidebar-nav .nav-label:first-child {
  margin-top: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent-primary);
}

.nav-item .icon {
  width: 20px;
  text-align: center;
  font-size: 16px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-color);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.user-info:hover {
  background: var(--bg-card);
}

.user-avatar {
  width: 36px;
  height: 36px;
  background: var(--gradient-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

.user-details .user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.user-details .user-role {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: capitalize;
}

/* ========== MAIN CONTENT ========== */
.main-content {
  flex: 1;
  margin-left: 260px;
  padding: 24px 32px;
  min-height: 100vh;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.page-header h1 {
  font-size: 26px;
  font-weight: 700;
}

.page-header p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

.header-actions {
  display: flex;
  gap: 12px;
}

/* ========== STAT CARDS ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient-primary);
  opacity: 0;
  transition: opacity 0.3s;
}

.stat-card:hover {
  border-color: var(--border-glow);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card:hover::before {
  opacity: 1;
}

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.stat-icon.purple { background: var(--accent-glow); }
.stat-icon.green { background: var(--success-bg); }
.stat-icon.orange { background: var(--warning-bg); }
.stat-icon.red { background: var(--error-bg); }
.stat-icon.blue { background: var(--info-bg); }

.stat-badge {
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
}

.stat-badge.up { background: var(--success-bg); color: var(--success); }
.stat-badge.down { background: var(--error-bg); color: var(--error); }

.stat-value {
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ========== DATA CARDS ========== */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 28px;
}

.content-grid.full {
  grid-template-columns: 1fr;
}

.data-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.data-card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.data-card-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.data-card-body {
  padding: 20px 24px;
}

/* ========== TABLE ========== */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 12px;
  font-size: 13px;
  border-bottom: 1px solid rgba(255, 222, 89, 0.05);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background: var(--bg-card-hover);
}

/* ========== BADGES ========== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
}

.badge.success { background: var(--success-bg); color: var(--success); }
.badge.error { background: var(--error-bg); color: var(--error); }
.badge.warning { background: var(--warning-bg); color: var(--warning); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.neutral { background: rgba(148, 163, 184, 0.12); color: var(--text-secondary); }

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ========== CONNECTOR CARDS ========== */
.connector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.connector-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: var(--transition);
}

.connector-card:hover {
  border-color: var(--border-glow);
  box-shadow: var(--shadow-md);
}

.connector-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.connector-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
}

.connector-name {
  font-size: 16px;
  font-weight: 600;
}

.connector-type {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: capitalize;
}

.connector-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.connector-meta-item {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.connector-meta-item span:first-child {
  color: var(--text-secondary);
}

.connector-actions {
  display: flex;
  gap: 8px;
}

.connector-actions .btn-sm {
  flex: 1;
  text-align: center;
}

/* ========== MODAL ========== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform 0.3s;
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal-header {
  padding: 24px 28px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--error-bg);
  color: var(--error);
}

.modal-body {
  padding: 24px 28px;
}

.modal-footer {
  padding: 16px 28px 24px;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* ========== EVENT LOG ========== */
.event-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 222, 89, 0.05);
}

.event-item:last-child {
  border-bottom: none;
}

.event-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}

.event-dot.info { background: var(--info); }
.event-dot.success { background: var(--success); }
.event-dot.warning { background: var(--warning); }
.event-dot.error { background: var(--error); }

.event-content {
  flex: 1;
}

.event-message {
  font-size: 13px;
  margin-bottom: 4px;
}

.event-time {
  font-size: 11px;
  color: var(--text-muted);
}

/* ========== CHART CONTAINER ========== */
.chart-container {
  position: relative;
  height: 280px;
  width: 100%;
}

/* ========== LOADING ========== */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid transparent;
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========== EMPTY STATE ========== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-state p {
  font-size: 14px;
}

/* ========== TOAST ========== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-lg);
  min-width: 280px;
}

.toast.success { background: #166534; color: #bbf7d0; }
.toast.error { background: #991b1b; color: #fecaca; }
.toast.info { background: #1e40af; color: #bfdbfe; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1024px) {
  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
    padding: 16px;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
  .login-card {
    padding: 32px 24px;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

.hidden { display: none !important; }

/* ========== SETTINGS & ROLES REFINEMENTS ========== */
.settings-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
}

.settings-tab {
  padding: 12px 24px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: var(--transition);
}

.settings-tab:hover {
  color: var(--text-primary);
}

.settings-tab.active {
  color: var(--accent-primary);
  font-weight: 600;
  border-bottom-color: var(--accent-primary);
}

.permissions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.permission-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: var(--transition);
  user-select: none;
}

.permission-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-glow);
}

.permission-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.permission-item.selected {
  border-color: var(--accent-primary);
  background: var(--accent-glow);
}
