/* iOS Dialer & App Styles */
:root {
  --ios-bg: #f2f2f7;
  --ios-card: #ffffff;
  --ios-blue: #007aff;
  --ios-green: #34c759;
  --ios-red: #ff3b30;
  --ios-gray: #8e8e93;
  --ios-separator: #c6c6c8;
  --ios-text: #000000;
  --ios-text-secondary: #3c3c4399; /* 60% opacity */
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial,
    sans-serif;
}

body {
  margin: 0;
  padding: 0;
  background-color: #fff; /* Changed from #000 to #fff */
  color: var(--ios-text);
  overflow: hidden; /* Prevent scroll on body, handle in views */
  height: 100vh;
  width: 100vw;
  display: flex;
  justify-content: center;
}

#mainContainer {
  width: 100%;
  height: 100%;
  max-width: 480px; /* Simulate phone on desktop */
  background-color: var(--ios-bg);
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* View Containers */
.view-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  background-color: var(--ios-bg);
  position: absolute; /* Ensure screens stack on top of each other */
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
}

.view-container.active {
  z-index: 10; /* Bring active view to front */
  display: flex !important;
}

.hidden {
  display: none !important;
}

/* Headers */
.ios-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background-color: var(--ios-bg);
  /* backdrop-filter: blur(20px); */
  position: sticky;
  top: 0;
  z-index: 10;
}

.ios-header h1 {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
}

.header-btn {
  background: none;
  border: none;
  color: var(--ios-blue);
  font-size: 17px;
  cursor: pointer;
  padding: 8px 0;
}

.header-btn.icon-btn {
  display: flex;
  align-items: center;
}

/* Keypad View */
#keypadView {
  background-color: #fff; /* White for keypad */
}
.app-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}

.top-bar {
  display: flex;
  justify-content: space-between;
  padding: 16px;
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  align-items: center;
  position: relative;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  z-index: 2;
}

/* Call Method Switch (Top Bar) */
.call-method-switch {
  display: flex;
  background: #e5e5ea;
  padding: 2px;
  border-radius: 8px;
  height: 36px;
  align-items: center;

  /* Center absolutely */
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
}

/* Login Button Top */
.login-btn-top {
  font-size: 12px;
  width: 110px;
  padding: 6px 12px;
  background: #f2f2f7;
  border-radius: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;

  /* Truncation */
  max-width: 110px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  z-index: 2;
  height: 36px;
}

/* Tooltip styles */
.method-btn[title]:hover::after {
  content: attr(title);
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 8px;
  padding: 4px 8px;
  background-color: rgba(0, 0, 0, 0.8);
  color: #fff;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
}

.method-btn {
  border: none;
  background: none;
  width: 40px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #8e8e93;
  transition: all 0.2s;
  position: relative;
}

.method-btn:hover {
  background-color: rgba(0, 0, 0, 0.05);
  color: #555;
}

.method-btn.active {
  background: #fff;
  color: #007aff; /* iOS Blue */
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.display-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-top: 40px;
  padding-bottom: 40px;
  min-height: 120px;
}

.phone-number {
  font-size: 36px;
  font-weight: 600;
  color: #000;
  height: 45px;
}

.status-text {
  font-size: 20px; /* Larger placeholder */
  color: #c7c7cc; /* iOS Placeholder Grey */
  margin-top: 8px;
  min-height: 20px;
  font-weight: 400;
}

.keypad {
  width: 100%;
  max-width: 340px; /* Constrain width so buttons aren't too far apart */
  margin: 0 auto 20px auto;
  padding: 0 20px;
}

.row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
}

.key {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background-color: #e5e5e5;
  border: none;
  font-size: 28px;
  color: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.1s;
  user-select: none;
}

.key:active,
.key.active-state {
  background-color: #bbb;
}

.key span {
  font-size: 10px;
  font-weight: 600;
  color: #000;
  margin-top: -2px;
  letter-spacing: 1px;
}

.action-row {
  align-items: center;
  margin-top: 10px;
}

.call-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background-color: var(--ios-green);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s;
}

.call-btn:active {
  transform: scale(0.95);
  opacity: 0.9;
}

.hangup-btn {
  background-color: var(--ios-red);
}

.backspace-btn {
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  font-size: 24px;
  color: #aaa;
  cursor: pointer;
  visibility: hidden;
}
.placeholder {
  width: 72px;
}

/* Active Call View */
.active-call-theme {
  background: radial-gradient(
    circle at center,
    #2c3e50 0%,
    #000000 100%
  ) !important;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  height: 100%;
  width: 100%;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding-top: 60px;
  padding-bottom: 40px;
}

.active-call-content {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.call-info {
  text-align: center;
  margin-bottom: 40px;
}

.call-name {
  font-size: 32px;
  font-weight: 500;
  margin-bottom: 8px;
}

.call-status {
  font-size: 18px;
  color: #ccc;
  margin-bottom: 8px;
}
.call-timer {
  font-size: 20px;
  color: #fff;
}

.pickup-msg {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 40px;
}

.pulse-ring {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.3);
  animation: pulse 2s infinite;
  margin-bottom: 20px;
}

