/* ==========================================
   API PANEL - DARK ADMIN THEME
   ========================================== */

:root {
  --bg-primary: #0f1117;
  --bg-secondary: #161822;
  --bg-card: #1c1e2e;
  --bg-input: #232538;
  --bg-hover: #252840;
  --border-color: #2a2d42;
  --text-primary: #e4e6f0;
  --text-secondary: #8b8fa3;
  --text-muted: #5c5f73;
  --accent-blue: #3b82f6;
  --accent-blue-hover: #2563eb;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-yellow: #f59e0b;
  --accent-purple: #8b5cf6;
  --accent-cyan: #06b6d4;
  --accent-orange: #f97316;
  --accent-pink: #ec4899;
  --accent-indigo: #6366f1;
  --accent-teal: #14b8a6;
  --accent-lime: #84cc16;
  --sidebar-width: 250px;
  --topbar-height: 60px;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --transition: all 0.2s ease;
}

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

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent-blue); text-decoration: none; }
a:hover { color: var(--accent-blue-hover); }

/* ==========================================
   LOGIN PAGE
   ========================================== */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0f1117 0%, #1a1c2e 50%, #0f1117 100%);
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 20px;
}

.login-box {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  padding: 40px;
  box-shadow: var(--shadow);
}

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

.login-icon {
  font-size: 48px;
  color: var(--accent-blue);
  margin-bottom: 15px;
}

.login-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

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

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

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

.login-form input {
  width: 100%;
  padding: 12px 15px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  transition: var(--transition);
}

.login-form input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.login-footer {
  text-align: center;
  margin-top: 25px;
  color: var(--text-muted);
  font-size: 12px;
}

/* ==========================================
   APP LAYOUT
   ========================================== */

.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 100;
  transition: var(--transition);
}

.sidebar.collapsed {
  transform: translateX(-100%);
}

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

.sidebar-header i {
  color: var(--accent-blue);
  font-size: 24px;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  border-left: 3px solid transparent;
}

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

.nav-item.active {
  background: rgba(59, 130, 246, 0.08);
  color: var(--accent-blue);
  border-left-color: var(--accent-blue);
}

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

.nav-divider {
  height: 1px;
  background: var(--border-color);
  margin: 10px 20px;
}

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

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
  font-size: 13px;
}

.user-info i { color: var(--accent-purple); }

/* Main Content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: var(--transition);
}

.main-content.expanded {
  margin-left: 0;
}

.top-bar {
  height: var(--topbar-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 25px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.sidebar-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 15px;
}

.current-time {
  color: var(--text-secondary);
  font-size: 13px;
  font-family: 'Courier New', monospace;
}

.content-area {
  padding: 25px;
}

/* ==========================================
   PAGE HEADER
   ========================================== */

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

.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-header h1 i {
  color: var(--accent-blue);
}

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

.page-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ==========================================
   ALERTS
   ========================================== */

.alert {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  transition: opacity 0.3s ease;
}

.alert-success {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--accent-green);
}

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--accent-red);
}

.alert-warning {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--accent-yellow);
}

.alert-info {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: var(--accent-blue);
}

/* ==========================================
   STATS GRID
   ========================================== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 15px;
  margin-bottom: 25px;
}

.stats-small .stat-card {
  padding: 15px 20px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 15px;
  transition: var(--transition);
}

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

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.stat-info h3 {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
}

.stat-info p {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.stat-blue .stat-icon { background: rgba(59,130,246,0.15); color: var(--accent-blue); }
.stat-blue .stat-info h3 { color: var(--accent-blue); }
.stat-green .stat-icon { background: rgba(16,185,129,0.15); color: var(--accent-green); }
.stat-green .stat-info h3 { color: var(--accent-green); }
.stat-red .stat-icon { background: rgba(239,68,68,0.15); color: var(--accent-red); }
.stat-red .stat-info h3 { color: var(--accent-red); }
.stat-yellow .stat-icon { background: rgba(245,158,11,0.15); color: var(--accent-yellow); }
.stat-yellow .stat-info h3 { color: var(--accent-yellow); }
.stat-purple .stat-icon { background: rgba(139,92,246,0.15); color: var(--accent-purple); }
.stat-purple .stat-info h3 { color: var(--accent-purple); }
.stat-cyan .stat-icon { background: rgba(6,182,212,0.15); color: var(--accent-cyan); }
.stat-cyan .stat-info h3 { color: var(--accent-cyan); }
.stat-teal .stat-info h3 { color: var(--accent-teal); }
.stat-orange .stat-info h3 { color: var(--accent-orange); }
.stat-indigo .stat-info h3 { color: var(--accent-indigo); }
.stat-pink .stat-info h3 { color: var(--accent-pink); }
.stat-lime .stat-info h3 { color: var(--accent-lime); }

/* ==========================================
   CARDS
   ========================================== */

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

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

