/* ===== Global Reset ===== */
* {
  box-sizing: border-box;
}

h1, h2, h3, h4, h5, h6, p, span, div {
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}

img, video, iframe, svg {
  max-width: 100%;
  height: auto;
}

pre, code {
  max-width: 100%;
  overflow-x: auto;
  word-wrap: break-word;
}

/* ===== Body ===== */
html, body {
  overflow-x: hidden;
  max-width: 100%;
}

body {
  margin: 0;
  font-family: Inter, sans-serif;
  background: #0b1020;
  color: #fff;
}

/* ===== App ===== */
.app {
  display: flex;
  min-height: 100vh;
  max-width: 100%;
  overflow-x: hidden;
}

/* ===== Smooth Scroll for anchor links ===== */
html {
  scroll-behavior: smooth;
}

/* ===== Sidebar ===== */
.sidebar {
  width: 220px;
  background: #11162a;
  padding: 24px;
  box-sizing: border-box;
}

.logo { 
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.logo span { color: #6fd2ff; }

.sidebar nav a {
  display: block;
  width: fit-content;
  margin: 14px 0;
  color: #b6c2e2;
  text-decoration: none;
  word-wrap: break-word;
}

.sidebar nav a.active {
  color: #6fd2ff;
}

/* ===== Main ===== */
.content {
  flex: 1;
  padding: 32px;
  max-width: 100%;
  overflow-x: hidden;
}

.topbar {
  display: flex;
  justify-content: space-between;
  margin-bottom: 24px;
  max-width: 100%;
  flex-wrap: wrap;
  gap: 12px;
}

/* ===== Cards ===== */
.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 32px;
  max-width: 100%;
}

.card {
  background: #141b3d;
  padding: 20px;
  border-radius: 14px;
  max-width: 100%;
  box-sizing: border-box;
}

/* ===== Panels ===== */
.panel {
  background: #141b3d;
  padding: 20px;
  border-radius: 14px;
  margin-bottom: 24px;
  max-width: 100%;
  box-sizing: border-box;
}

.chart-placeholder {
  height: 180px;
  background: rgba(255,255,255,0.05);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6fd2ff;
}

table {
  width: 100%;
  border-collapse: collapse;
  max-width: 100%;
  table-layout: fixed;
}

th, td {
  padding: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  margin-bottom: 32px;
  max-width: 100%;
}

/* ===== SETTINGS PAGE ===== */

.page-header {
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 1.8rem;
}

.page-header p {
  color: var(--text-secondary);
}

/* ===== Cards ===== */
.settings-card {
  margin-bottom: 24px;
}

/* ===== Profile ===== */
.profile-row {
  display: flex;
  gap: 24px;
  align-items: center;
  max-width: 100%;
  flex-wrap: wrap;
}

.avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f9cff, #6a5cff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.2rem;
  color: #fff;
}

.profile-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  max-width: 100%;
}

/* ===== Fields ===== */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 100%;
}

.field label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.field input,
.field select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  color: var(--text-primary);
  max-width: 100%;
  width: 100%;
}

/* ===== Grid ===== */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  max-width: 100%;
}

/* ===== Toggle ===== */
.toggle-field {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.toggle {
  width: 48px;
  height: 26px;
  background: var(--bg-input);
  border-radius: 20px;
  position: relative;
}

.toggle-dot {
  width: 20px;
  height: 20px;
  background: #4f9cff;
  border-radius: 50%;
  position: absolute;
  top: 3px;
  left: 3px;
}

/* ====== ENHANCED METRICS CARDS ====== */
.metrics {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  max-width: 100%;
}

.metric-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px !important;
  border: 1px solid rgba(111, 210, 255, 0.1);
  transition: transform 0.2s, border-color 0.2s;
  max-width: 100%;
  box-sizing: border-box;
}

.metric-card:hover {
  transform: translateY(-4px);
  border-color: rgba(111, 210, 255, 0.3);
}

