/* General styling resets & layout settings */
:root {
  --bg-dark: #090d16;
  --panel-bg: rgba(17, 25, 40, 0.6);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-blue: #6366f1;
  --accent-blue-hover: #4f46e5;
  --accent-green: #10b981;
  --accent-green-hover: #059669;
  --accent-red: #f43f5e;
  --accent-red-hover: #e11d48;
  --accent-yellow: #eab308;
  --accent-yellow-hover: #ca8a04;
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
  --transition-speed: 0.25s;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  position: relative;
}

/* Background elements for glow effect */
.app-container {
  width: 100%;
  max-width: 1200px;
  min-height: 90vh;
  margin: 20px;
  display: flex;
  flex-direction: column;
  background: rgba(10, 15, 30, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  z-index: 10;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.bg-gradient {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  z-index: 1;
  opacity: 0.4;
  pointer-events: none;
}

.bg-grad-1 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, var(--accent-blue) 0%, transparent 70%);
  top: -10%;
  left: 10%;
}

.bg-grad-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #ec4899 0%, transparent 70%);
  bottom: -15%;
  right: 5%;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 32px;
  border-bottom: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.02);
}

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

.icon-brand {
  width: 32px;
  height: 32px;
  color: var(--accent-blue);
  filter: drop-shadow(0 0 8px rgba(99, 102, 241, 0.5));
}

.brand h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.accent-text {
  background: linear-gradient(135deg, var(--accent-blue) 0%, #a5b4fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.system-status {
  display: flex;
  gap: 12px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(255, 255, 255, 0.03);
  transition: all var(--transition-speed) ease;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* Status variants */
.status-badge.disconnected .status-dot {
  background-color: var(--accent-red);
  box-shadow: 0 0 8px var(--accent-red);
}
.status-badge.connected .status-dot {
  background-color: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}
.status-badge.connecting .status-dot {
  background-color: var(--accent-yellow);
  box-shadow: 0 0 8px var(--accent-yellow);
  animation: pulse 1.5s infinite;
}

.status-badge.unregistered .status-dot {
  background-color: var(--text-muted);
}
.status-badge.registering .status-dot {
  background-color: var(--accent-yellow);
  box-shadow: 0 0 8px var(--accent-yellow);
  animation: pulse 1.5s infinite;
}
.status-badge.registered .status-dot {
  background-color: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}

/* Layout */
.main-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  flex: 1;
  padding: 32px;
  gap: 32px;
}

@media (max-width: 900px) {
  .main-content {
    grid-template-columns: 1fr;
  }
}

.sidebar-panel {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.glass-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 12px;
}

.card-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
}

/* Forms */
.settings-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}

.sub-label {
  font-size: 0.7rem;
  font-style: italic;
  opacity: 0.7;
}

.form-group input {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 0.9rem;
  transition: all var(--transition-speed) ease;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent-blue);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.15);
}

.checkbox-group {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.checkbox-group input {
  cursor: pointer;
  width: 16px;
  height: 16px;
  accent-color: var(--accent-blue);
}

.checkbox-group label {
  cursor: pointer;
  user-select: none;
}

/* Buttons */
.btn {
  padding: 12px 20px;
  border-radius: 10px;
  font-family: var(--font-family);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition-speed) ease;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--accent-blue-hover);
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn:disabled, .btn-action:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none !important;
}

