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

:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-card: #16213e;
  --bg-input: #1e2a4a;
  --sidebar-bg: #0d1117;
  --accent: #2aabee;
  --accent-hover: #4db8f0;
  --accent-glow: rgba(42, 171, 238, 0.15);
  --success: #4ade80;
  --danger: #ef4444;
  --warning: #f59e0b;
  --text-primary: #e4e6eb;
  --text-secondary: #8b8fa3;
  --text-muted: #5c5f6e;
  --border: #2a2a40;
  --border-focus: #2aabee;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --transition: 0.2s ease;
}

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

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

a:hover {
  color: var(--accent-hover);
}

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

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

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

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  transition: all var(--transition);
}

.btn-primary {
  background: var(--accent);
  color: white;
  padding: 12px 24px;
  width: 100%;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-primary);
  padding: 10px 20px;
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.btn-danger {
  background: var(--danger);
  color: white;
  padding: 8px 16px;
  font-size: 13px;
}

.btn-danger:hover {
  opacity: 0.9;
}

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

/* Auth Pages */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-container {
  width: 100%;
  max-width: 420px;
}

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

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo .icon {
  width: 56px;
  height: 56px;
  background: var(--accent);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 28px;
}

.auth-logo h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.auth-logo p {
  color: var(--text-secondary);
  font-size: 14px;
}

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

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

.form-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 4px;
}

.form-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: var(--text-secondary);
}

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 14px;
}

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

.alert-success {
  background: rgba(74, 222, 128, 0.1);
  color: var(--success);
  border: 1px solid rgba(74, 222, 128, 0.2);
}

/* Dashboard Layout */
.dashboard {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 24px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
}

.sidebar-logo .icon {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.sidebar-logo h2 {
  font-size: 16px;
  font-weight: 700;
}

.sidebar-menu {
  list-style: none;
  flex: 1;
}

.sidebar-menu li {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.sidebar-menu li:hover,
.sidebar-menu li.active {
  background: var(--accent-glow);
  color: var(--text-primary);
}

.sidebar-menu li.active {
  color: var(--accent);
}

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

.sidebar-user .name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
}

.sidebar-user .email {
  font-size: 12px;
  color: var(--text-muted);
}

.sidebar-user .logout {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-block;
}

.sidebar-user .logout:hover {
  color: var(--danger);
}

.main-content {
  flex: 1;
  padding: 32px;
  overflow-y: auto;
}

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

.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

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

/* Client Cards */
.client-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}

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

.client-card:hover {
  border-color: var(--accent);
}

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

.client-card .phone {
  font-size: 16px;
  font-weight: 600;
}

.client-card .status-badge {
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: 500;
}

.status-badge.connected {
  background: rgba(74, 222, 128, 0.1);
  color: var(--success);
}

.client-card .info {
  font-size: 13px;
  color: var(--text-secondary);
}

.client-card .info span {
  display: block;
  margin-bottom: 4px;
}

.client-card .actions {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Send Message Form */
.send-page { max-width: 600px; }
.send-form .form-group { margin-bottom: 20px; }
.send-form label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.send-form select {
  width: 100%; padding: 12px 16px; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary); font-size: 15px; outline: none;
  transition: border-color var(--transition); cursor: pointer;
}
.send-form select:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--accent-glow); }
.send-form select option { background: var(--bg-secondary); color: var(--text-primary); }
.send-form textarea {
  width: 100%; padding: 12px 16px; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary); font-size: 15px; outline: none;
  transition: border-color var(--transition); resize: vertical; min-height: 100px; font-family: inherit;
}
.send-form textarea:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--accent-glow); }
.send-form textarea::placeholder { color: var(--text-muted); }
.send-type-toggle {
  display: flex; gap: 0; border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; margin-bottom: 16px;
}
.send-type-btn {
  flex: 1; padding: 10px 16px; background: transparent; color: var(--text-secondary);
  font-size: 13px; border: none; cursor: pointer; transition: all var(--transition);
  border-right: 1px solid var(--border); font-weight: 500;
}
.send-type-btn:last-child { border-right: none; }
.send-type-btn.active { background: var(--accent); color: white; }
.send-type-btn:hover:not(.active) { background: var(--accent-glow); }
.file-input-wrapper {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--bg-input); border: 1px dashed var(--border);
  border-radius: var(--radius-sm); cursor: pointer; transition: all var(--transition);
}
.file-input-wrapper:hover { border-color: var(--accent); background: var(--accent-glow); }
.file-input-wrapper input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-input-wrapper .file-label { font-size: 14px; color: var(--text-secondary); }
.file-input-wrapper .file-name { font-size: 13px; color: var(--accent); }

.page-section { display: none; }
.page-section.active { display: block; }

/* API Keys */
.api-key-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 12px;
}
.api-key-item .key-info .key-name { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.api-key-item .key-info .key-value { font-size: 12px; color: var(--text-muted); font-family: monospace; }
.api-key-item .key-info .key-date { font-size: 12px; color: var(--text-muted); }
.copy-btn {
  padding: 6px 12px; font-size: 12px; background: var(--bg-input); color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: 6px; cursor: pointer; transition: all var(--transition);
}
.copy-btn:hover { border-color: var(--accent); color: var(--accent); }
.copy-btn.copied { border-color: var(--success); color: var(--success); }

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

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

.empty-state h3 {
  font-size: 18px;
  margin-bottom: 8px;
  color: var(--text-primary);
}

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

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal-overlay.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  width: 100%;
  max-width: 460px;
  padding: 32px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  max-height: 90vh;
  overflow-y: auto;
}

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

.modal-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-primary);
  background: var(--bg-input);
}

/* Steps */
.step-indicator {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  justify-content: center;
}

.step-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  transition: all var(--transition);
}

.step-dot.active {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

.step-dot.done {
  background: var(--success);
}

.step-content {
  display: none;
}

.step-content.active {
  display: block;
}

.step-text {
  text-align: center;
  margin-bottom: 24px;
}

.step-text h3 {
  font-size: 17px;
  margin-bottom: 8px;
}

.step-text p {
  font-size: 14px;
  color: var(--text-secondary);
}

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

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

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Loading button state */
.btn-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.8;
}

/* Spinner Overlay for loading states */
.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 14px;
}

.loading-spinner .spinner {
  width: 32px;
  height: 32px;
  border-width: 3px;
}

/* Responsive */
@media (max-width: 768px) {
  .dashboard {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    padding: 16px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-menu {
    display: none;
  }

  .main-content {
    padding: 20px;
  }

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

  .auth-card {
    padding: 24px;
  }
}