.metric-icon {
  font-size: 2rem;
  width: 60px;
  height: 60px;
  background: rgba(111, 210, 255, 0.1);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.metric-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-label {
  font-size: 0.85rem;
  color: #b6c2e2;
}

.metric-value {
  font-size: 1.8rem;
  font-weight: 700;
}

.metric-trend {
  font-size: 0.85rem;
  font-weight: 600;
}

.metric-trend.positive {
  color: #34d399;
}

.metric-trend.negative {
  color: #f87171;
}

/* ===== BAR CHART ===== */
.bar-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  height: 200px;
  gap: 12px;
  padding: 20px 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  height: 100%;
}

.bar {
  width: 100%;
  max-width: 50px;
  background: linear-gradient(180deg, #6fd2ff, #4f9cff);
  border-radius: 6px 6px 0 0;
  transition: all 0.3s;
  cursor: pointer;
}

.bar:hover {
  background: linear-gradient(180deg, #8fe0ff, #6fb0ff);
}

.bar-label {
  font-size: 0.8rem;
  color: #b6c2e2;
  margin-top: auto;
}

/* ===== LINE CHART ===== */
.line-chart {
  position: relative;
  height: 200px;
  background: linear-gradient(
    to bottom,
    rgba(111, 210, 255, 0.1) 0%,
    rgba(111, 210, 255, 0.05) 50%,
    transparent 100%
  );
  border-radius: 10px;
  overflow: hidden;
  max-width: 100%;
}

.line-point {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #6fd2ff;
  border: 3px solid #141b3d;
  border-radius: 50%;
  transform: translate(-50%, 50%);
  cursor: pointer;
  transition: all 0.3s;
}

.line-point:hover {
  width: 16px;
  height: 16px;
  background: #8fe0ff;
}

.line-point .point-value {
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 27, 61, 0.95);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s;
}

.line-point:hover .point-value {
  opacity: 1;
}

/* ===== DONUT CHART ===== */
.donut-chart {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 20px auto;
  max-width: 100%;
}

.donut-segment {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: conic-gradient(
    from var(--rotation),
    var(--color) 0deg,
    var(--color) calc(var(--percentage) * 3.6deg),
    transparent calc(var(--percentage) * 3.6deg)
  );
}

.donut-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 120px;
  height: 120px;
  background: #141b3d;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.donut-total {
  text-align: center;
}

.donut-total strong {
  display: block;
  font-size: 1.5rem;
  color: #fff;
}

.donut-total span {
  font-size: 0.75rem;
  color: #b6c2e2;
}

.donut-label {
  position: absolute;
  top: 50%;
  left: 50%;
  font-size: 0.75rem;
  color: #b6c2e2;
  white-space: nowrap;
}

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

.data-table thead th {
  text-align: left;
  padding: 12px;
  border-bottom: 2px solid rgba(255,255,255,0.1);
  color: #b6c2e2;
  font-size: 0.85rem;
  font-weight: 600;
}