.form-actions {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 12px;
  margin-top: 8px;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  transition: all var(--transition-speed) ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.btn-text {
  background: transparent;
  border: none;
  color: var(--accent-blue);
  font-family: var(--font-family);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: color var(--transition-speed) ease;
}

.btn-text:hover {
  color: var(--accent-blue-hover);
  text-decoration: underline;
}

/* Call History List */
.history-list-wrapper {
  max-height: 200px;
  overflow-y: auto;
}

.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-empty {
  color: var(--text-muted);
  text-align: center;
  font-size: 0.85rem;
  padding: 20px 0;
  font-style: italic;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  font-size: 0.85rem;
  transition: background var(--transition-speed) ease;
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

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

.history-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.history-icon.outgoing {
  color: var(--accent-blue);
  background: rgba(99, 102, 241, 0.15);
}

.history-icon.incoming {
  color: var(--accent-green);
  background: rgba(16, 185, 129, 0.15);
}

.history-icon.missed {
  color: var(--accent-red);
  background: rgba(244, 63, 94, 0.15);
}

.history-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-name {
  font-weight: 500;
  color: var(--text-main);
}

.history-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.history-duration {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-right: 12px;
}

.history-actions {
  display: flex;
  gap: 6px;
}

/* Dialer panel */
.dialer-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 480px;
  overflow: hidden;
}

/* Dialer Screen */
.dialer-screen {
  width: 100%;
  position: relative;
  margin-bottom: 24px;
}

#dialInput {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 16px 45px 16px 16px;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-main);
  text-align: center;
  letter-spacing: 0.5px;
  font-family: var(--font-family);
  transition: all var(--transition-speed) ease;
}

#dialInput:focus {
  outline: none;
  border-color: var(--accent-blue);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.15);
}

.clear-btn {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  transition: all var(--transition-speed) ease;
}

.clear-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

/* Keypad Grid */
.keypad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  width: 100%;
  max-width: 280px;
  margin-bottom: 24px;
}

.key-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  height: 64px;
  width: 64px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  justify-self: center;
  transition: all var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
}

.key-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.key-btn:active {
  transform: scale(0.95);
  background: rgba(99, 102, 241, 0.2);
  border-color: var(--accent-blue);
}

.key-num {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.2;
}

.key-sub {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Dialer Actions */
.dialer-actions {
  display: flex;
  justify-content: center;
  width: 100%;
}

.btn-action {
  height: 64px;
  width: 64px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-speed) ease;
}

.call-btn {
  background: var(--accent-green);
  color: white;
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.3);
}

.call-btn:hover:not(:disabled) {
  background: var(--accent-green-hover);
  transform: scale(1.05);
  box-shadow: 0 10px 25px rgba(16, 185, 129, 0.5);
}

.call-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.btn-action svg {
  width: 24px;
  height: 24px;
}

/* Active Call Dashboard Overlay */
.call-dashboard {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #0f172a;
  border-radius: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 40px 24px;
  animation: slideIn var(--transition-speed) ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.call-glow-bg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 260px;
  height: 260px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, transparent 70%);
  z-index: -1;
  pointer-events: none;
  animation: breathing 3s ease-in-out infinite;
}

@keyframes breathing {
  0%, 100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.5;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.2);
    opacity: 0.9;
  }
}

.caller-meta {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.avatar-ring {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.01);
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.3);
  margin-bottom: 8px;
}

.avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.avatar svg {
  width: 36px;
  height: 36px;
}

.caller-meta h3 {
  font-size: 1.5rem;
  font-weight: 600;
}

.caller-meta p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.call-state-badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent-blue);
  margin-top: 4px;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.call-timer {
  font-size: 2rem;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  margin-top: 8px;
}

/* Call actions in Dashboard */
.call-controls {
  display: flex;
  gap: 24px;
  justify-content: center;
  width: 100%;
}

.call-control-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  width: 68px;
  height: 68px;
  border-radius: 50%;
  justify-content: center;
  color: var(--text-main);
  cursor: pointer;
  transition: all var(--transition-speed) ease;
}

.call-control-btn svg {
  width: 22px;
  height: 22px;
}

.call-control-btn .btn-label {
  display: none; /* Keep cleaner, or show on hover */
}

.call-control-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

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

/* Active states */
.call-control-btn.active {
  background: var(--accent-yellow);
  border-color: var(--accent-yellow);
  color: #000;
  box-shadow: 0 0 15px rgba(234, 179, 8, 0.3);
}

.call-control-btn.active:hover {
  background: var(--accent-yellow-hover);
}

.call-control-btn.muted {
  background: var(--accent-red);
  border-color: var(--accent-red);
  color: white;
  box-shadow: 0 0 15px rgba(244, 63, 94, 0.3);
}