.card-header h3 {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  padding: 20px;
}

.cards-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

/* ==========================================
   TABLES
   ========================================== */

.table-responsive {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  background: var(--bg-input);
  padding: 10px 15px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.table td {
  padding: 10px 15px;
  border-bottom: 1px solid var(--border-color);
  font-size: 13px;
  color: var(--text-primary);
}

.table-compact td { padding: 8px 12px; font-size: 12px; }
.table-compact th { padding: 8px 12px; }

.table tbody tr:hover {
  background: var(--bg-hover);
}

.table .text-center { text-align: center; }
.link-cell { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.service-name { max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions-cell { white-space: nowrap; display: flex; gap: 4px; }

/* ==========================================
   BADGES
   ========================================== */

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-pending { background: rgba(245,158,11,0.15); color: var(--accent-yellow); }
.badge-processing, .badge-in-progress { background: rgba(6,182,212,0.15); color: var(--accent-cyan); }
.badge-completed { background: rgba(16,185,129,0.15); color: var(--accent-green); }
.badge-partial { background: rgba(139,92,246,0.15); color: var(--accent-purple); }
.badge-cancelled { background: rgba(107,114,128,0.15); color: #9ca3af; }
.badge-error { background: rgba(239,68,68,0.15); color: var(--accent-red); }

/* ==========================================
   BUTTONS
   ========================================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-primary);
  background: var(--bg-input);
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { background: var(--bg-hover); transform: translateY(-1px); }
.btn-primary { background: var(--accent-blue); color: #fff; }
.btn-primary:hover { background: var(--accent-blue-hover); color: #fff; }
.btn-success { background: var(--accent-green); color: #fff; }
.btn-success:hover { background: #059669; color: #fff; }
.btn-danger { background: var(--accent-red); color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }
.btn-warning { background: var(--accent-yellow); color: #000; }
.btn-warning:hover { background: #d97706; }
.btn-info { background: var(--accent-cyan); color: #fff; }
.btn-info:hover { background: #0891b2; color: #fff; }
.btn-secondary { background: var(--bg-input); color: var(--text-secondary); }
.btn-secondary:hover { color: var(--text-primary); }

.btn-block { width: 100%; justify-content: center; }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-xs { padding: 4px 8px; font-size: 11px; }

/* ==========================================
   FORMS
   ========================================== */

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

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

.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-control-sm {
  padding: 5px 8px;
  font-size: 12px;
}

.inline-input {
  width: 100px;
  display: inline-block;
}

.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

select.form-control {
  cursor: pointer;
}

textarea.form-control {
  resize: vertical;
  min-height: 60px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 15px;
}

.form-group small {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 4px;
}

/* ==========================================
   FILTER BAR
   ========================================== */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
  padding: 12px 15px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
}

/* ==========================================
   PAGINATION
   ========================================== */

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
  margin-top: 20px;
}

/* ==========================================
   MODALS
   ========================================== */

.modal {
  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: 1000;
  padding: 20px;
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 25px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-lg { max-width: 700px; }

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

.modal-header h3 {
  font-size: 17px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  padding: 0 5px;
  line-height: 1;
}

.modal-close:hover { color: var(--accent-red); }

/* ==========================================
   INFO BOX
   ========================================== */

.info-box {
  background: rgba(59,130,246,0.08);
  border: 1px solid rgba(59,130,246,0.2);
  border-radius: var(--radius);
  padding: 15px 20px;
  margin-bottom: 20px;
  display: flex;
  gap: 12px;
  font-size: 13px;
  line-height: 1.6;
}

.info-box i {
  color: var(--accent-blue);
  font-size: 18px;
  margin-top: 2px;
}

.info-box code {
  background: var(--bg-input);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: var(--accent-cyan);
}

/* ==========================================
   CODE BLOCK
   ========================================== */

.code-block {
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 15px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--accent-green);
  max-height: 400px;
  overflow-y: auto;
}

/* ==========================================
   API KEY CELL
   ========================================== */

.api-key-cell {
  display: flex;
  align-items: center;
  gap: 6px;
}

.api-key-text {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: var(--accent-cyan);
  background: var(--bg-input);
  padding: 3px 8px;
  border-radius: 4px;
}

/* ==========================================
   SETTINGS GRID
   ========================================== */

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 20px;
}

/* ==========================================
   SCROLLBAR
   ========================================== */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ==========================================
   RESPONSIVE
   ========================================== */

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.collapsed {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .content-area {
    padding: 15px;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .settings-grid {
    grid-template-columns: 1fr;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
}

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