.data-table tbody td {
  padding: 14px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.data-table tbody tr:hover {
  background: rgba(111, 210, 255, 0.05);
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6fd2ff, #4f9cff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
}

.channel-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.channel-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.badge {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-block;
}

.badge-active {
  background: rgba(52, 211, 153, 0.2);
  color: #34d399;
}

.badge-pending {
  background: rgba(251, 191, 36, 0.2);
  color: #fbbf24;
}

.badge-inactive {
  background: rgba(148, 163, 184, 0.2);
  color: #94a3b8;
}

/* ===== DASHBOARD GRID ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  max-width: 100%;
}

/* ===== STATS LIST ===== */
.stats-list {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-label {
  font-size: 0.9rem;
  color: #b6c2e2;
}

.stat-bar {
  height: 8px;
  background: rgba(255,255,255,0.05);
  border-radius: 10px;
  overflow: hidden;
}

.stat-progress {
  height: 100%;
  background: linear-gradient(90deg, #6fd2ff, #4f9cff);
  border-radius: 10px;
  transition: width 0.6s ease;
}

.stat-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: #6fd2ff;
}

/* ===== TOOLTIP ===== */
.has-tooltip {
  position: relative;
}

.has-tooltip .tooltip {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #f1f5f9;
  padding: 10px 14px;
  font-size: 0.75rem;
  line-height: 1.4;
  border-radius: 8px;
  white-space: normal;
  max-width: 250px;
  word-wrap: break-word;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  border: 1px solid rgba(111, 210, 255, 0.2);
  z-index: 1000;
}

/* ===== TOOLTIP ARROW ===== */
.has-tooltip .tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: #1e293b transparent transparent transparent;
}

/* ===== HOVER ===== */
.has-tooltip:hover .tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(-6px);
}

/* ===== SETTINGS PAGE IMPROVEMENTS ===== */
.profile-fields {
  flex: 1;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 100%;
}

.settings-grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
  max-width: 100%;
}

.settings-actions {
  margin-top: 24px;
  display: flex;
  gap: 12px;
  max-width: 100%;
  flex-wrap: wrap;
}

.security-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
  max-width: 100%;
}

.security-grid .toggle-row {
  grid-column: 1 / -1;
}

/* ===== BUTTONS ===== */
.btn {
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
  max-width: 100%;
  box-sizing: border-box;
}

.btn-primary {
  background: linear-gradient(135deg, #6fd2ff, #4f9cff);
  color: #0b1020;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(111, 210, 255, 0.4);
}

.btn-secondary {
  background: rgba(255,255,255,0.05);
  color: #b6c2e2;
}

.btn-secondary:hover {
  background: rgba(255,255,255,0.1);
}

.btn-danger {
  background: #ef4444;
  color: #fff;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-danger-outline {
  background: transparent;
  color: #ef4444;
  border: 1px solid #ef4444;
}

.btn-danger-outline:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* ===== TOGGLE SWITCH ===== */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: rgba(255,255,255,0.02);
  border-radius: 10px;
  max-width: 100%;
  flex-wrap: wrap;
  gap: 12px;
}

.toggle-label {
  font-weight: 600;
  margin-bottom: 4px;
}

.toggle-description {
  font-size: 0.85rem;
  color: #b6c2e2;
}

.toggle-switch {
  position: relative;
  width: 50px;
  height: 26px;
  cursor: pointer;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255,255,255,0.1);
  border-radius: 26px;
  transition: 0.3s;
}

.toggle-slider:before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
  background: linear-gradient(135deg, #6fd2ff, #4f9cff);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(24px);
}

/* ===== FORM INPUTS ===== */
.field input,
.field select {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 10px 14px;
  color: #fff;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: #6fd2ff;
  background: rgba(111, 210, 255, 0.05);
}

/* ===== DANGER ZONE ===== */
.danger-zone {
  border: 1px solid rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.05);
}

.danger-zone h3 {
  color: #ef4444;
}

.danger-zone p {
  color: #b6c2e2;
  margin: 12px 0 20px;
  font-size: 0.9rem;
}

.danger-actions {
  display: flex;
  gap: 12px;
  max-width: 100%;
  flex-wrap: wrap;
}

.demo-label {
  display: inline-block;
  margin-top: 4px;
  font-size: 11px;
  color: #7aa2ff;
  opacity: 0.7;
}

