/* Design Tokens */
:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-gradient: linear-gradient(135deg, #2563eb 0%, #8b5cf6 100%);
  --background-color: #f8fafc;
  --surface-color: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-light: #94a3b8;
  --border-color: #e2e8f0;
  --success-color: #10b981;
  --success-light: #d1fae5;
  --danger-color: #ef4444;
  --danger-light: #fee2e2;
  --warning-color: #f59e0b;
  --warning-light: #fef3c7;
  --info-color: #3b82f6;
  --info-light: #dbeafe;

  /* Sidebar Tokens */
  --sidebar-bg: #0b0f19;
  --sidebar-hover: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-active-bg: linear-gradient(135deg, #2563eb 0%, #8b5cf6 100%);
  --sidebar-active-text: #ffffff;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg:
    0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

  --border-radius-sm: 6px;
  --border-radius-md: 12px;
  --border-radius-lg: 16px;
}

/* Global Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Inter", sans-serif;
  background-color: var(--background-color);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Grid System */
.grid {
  display: grid;
  gap: 24px;
  margin-bottom: 24px;
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}
.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}
.grid-4 {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

@media (min-width: 768px) {
  .col-span-2 {
    grid-column: span 2;
  }
  .col-span-3 {
    grid-column: span 3;
  }
}

/* Sidebar Layout Structure */
.app-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
  position: relative;
  background-color: var(--background-color);
}

/* Sidebar Navigation Drawer */
.sidebar {
  width: 260px;
  height: 100vh;
  background-color: var(--sidebar-bg);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-brand {
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-brand .logo-text {
  font-size: 22px;
  font-weight: 800;
  background: linear-gradient(135deg, #60a5fa 0%, #c084fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.sidebar-brand .logo-sub {
  color: #ffffff;
  font-weight: 400;
}

.sidebar-close-btn {
  display: none;
  color: var(--sidebar-text);
  font-size: 20px;
  cursor: pointer;
}

.sidebar-nav {
  flex: 1;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: var(--sidebar-text);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--border-radius-md);
  transition: all 0.2s ease;
}

.sidebar-link i {
  font-size: 18px;
}

.sidebar-link:hover {
  color: #ffffff;
  background-color: var(--sidebar-hover);
}

.sidebar-link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

/* Main Layout content side */
.main-layout {
  flex: 1;
  margin-left: 260px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Top Bar (Header) */
.topbar {
  height: 70px;
  background-color: var(--surface-color);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 900;
  box-shadow: var(--shadow-sm);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.menu-toggle-btn {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-primary);
  cursor: pointer;
}

.topbar-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--primary-color);
  letter-spacing: 0.5px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 16px;
  border-right: 1px solid var(--border-color);
}

.user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.btn-logout-icon {
  font-size: 20px;
  color: var(--danger-color);
  background-color: var(--danger-light);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-logout-icon:hover {
  background-color: var(--danger-color);
  color: white;
}

/* Page Body content wrapper */
.page-content {
  flex: 1;
  padding: 32px;
}

.content-container {
  max-width: 1200px;
  margin: 0 auto;
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  z-index: 950;
}

/* Page Headers */
h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.section-subtitle {
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 24px;
}

/* Cards & Containers */
.card {
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  background-color: #fafbfc;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.card-body {
  padding: 24px;
}

/* Stats Widgets */
.stat-card {
  border-left: 4px solid var(--border-color);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

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

.stat-primary {
  border-left-color: var(--primary-color);
}
.stat-success {
  border-left-color: var(--success-color);
}
.stat-info {
  border-left-color: var(--info-color);
}
.stat-warning {
  border-left-color: var(--warning-color);
}

.stat-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.stat-primary .stat-value {
  color: var(--primary-color);
}
.stat-success .stat-value {
  color: var(--success-color);
}
.stat-info .stat-value {
  color: var(--info-color);
}
.stat-warning .stat-value {
  color: var(--warning-color);
}

/* Table styling */
.table-responsive {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.table th {
  background-color: #f8fafc;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
}

.table tbody tr:hover {
  background-color: #f8fafc;
}

.table-summary-row {
  background-color: #f8fafc;
  font-weight: bold;
}

.text-center {
  text-align: center;
}
.text-right {
  text-align: right;
}
.text-danger {
  color: var(--danger-color);
}
.text-success {
  color: var(--success-color);
}
.font-semibold {
  font-weight: 600;
}
.font-mono {
  font-family: monospace;
}
.font-bold {
  font-weight: 700;
}
.text-large {
  font-size: 16px;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  text-transform: uppercase;
}

.badge-success {
  background-color: var(--success-light);
  color: var(--success-color);
}
.badge-danger {
  background-color: var(--danger-light);
  color: var(--danger-color);
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  background-color: #fff;
  transition: all 0.2s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-help {
  display: block;
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}

.form-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-divider {
  border: 0;
  height: 1px;
  background-color: var(--border-color);
  margin: 24px 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--border-radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--primary-gradient);
  color: white;
}

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.btn-secondary {
  background-color: var(--border-color);
  color: var(--text-secondary);
}

.btn-secondary:hover {
  background-color: #cbd5e1;
}

.btn-block {
  display: flex;
  width: 100%;
}

/* Alerts */
.alert {
  padding: 14px 20px;
  border-radius: var(--border-radius-sm);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 24px;
}

.alert-danger {
  background-color: var(--danger-light);
  color: var(--danger-color);
  border: 1px solid #fecaca;
}

.alert-success {
  background-color: var(--success-light);
  color: var(--success-color);
  border: 1px solid #a7f3d0;
}

/* Login Page Styling - Dark Navy Theme */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(circle at top right, #1e1b4b 0%, #0b0f19 100%);
  color: #ffffff;
}

.login-wrapper {
  width: 100%;
  max-width: 440px;
  padding: 24px;
}

.login-card {
  background-color: rgba(30, 41, 59, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--border-radius-lg);
  padding: 40px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-header .logo-text {
  font-size: 28px;
  font-weight: 800;
  background: linear-gradient(135deg, #60a5fa 0%, #c084fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.login-header .logo-sub {
  color: #ffffff;
  font-weight: 400;
}

.login-subtitle {
  color: #94a3b8;
  font-size: 14px;
  margin-top: 8px;
}

/* Dark mode inputs specifically for login card */
.login-card .form-label {
  color: #cbd5e1;
}

.login-card .form-control {
  background-color: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.login-card .form-control::placeholder {
  color: #64748b;
}

.login-card .form-control:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.25);
  background-color: rgba(15, 23, 42, 0.8);
}

.login-card .password-toggle-icon {
  color: rgba(255, 255, 255, 0.4);
}

.login-card .password-toggle-icon:hover {
  color: #60a5fa;
}

/* Filter Card Form Layout */
.filter-form .form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
}

.flex-1 {
  flex: 1;
  min-width: 200px;
}

.filter-form .form-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

/* Settings & Configurations Display */
.settings-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-bottom: 1px dashed var(--border-color);
  padding-bottom: 12px;
}

.settings-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.settings-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-light);
}

.settings-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
}

