/* ═══════════════════════════════════════════════════════════
   SMS Gateway — Premium Dark Theme
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a28;
  --bg-elevated: #222236;
  --bg-hover: #2a2a42;

  --text-primary: #f0f0f5;
  --text-secondary: #9090a8;
  --text-muted: #606078;

  --accent: #7c6aef;
  --accent-light: #9b8bff;
  --accent-dark: #5a48cc;
  --accent-glow: rgba(124, 106, 239, 0.15);

  --green: #34d399;
  --green-glow: rgba(52, 211, 153, 0.15);
  --red: #f87171;
  --yellow: #fbbf24;
  --blue: #60a5fa;

  --border: rgba(255, 255, 255, 0.06);
  --border-light: rgba(255, 255, 255, 0.1);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px rgba(124, 106, 239, 0.2);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html,
body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── App Layout ──────────────────────────────────────── */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 900px;
  margin: 0 auto;
}

/* ─── Header ──────────────────────────────────────────── */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px);
  background: rgba(10, 10, 15, 0.8);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

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

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

.logo-icon {
  font-size: 24px;
}

.logo h1 {
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.phone-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.copy-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  transition: var(--transition);
  display: flex;
  align-items: center;
}

.copy-btn:hover {
  color: var(--accent-light);
  background: var(--accent-glow);
}

.balance-badge {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 11px;
}

.balance-label {
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.balance-value {
  color: var(--green);
  font-weight: 600;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.unread-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--accent);
  color: white;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  animation: pulse 2s infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.7;
  }
}

/* ─── Buttons ─────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
  box-shadow: var(--shadow-sm), 0 0 20px rgba(124, 106, 239, 0.15);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  box-shadow: var(--shadow-md), var(--shadow-glow);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

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

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px;
  border-radius: var(--radius-sm);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

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

/* ─── Main Content ────────────────────────────────────── */

.main {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

/* ─── Compose Panel ───────────────────────────────────── */

.compose-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 300ms cubic-bezier(0.4, 0, 0.2, 1),
    padding 300ms cubic-bezier(0.4, 0, 0.2, 1);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.compose-panel.open {
  max-height: 400px;
  padding: 20px 24px;
}

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

.compose-header h2 {
  font-size: 15px;
  font-weight: 600;
}

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

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  transition: var(--transition);
  outline: none;
  resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
}

.char-count {
  text-align: right;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.auth-input {
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
}

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

/* ─── Messages Section ────────────────────────────────── */

.messages-section {
  padding: 0 24px 24px;
}

.messages-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 16px;
  position: sticky;
  top: 0;
  background: var(--bg-primary);
  z-index: 10;
}

.messages-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ─── Message Thread List ─────────────────────────────── */

.message-thread {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
}

.message-thread:hover {
  background: var(--bg-secondary);
  border-color: var(--border);
}

.message-thread:active {
  background: var(--bg-tertiary);
}

.thread-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.avatar-inbound {
  background: linear-gradient(135deg, var(--accent-glow), rgba(124, 106, 239, 0.25));
  border: 1px solid rgba(124, 106, 239, 0.2);
}

.avatar-outbound {
  background: linear-gradient(135deg, var(--green-glow), rgba(52, 211, 153, 0.25));
  border: 1px solid rgba(52, 211, 153, 0.2);
}

.thread-content {
  flex: 1;
  min-width: 0;
}

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

