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

:root {
  /* Backgrounds */
  --bg-body: #0a0c10;
  --bg-sidebar: #0d0f14;
  --bg-card: #12151c;
  --bg-card-hover: #181c25;
  --bg-input: #181c25;

  /* Borders */
  --border-color: #1e2330;
  --border-light: #252a38;

  /* Text */
  --text-primary: #e8eaf0;
  --text-secondary: #8b92a5;
  --text-muted: #5c6478;

  /* Accent Colors */
  --accent-green: #22c55e;
  --accent-green-bg: rgba(34, 197, 94, 0.1);
  --accent-red: #ef4444;
  --accent-red-bg: rgba(239, 68, 68, 0.1);
  --accent-blue: #3b82f6;
  --accent-blue-bg: rgba(59, 130, 246, 0.1);
  --accent-yellow: #eab308;
  --accent-yellow-bg: rgba(234, 179, 8, 0.1);
  --accent-purple: #a855f7;
  --accent-purple-bg: rgba(168, 85, 247, 0.1);
  --accent-cyan: #06b6d4;
  --accent-cyan-bg: rgba(6, 182, 212, 0.1);

  /* Layout */
  --sidebar-width: 250px;
  --header-height: 60px;

  /* Radius */
  --radius: 12px;
  --radius-sm: 8px;

  /* Shadows */
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
}

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

ul {
  list-style: none;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-body);
}

::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 3px;
}

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

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

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

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

.sidebar-header img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

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

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

.sidebar-section {
  padding: 16px 12px 8px;
}

.sidebar-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 0 12px;
  margin-bottom: 8px;
}

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}

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

.sidebar-nav li a.active {
  background: var(--accent-green);
  color: #000;
}

.sidebar-nav li a i {
  width: 18px;
  height: 18px;
}

.sidebar-section-bottom {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--border-color);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
}

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

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

.main-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.main-header-left h2 {
  font-size: 16px;
  font-weight: 600;
}

.hamburger-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px;
}

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

.page-content {
  padding: 24px;
}

/* ==================== COMPONENTS ==================== */

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

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

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

.card-title i {
  color: var(--accent-green);
}

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

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

.metric-label {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.metric-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
}

.metric-value.small {
  font-size: 22px;
}

.metric-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  margin-top: 8px;
}

.metric-delta.positive {
  background: var(--accent-green-bg);
  color: var(--accent-green);
}

.metric-delta.negative {
  background: var(--accent-red-bg);
  color: var(--accent-red);
}

.metric-delta.neutral {
  background: rgba(92, 100, 120, 0.15);
  color: var(--text-muted);
}

/* Content Grid */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.content-grid-full {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

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

.btn-primary {
  background: var(--accent-green);
  color: #000;
}

.btn-primary:hover {
  background: #16a34a;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.btn-outline:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--accent-red-bg);
  color: var(--accent-red);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

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

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}

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

.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: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
}

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

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

/* Alerts */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-success {
  background: var(--accent-green-bg);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: var(--accent-green);
}

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

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

.alert-warning {
  background: var(--accent-yellow-bg);
  border: 1px solid rgba(234, 179, 8, 0.3);
  color: var(--accent-yellow);
}

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

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

.data-table td {
  padding: 12px 20px;
  font-size: 13px;
  border-bottom: 1px solid var(--border-color);
}

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

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.badge-green {
  background: var(--accent-green-bg);
  color: var(--accent-green);
}

.badge-red {
  background: var(--accent-red-bg);
  color: var(--accent-red);
}

.badge-blue {
  background: var(--accent-blue-bg);
  color: var(--accent-blue);
}

.badge-yellow {
  background: var(--accent-yellow-bg);
  color: var(--accent-yellow);
}

/* Loading Spinner */
.loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent-green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

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

/* Status Dot */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.online {
  background: var(--accent-green);
  animation: pulse 2s infinite;
}

.status-dot.offline {
  background: var(--accent-red);
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* Upload Area */
.upload-area {
  border: 2px dashed var(--border-light);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
}

.upload-area:hover {
  border-color: var(--accent-green);
  background: var(--accent-green-bg);
}

.upload-area.dragover {
  border-color: var(--accent-green);
  background: var(--accent-green-bg);
}

.upload-area i {
  color: var(--text-muted);
  margin-bottom: 12px;
}

.upload-area p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.upload-area .upload-hint {
  font-size: 12px;
  color: var(--text-muted);
}

/* Code Block */
.code-block {
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
  overflow-x: auto;
  position: relative;
}

.code-block .code-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.code-block .code-copy:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.code-key {
  color: var(--accent-cyan);
}

.code-string {
  color: var(--accent-green);
}

.code-comment {
  color: var(--text-muted);
}

/* Result Box */
.result-box {
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-top: 12px;
  min-height: 80px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

/* DB Info */
.db-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.db-info-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.db-info-name {
  font-size: 13px;
  font-weight: 500;
}

/* API Endpoint Row */
.endpoint-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}

.endpoint-row:last-child {
  border-bottom: none;
}

.endpoint-method {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  min-width: 52px;
  text-align: center;
}

.method-get {
  background: var(--accent-blue-bg);
  color: var(--accent-blue);
}

.method-post {
  background: var(--accent-green-bg);
  color: var(--accent-green);
}

.method-delete {
  background: var(--accent-red-bg);
  color: var(--accent-red);
}

.endpoint-path {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.endpoint-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: auto;
}

/* Section Title */
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop.show {
    display: block;
  }

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

  .hamburger-btn {
    display: block;
  }

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

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

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

@media (max-width: 480px) {
  .main-header {
    height: 56px;
  }

  .page-content {
    padding: 16px 12px;
  }

  .card {
    padding: 16px;
  }
}