@keyframes pulse {
  0% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.2);
    opacity: 0.1;
  }
  100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
}

.sub-text {
  font-size: 14px;
  color: #999;
  margin-top: 5px;
}

.cancel-call-btn {
  margin-top: 30px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #fff;
  padding: 10px 30px;
  border-radius: 20px;
  font-size: 16px;
  cursor: pointer;
}

.call-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  width: 100%;
  max-width: 320px;
  padding: 0 20px;
  margin-top: auto;
  margin-bottom: 40px;
}

.control-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.call-control-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

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

.control-item span {
  font-size: 12px;
  color: #fff;
}

.call-end-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background-color: var(--ios-red);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* DEBRIEF VIEW STYLES (Bottom Sheet) */
.backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 40;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  will-change: opacity;
}

.backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

.bottom-sheet-view {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: #fff;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  z-index: 50;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  max-height: 90%;
  overflow: hidden;
  will-change: transform;
  touch-action: pan-y;
}

.bottom-sheet-view.active {
  transform: translateY(0);
  display: flex !important;
}

.sheet-handle-bar {
  width: 100%;
  padding: 12px 0;
  display: flex;
  justify-content: center;
  flex-shrink: 0;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

.sheet-handle-bar:active {
  cursor: grabbing;
}

.sheet-handle {
  width: 36px;
  height: 5px;
  background-color: #e5e5ea;
  border-radius: 2.5px;
  transition: background-color 0.2s;
}

.sheet-handle-bar:active .sheet-handle {
  background-color: #d1d1d6;
}

.debrief-header {
  padding: 0 20px 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #f2f2f7;
}

.debrief-header h1 {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
}

.debrief-content {
  padding: 30px 20px;
  padding-bottom: calc(30px + env(safe-area-inset-bottom, 20px));
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.debrief-status-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.status-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}

.status-icon.loading {
  background-color: #f2f2f7;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-left-color: var(--ios-blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.status-icon.success {
  background-color: var(--ios-green);
  color: white;
}

.status-icon.error {
  background-color: var(--ios-red);
  color: white;
}

.debrief-status-container h2 {
  font-size: 22px;
  font-weight: 600;
  margin: 0;
}

.debrief-status-container p {
  font-size: 16px;
  color: var(--ios-text-secondary);
  margin: 0;
  line-height: 1.4;
  max-width: 280px;
}

.debrief-cta-container {
  width: 100%;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.debrief-cta-container.hidden {
  opacity: 0;
  pointer-events: none;
  display: none !important;
}

/* Settings & Login Modal Overlay */
#settingsModal,
#loginModal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 200;
  display: flex;
  justify-content: center;
  align-items: center;
}

#loginModal {
  z-index: 9999;
}

.modal-content {
  background: #fff;
  padding: 24px;
  border-radius: 16px;
  width: 85%;
  max-width: 320px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

/* Login Modal Styles */
.login-content {
  background: #131313; /* Dark background */
  color: #fff;
  max-width: 400px;
  padding: 40px;
  border: 1px solid #333;
}

.login-content h2 {
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 24px;
  font-weight: 600;
}

.login-content .subtitle {
  color: #999;
  font-size: 14px;
  margin-bottom: 30px;
}

.login-content .link {
  color: #8645ff;
  text-decoration: none;
}

.social-login {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.social-btn {
  flex: 1;
  background: #2a2a2a;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 10px;
  color: #fff;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s;
}

.social-btn:hover {
  background: #333;
}

.divider {
  display: flex;
  align-items: center;
  color: #666;
  font-size: 12px;
  margin: 20px 0;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #333;
}

.divider::before {
  margin-right: 10px;
}

.divider::after {
  margin-left: 10px;
}

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

.form-group label {
  display: block;
  color: #ccc;
  font-size: 12px;
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  background: #1e1e1e;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 12px;
  color: #fff;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: #8645ff;
}

.primary-btn {
  background: #6534ff;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.primary-btn:hover {
  background: #5025d1;
}

.full-width {
  width: 100%;
}

.sso-link,
.forgot-password {
  margin-top: 15px;
  font-size: 13px;
}

.sso-link a,
.forgot-password a {
  color: #999;
  text-decoration: none;
}

.sso-link a:hover,
.forgot-password a:hover {
  color: #fff;
}

.error-text {
  color: #ff3b30;
  font-size: 13px;
  margin-top: 15px;
  background: rgba(255, 59, 48, 0.1);
  padding: 10px;
  border-radius: 6px;
}

/* Settings Toggle */
.toggle-btn {
  transition: all 0.2s;
}
.toggle-btn.active {
  background-color: var(--ios-blue) !important;
  color: #fff !important;
  border-color: var(--ios-blue) !important;
}