/* ===== RESPONSIVE - TABLET ===== */
@media (max-width: 1024px) {
  .content {
    padding: 24px;
  }

  .metrics {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .analytics-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== RESPONSIVE - MOBILE ===== */
@media (max-width: 900px) {
  html, body {
    overflow-x: hidden;
    max-width: 100vw;
  }

  .app {
    flex-direction: column;
    width: 100%;
    max-width: 100vw;
  }

  .sidebar {
    width: 100%;
    padding: 16px;
    box-sizing: border-box;
  }

  .sidebar nav {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
  }

  .sidebar nav a {
    margin: 0;
  }

  .content {
    padding: 20px 16px;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
  }

  .topbar {
    flex-direction: column;
    gap: 12px;
  }

  .metrics {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .analytics-grid {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .card,
  .panel {
    max-width: 100%;
    box-sizing: border-box;
  }

  .settings-grid-2col {
    grid-template-columns: 1fr;
  }

  .profile-fields {
    grid-template-columns: 1fr;
  }

  .security-grid {
    grid-template-columns: 1fr;
  }

  .bar-chart {
    gap: 8px;
    padding: 15px 0;
  }

  .bar {
    max-width: 35px;
  }

  .data-table {
    font-size: 0.85rem;
    display: block;
    overflow-x: auto;
    max-width: 100%;
  }

  .data-table thead th,
  .data-table tbody td {
    padding: 10px 8px;
    white-space: normal;
    word-wrap: break-word;
  }

  .has-tooltip .tooltip {
    white-space: normal;
    max-width: calc(100vw - 40px);
    left: 50%;
    right: auto;
    transform: translateX(-50%);
  }

  .has-tooltip:hover .tooltip {
    transform: translateX(-50%) translateY(-6px);
  }

  .has-tooltip .tooltip::after {
    left: 50%;
    transform: translateX(-50%);
  }
}

/* ===== RESPONSIVE - SMALL MOBILE ===== */
@media (max-width: 600px) {
  html, body {
    overflow-x: hidden;
    max-width: 100vw;
  }

  body {
    font-size: 14px;
  }

  .sidebar {
    padding: 12px;
    box-sizing: border-box;
  }

  .content {
    padding: 16px 12px;
    max-width: 100vw;
    box-sizing: border-box;
  }

  .page-header h1 {
    font-size: 1.5rem;
  }

  .metric-card {
    padding: 18px !important;
    flex-direction: column;
    text-align: center;
  }

  .metric-icon {
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
  }

  .metric-value {
    font-size: 1.5rem;
  }

  .card,
  .panel {
    padding: 16px;
  }

  .profile-row {
    flex-direction: column;
    text-align: center;
  }

  .settings-actions {
    flex-direction: column;
  }

  .settings-actions .btn {
    width: 100%;
  }

  .danger-actions {
    flex-direction: column;
  }

  .danger-actions .btn {
    width: 100%;
  }

  .bar-chart {
    height: 150px;
    gap: 6px;
  }

  .bar {
    max-width: 25px;
  }

  .bar-label {
    font-size: 0.7rem;
  }

  .donut-chart {
    width: 160px;
    height: 160px;
  }

  .donut-center {
    width: 100px;
    height: 100px;
  }

  .donut-total strong {
    font-size: 1.2rem;
  }

  .data-table {
    display: block;
    overflow-x: auto;
    max-width: 100%;
  }

  .data-table thead th,
  .data-table tbody td {
    white-space: normal;
    word-wrap: break-word;
  }

  .user-cell,
  .channel-cell {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .toggle-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}

/* ===== RESPONSIVE - VERY SMALL MOBILE ===== */
@media (max-width: 400px) {
  html, body {
    overflow-x: hidden;
    max-width: 100vw;
  }

  .content {
    padding: 12px 8px;
    max-width: 100vw;
    box-sizing: border-box;
  }

  .page-header h1 {
    font-size: 1.3rem;
  }

  .metric-value {
    font-size: 1.3rem;
  }

  .btn {
    padding: 9px 16px;
    font-size: 0.85rem;
  }

  .card,
  .panel {
    padding: 12px;
    max-width: 100%;
    box-sizing: border-box;
  }

  table th,
  table td {
    padding: 8px 6px;
    font-size: 0.8rem;
  }
}