.call-control-btn.muted:hover {
  background: var(--accent-red-hover);
}

.call-control-btn.btn-danger {
  background: var(--accent-red);
  border-color: var(--accent-red);
  color: white;
  box-shadow: 0 8px 20px rgba(244, 63, 94, 0.3);
}

.call-control-btn.btn-danger:hover {
  background: var(--accent-red-hover);
  box-shadow: 0 10px 25px rgba(244, 63, 94, 0.5);
}

.dtmf-toggle-wrapper {
  margin-top: 10px;
}

/* Modals / Incoming Call overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(5, 8, 15, 0.85);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  animation: fadeIn var(--transition-speed) ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  width: 90%;
  max-width: 400px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 32px;
  text-align: center;
}

.incoming-call-card {
  overflow: hidden;
}

.pulse-ring {
  position: absolute;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 2px solid rgba(16, 185, 129, 0.3);
  top: 25%;
  z-index: -1;
  animation: ringsPulse 2s infinite ease-out;
}

@keyframes ringsPulse {
  0% {
    transform: scale(0.6);
    opacity: 1;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

.caller-info {
  margin-bottom: 40px;
}

.incoming-tag {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 20px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
  border: 1px solid rgba(16, 185, 129, 0.3);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 16px;
  animation: flash 1.5s infinite;
}

@keyframes flash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.caller-info h3 {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.caller-info p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.modal-actions {
  display: flex;
  gap: 32px;
}

.btn-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  transition: all var(--transition-speed) ease;
}

.btn-circle svg {
  width: 24px;
  height: 24px;
}

.btn-circle.btn-success {
  background: var(--accent-green);
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.4);
}

.btn-circle.btn-success:hover {
  background: var(--accent-green-hover);
  transform: scale(1.1);
  box-shadow: 0 10px 25px rgba(16, 185, 129, 0.6);
}

.btn-circle.btn-danger {
  background: var(--accent-red);
  box-shadow: 0 8px 20px rgba(244, 63, 94, 0.4);
}

.btn-circle.btn-danger:hover {
  background: var(--accent-red-hover);
  transform: scale(1.1);
  box-shadow: 0 10px 25px rgba(244, 63, 94, 0.6);
}

.btn-circle:active {
  transform: scale(0.95);
}

/* Animations */
@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.5; }
  100% { transform: scale(1); opacity: 1; }
}

.hidden {
  display: none !important;
}

/* Custom scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Settings Card Minimized */
.settings-card.minimized .settings-form {
  display: none;
}
.settings-card.minimized {
  padding-bottom: 12px;
}
.settings-card #toggleSettingsBtn svg {
  transition: transform var(--transition-speed) ease;
}
.settings-card.minimized #toggleSettingsBtn svg {
  transform: rotate(180deg);
}

/* Call Dashboard Minimized (Exposes Keypad for DTMF) */
.call-dashboard.minimized {
  bottom: auto;
  height: 190px;
  border-bottom: 1px solid var(--panel-border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  padding: 20px 24px;
}
.call-dashboard.minimized .call-glow-bg,
.call-dashboard.minimized .avatar-ring {
  display: none !important;
}
.call-dashboard.minimized .caller-meta {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  gap: 16px;
  margin-bottom: 12px;
}
.call-dashboard.minimized .caller-meta h3 {
  font-size: 1.1rem;
}
.call-dashboard.minimized .caller-meta p {
  display: none;
}
.call-dashboard.minimized .call-state-badge {
  font-size: 0.65rem;
  padding: 3px 8px;
  margin-top: 0;
}
.call-dashboard.minimized .call-timer {
  font-size: 1.35rem;
  margin-top: 0;
  font-weight: 500;
}
.call-dashboard.minimized .call-controls {
  gap: 16px;
}
.call-dashboard.minimized .call-control-btn {
  width: 52px;
  height: 52px;
}
.call-dashboard.minimized .call-control-btn svg {
  width: 18px;
  height: 18px;
}
.call-dashboard.minimized .dtmf-toggle-wrapper {
  margin-top: 0;
}