.thread-number {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.thread-time {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.thread-preview {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.you-label {
  color: var(--text-muted);
  font-weight: 500;
}

.thread-unread {
  background: var(--accent);
  color: white;
  font-size: 11px;
  font-weight: 700;
  min-width: 22px;
  height: 22px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}

/* ─── Thread View ─────────────────────────────────────── */

.thread-view {
  display: flex;
  flex-direction: column;
  min-height: 300px;
}

.thread-view-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.thread-view-number {
  flex: 1;
  font-weight: 600;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.thread-messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  line-height: 1.5;
  font-size: 14px;
}

.bubble-sent {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
  border-bottom-right-radius: 4px;
}

.bubble-received {
  align-self: flex-start;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.bubble-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
  font-size: 11px;
  opacity: 0.6;
}

/* ─── Empty & Loading States ──────────────────────────── */

.empty-state {
  text-align: center;
  padding: 60px 20px;
}

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

.empty-state h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
  max-width: 400px;
  margin: 0 auto;
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 20px;
  gap: 16px;
}

.loading-state p {
  color: var(--text-muted);
  font-size: 14px;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-light);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

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

/* ─── Toast Notifications ─────────────────────────────── */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  transform: translateX(120%);
  transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(20px);
}

.toast-show {
  transform: translateX(0);
}

.toast-success {
  background: rgba(52, 211, 153, 0.15);
  border: 1px solid rgba(52, 211, 153, 0.3);
  color: var(--green);
}

.toast-error {
  background: rgba(248, 113, 113, 0.15);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: var(--red);
}

.toast-info {
  background: rgba(96, 165, 250, 0.15);
  border: 1px solid rgba(96, 165, 250, 0.3);
  color: var(--blue);
}

/* ─── Scrollbar ───────────────────────────────────────── */

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

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

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ─── Call Panel ──────────────────────────────────────── */

.call-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 300ms cubic-bezier(0.4, 0, 0.2, 1),
    padding 300ms cubic-bezier(0.4, 0, 0.2, 1);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.call-panel.open {
  max-height: 500px;
  padding: 20px 24px;
}

.call-setup {
  display: block;
}

/* ─── Active Call Display ─────────────────────────────── */

.active-call {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 12px 0 8px;
}

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

.call-pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  animation: callPulse 1.5s ease-in-out infinite;
}

@keyframes callPulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.4);
  }

  50% {
    box-shadow: 0 0 0 8px rgba(52, 211, 153, 0);
  }
}

.call-status-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.call-number {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.call-timer {
  font-size: 28px;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  letter-spacing: 2px;
}

.call-controls {
  display: flex;
  gap: 16px;
  margin-top: 8px;
}

.call-control-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.call-control-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.call-control-btn.active {
  background: rgba(251, 191, 36, 0.15);
  border-color: rgba(251, 191, 36, 0.3);
  color: var(--yellow);
}

.call-control-btn.call-hangup {
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.2);
  color: var(--red);
}

.call-control-btn.call-hangup:hover {
  background: rgba(248, 113, 113, 0.2);
  border-color: rgba(248, 113, 113, 0.4);
}

/* ─── Call Buttons ────────────────────────────────────── */

.btn-call {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  background: linear-gradient(135deg, var(--green), #22a06b);
  color: white;
  box-shadow: var(--shadow-sm), 0 0 20px rgba(52, 211, 153, 0.15);
}

.btn-call:hover {
  background: linear-gradient(135deg, #5de0b0, var(--green));
  box-shadow: var(--shadow-md), 0 0 30px rgba(52, 211, 153, 0.2);
  transform: translateY(-1px);
}

.btn-call:active {
  transform: translateY(0);
}

.btn-call-sm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.25);
  color: var(--green);
}

.btn-call-sm:hover {
  background: rgba(52, 211, 153, 0.2);
  border-color: rgba(52, 211, 153, 0.4);
}

/* ─── Thread Call Button ──────────────────────────────── */

.thread-call-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius-sm);
  background: rgba(52, 211, 153, 0.1);
  color: var(--green);
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
  opacity: 0;
}

.message-thread:hover .thread-call-btn {
  opacity: 1;
}

.thread-call-btn:hover {
  background: rgba(52, 211, 153, 0.25);
  transform: scale(1.1);
}

/* ─── Header Actions ─────────────────────────────────── */

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

.thread-view-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── Responsive ──────────────────────────────────────── */

@media (max-width: 640px) {
  .header {
    padding: 12px 16px;
  }

  .phone-badge {
    display: none;
  }

  .messages-section {
    padding: 0 16px 16px;
  }

  .compose-panel.open {
    padding: 16px;
  }

  .bubble {
    max-width: 85%;
  }

  .balance-badge {
    display: none;
  }
}