.settings-value.code-text {
  font-family: monospace;
  color: var(--primary-color);
}

.settings-value.wa-target {
  font-size: 13px;
  word-break: break-all;
}

/* Mobile Integration Status Widgets */
.mobile-integration-status {
  background-color: #fafbfc;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 24px;
}

.api-endpoint-card {
  background-color: #0f172a;
  color: #38bdf8;
  font-family: monospace;
  font-size: 13px;
  padding: 14px 18px;
  border-radius: var(--border-radius-sm);
  margin: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.endpoint-label {
  color: #94a3b8;
  font-size: 11px;
  font-weight: bold;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}

.indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.indicator-dot.active {
  background-color: var(--success-color);
  box-shadow: 0 0 0 4px var(--success-light);
}

.indicator-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Footer */
.footer {
  height: 72px;
  border-top: 1px solid var(--border-color);
  background-color: var(--surface-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--text-light);
}

.footer-container {
  text-align: center;
}

/* Password Toggle Styling */
.password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.password-wrapper .form-control {
  padding-right: 44px !important;
}

.password-toggle-icon {
  position: absolute;
  right: 14px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-light);
  font-size: 18px;
  z-index: 5;
  user-select: none;
  transition: color 0.2s ease;
}

.password-toggle-icon:hover {
  color: var(--primary-color);
}

/* Floating Donut Menu Button for Mobile */
.donut-menu-btn {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--primary-gradient);
  color: #ffffff;
  align-items: center;
  justify-content: center;
  z-index: 1050;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4);
  border: 4px solid rgba(255, 255, 255, 0.95);
  outline: none;
}

.donut-menu-btn:hover,
.donut-menu-btn:active {
  transform: scale(1.08) rotate(90deg);
  box-shadow: 0 6px 24px rgba(37, 99, 235, 0.5);
}

.donut-menu-btn i {
  font-size: 24px;
}

/* Responsive Overrides (Screen width < 992px) */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
  }

  .sidebar-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .main-layout {
    margin-left: 0;
    width: 100%;
  }

  .topbar {
    padding: 0 16px;
  }

  .menu-toggle-btn {
    display: block;
  }

  .page-content {
    padding: 16px;
  }

  .app-container.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .app-container.sidebar-open .sidebar-overlay {
    display: block;
  }

  .donut-menu-btn {
    display: flex;
  }
}

@media (min-width: 992px) {
  .sidebar {
    transform: translateX(0) !important;
  }
  .sidebar-overlay {
    display: none !important;
  }
  .donut-menu-btn {
    display: none !important;
  }
}

/* Pagination Styling */
.pagination-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  background-color: #fafbfc;
  flex-wrap: wrap;
  gap: 12px;
}

.pagination-info {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.pagination {
  display: inline-flex;
  list-style: none;
  border-radius: var(--border-radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-color);
  padding: 0;
  margin: 0;
}

.pagination li {
  display: inline;
}

.pagination-link,
.pagination li span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  padding: 0 12px;
  background-color: var(--surface-color);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  border-right: 1px solid var(--border-color);
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
}

.pagination li:last-child .pagination-link,
.pagination li:last-child span {
  border-right: none;
}

.pagination-link:hover {
  background-color: var(--primary-light);
  color: var(--primary-color);
}

.pagination li.active span {
  background: var(--primary-gradient);
  color: white;
  border-color: transparent;
  cursor: default;
}

.pagination li.disabled span {
  background-color: #f1f5f9;
  color: var(--text-light);
  cursor: not-allowed;
}

.pagination li.ellipsis span {
  background-color: var(--surface-color);
  color: var(--text-light);
  cursor: default;
}

/* Sidebar Section Divider */
.sidebar-section-divider {
  height: 1px;
  background-color: rgba(255, 255, 255, 0.08);
  margin: 12px 16px;
}
