/* ─────────────────────────────────────────────────────────────
   CaptionMate — iOS iPhone Light Theme
   Apple Human Interface Guidelines Compliant UI
───────────────────────────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  /* iOS Light Palette */
  --ios-bg             : #F2F2F7;
  --ios-card           : #FFFFFF;
  --ios-secondary-bg   : #E5E5EA;
  --ios-tertiary-bg    : #F7F7F9;
  --ios-key-bg         : #E5E5EA;
  --ios-key-active     : #D1D1D6;
  --ios-key-text       : #000000;
  
  --ios-blue           : #007AFF;
  --ios-blue-light     : rgba(0, 122, 255, 0.12);
  --ios-green          : #34C759;
  --ios-green-light    : rgba(52, 199, 89, 0.12);
  --ios-red            : #FF3B30;
  --ios-red-light      : rgba(255, 59, 48, 0.12);
  --ios-amber          : #FF9500;
  
  --ios-text-primary   : #000000;
  --ios-text-secondary : #8E8E93;
  --ios-text-tertiary  : #C7C7CC;
  
  --ios-separator      : rgba(60, 60, 67, 0.14);
  --ios-shadow         : 0 4px 16px rgba(0, 0, 0, 0.05);
  --ios-card-shadow    : 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.03);
  
  --header-h           : 52px;
  --tabbar-h           : 62px;
  --sidebar-w          : 220px;
  
  --font-family        : -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", sans-serif;
}

html, body {
  width: 100%;
  max-width: 100vw;
  height: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0;
  background-color: var(--ios-bg);
  color: var(--ios-text-primary);
  font-family: var(--font-family);
  overflow: hidden;
  overflow-x: hidden;
  touch-action: pan-y;
  -webkit-font-smoothing: antialiased;
}

/* ── Screen Management ─────────────────────────────────────── */
.screen {
  width: 100%;
  max-width: 100vw;
  height: 100%;
  height: 100dvh;
  position: fixed;
  inset: 0;
  overflow: hidden;
  overflow-x: hidden;
}
.screen.active { display: flex; }
.screen.hidden { display: none !important; }

/* ── iOS Utility Helpers ───────────────────────────────────── */
.hidden { display: none !important; }
.text-blue { color: var(--ios-blue) !important; }
.text-green { color: var(--ios-green) !important; }
.text-red { color: var(--ios-red) !important; }

/* ════════════════════════════════════════════════════════════
   1. LOGIN SCREEN (Apple ID / iOS Settings Style)
════════════════════════════════════════════════════════════ */
#loginScreen {
  align-items: center;
  justify-content: center;
  background: var(--ios-bg);
  padding: 16px;
  overflow-y: auto;
  overflow-x: hidden;
}

.login-wrap {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.logo-box {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.logo-icon-ios {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: linear-gradient(145deg, #007AFF, #0056B3);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(0, 122, 255, 0.28);
  margin-bottom: 14px;
}
.logo-icon-ios svg {
  width: 36px;
  height: 36px;
}

.logo-box h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--ios-text-primary);
}

.logo-box .subtitle {
  font-size: 14px;
  color: var(--ios-text-secondary);
  margin-top: 4px;
}

.ios-card {
  width: 100%;
  background: var(--ios-card);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--ios-card-shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
  border: 1px solid var(--ios-separator);
}

.alert-error {
  background: var(--ios-red-light);
  border-left: 3px solid var(--ios-red);
  color: var(--ios-red);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
}

.ios-input-group {
  background: var(--ios-tertiary-bg);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--ios-separator);
}

.ios-input-row {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  gap: 12px;
}

.ios-input-row label {
  font-size: 14px;
  font-weight: 500;
  color: var(--ios-text-secondary);
  width: 72px;
  flex-shrink: 0;
}

.ios-input-row input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 15px;
  color: var(--ios-text-primary);
  font-family: inherit;
}

.ios-input-row input::placeholder {
  color: var(--ios-text-tertiary);
}

.ios-divider {
  height: 1px;
  background: var(--ios-separator);
  margin-left: 14px;
}

.pw-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  position: relative;
}

.pw-toggle {
  background: none;
  border: none;
  color: var(--ios-text-secondary);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
}

.btn-ios-primary {
  background: var(--ios-blue);
  color: #FFFFFF;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: opacity 0.15s, transform 0.1s;
}
.btn-ios-primary:active {
  opacity: 0.85;
  transform: scale(0.98);
}
.btn-ios-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.login-footer {
  text-align: center;
  font-size: 11px;
  color: var(--ios-text-secondary);
  line-height: 1.4;
}

.login-options-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
}

.ios-link-btn {
  background: none;
  border: none;
  color: var(--ios-blue);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  padding: 4px 0;
}
.ios-link-btn:hover { text-decoration: underline; }
.ios-link-btn.admin-link {
  color: var(--ios-text-secondary);
}
.ios-link-btn.admin-link:hover {
  color: var(--ios-text-primary);
}


/* ════════════════════════════════════════════════════════════
   2. MAIN APP SHELL
════════════════════════════════════════════════════════════ */
#appScreen {
  flex-direction: column;
  background: var(--ios-bg);
  height: 100%;
  height: 100dvh;
}

/* iOS Top Header / Status Bar */
.ios-header {
  height: var(--header-h);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--ios-separator);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  z-index: 20;
}

/* ── PWA Install Header Banner ─────────────────────────────── */
.pwa-banner {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--ios-separator);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
  animation: slideDownBanner 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 19;
  flex-shrink: 0;
}

.pwa-banner.hidden {
  display: none !important;
}

@keyframes slideDownBanner {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

.pwa-banner-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.pwa-icon-circle {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--ios-green);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(52, 199, 89, 0.35);
}

.pwa-text-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.pwa-headline {
  font-size: 13px;
  font-weight: 700;
  color: var(--ios-text-primary);
  line-height: 1.2;
}

.pwa-caption {
  font-size: 11px;
  color: var(--ios-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pwa-banner-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-pwa-action {
  background: var(--ios-green);
  color: #FFFFFF;
  border: none;
  border-radius: 16px;
  padding: 6px 13px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 2px 8px rgba(52, 199, 89, 0.35);
  transition: transform 0.1s, background 0.15s;
}

.btn-pwa-action:hover {
  background: #2ebd52;
}
.btn-pwa-action:active {
  transform: scale(0.95);
}

.btn-pwa-dismiss {
  background: none;
  border: none;
  color: var(--ios-text-tertiary);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}
.btn-pwa-dismiss:hover {
  color: var(--ios-text-primary);
  background: var(--ios-secondary-bg);
}
.btn-pwa-dismiss:active {
  transform: scale(0.9);
}

.header-left { display: flex; align-items: center; }
.brand-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--ios-text-primary);
}

.header-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.engine-pill {
  background: var(--ios-secondary-bg);
  border-radius: 20px;
  padding: 4px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ios-text-secondary);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.dot-idle   { background: var(--ios-text-secondary); }
.dot-ready  { background: var(--ios-green); box-shadow: 0 0 6px rgba(52, 199, 89, 0.6); }
.dot-busy   { background: var(--ios-amber); }
.dot-error  { background: var(--ios-red); }

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

.user-chip {
  font-size: 13px;
  font-weight: 500;
  color: var(--ios-text-secondary);
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn-ghost {
  background: none;
  border: none;
  color: var(--ios-text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  transition: background 0.15s, color 0.15s;
}
.icon-btn-ghost:hover {
  background: var(--ios-secondary-bg);
  color: var(--ios-red);
}

/* App Body Grid */
.app-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  max-width: 100vw;
  width: 100%;
}

/* Sidebar for Tablet / Desktop */
.sidebar {
  width: var(--sidebar-w);
  background: var(--ios-card);
  border-right: 1px solid var(--ios-separator);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  gap: 6px;
  flex-shrink: 0;
}

.side-btn {
  background: transparent;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
  font-weight: 500;
  color: var(--ios-text-secondary);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}
.side-btn:hover {
  background: var(--ios-tertiary-bg);
  color: var(--ios-text-primary);
}
.side-btn.active {
  background: var(--ios-blue-light);
  color: var(--ios-blue);
  font-weight: 600;
}
.side-icon {
  display: flex;
  align-items: center;
}

/* Main Content Area */
.content {
  flex: 1;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  max-width: 100%;
  width: 100%;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

/* Tabs */
.tab {
  display: none;
  width: 100%;
  max-width: 100%;
}
.tab.active {
  display: block;
}

/* ════════════════════════════════════════════════════════════
   3. iOS DIALER (KEYPAD) TAB
════════════════════════════════════════════════════════════ */
.ios-dialer-container {
  width: 100%;
  max-width: 340px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-bottom: 12px;
}

/* Info Pill Bar */
.ios-info-card {
  width: 100%;
  background: var(--ios-card);
  border-radius: 12px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--ios-card-shadow);
  border: 1px solid var(--ios-separator);
}

.info-pill-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  text-align: center;
}

.pill-title {
  font-size: 9.5px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.4px;
  color: var(--ios-text-secondary);
}

.pill-value {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ios-text-primary);
  margin-top: 1px;
}
.pill-value.badge-green {
  color: var(--ios-green);
}

.info-pill-divider {
  width: 1px;
  height: 20px;
  background: var(--ios-separator);
}

/* Big Display Screen */
.ios-display-wrap {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin: 2px 0;
}

#dialInput {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  font-size: 26px;
  font-weight: 500;
  color: var(--ios-text-primary);
  text-align: center;
  letter-spacing: 1.2px;
  font-family: var(--font-family);
  padding: 0 36px;
}
#dialInput::placeholder {
  color: var(--ios-text-tertiary);
  font-size: 20px;
  letter-spacing: 0px;
}

.ios-country-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 122, 255, 0.1);
  border: 1px solid rgba(0, 122, 255, 0.25);
  color: var(--ios-blue);
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  margin-bottom: 2px;
  animation: fadeInCountry 0.15s ease-out;
}
.ios-country-badge.hidden {
  display: none !important;
}
@keyframes fadeInCountry {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.backspace-btn {
  position: absolute;
  right: 6px;
  background: none;
  border: none;
  color: var(--ios-text-secondary);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: transform 0.1s, color 0.15s;
  z-index: 5;
}
.backspace-btn:active {
  transform: scale(0.9);
  color: var(--ios-text-primary);
}

/* Authentic iOS Dial Pad Grid (3 Columns) */
.ios-keypad {
  display: grid !important;
  grid-template-columns: repeat(3, 1fr) !important;
  gap: 8px 18px !important;
  width: 100%;
  max-width: 270px;
  margin: 4px auto 0 auto;
}


.ios-key {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--ios-key-bg);
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  user-select: none;
  -webkit-user-select: none;
  transition: background-color 0.08s, transform 0.06s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.ios-key:active {
  background: var(--ios-key-active);
  transform: scale(0.94);
}

.ios-key .digit {
  font-size: 26px;
  font-weight: 400;
  color: var(--ios-key-text);
  line-height: 1;
}

.ios-key .digit.star {
  font-size: 30px;
  line-height: 0.9;
  margin-top: 3px;
}

.ios-key .letters {
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 1.2px;
  color: var(--ios-text-secondary);
  margin-top: 1px;
  text-transform: uppercase;
}

/* Call Action Button Row */
.ios-call-action-row {
  width: 100%;
  max-width: 270px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 4px;
}

.action-spacer {
  width: 64px;
}

.btn-call-ios {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--ios-green);
  color: #FFFFFF;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(52, 199, 89, 0.4);
  transition: transform 0.08s, opacity 0.1s;
}

.btn-call-ios:active {
  transform: scale(0.92);
  opacity: 0.9;
}
.btn-call-ios:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Utility Bar */
.ios-util-bar {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 4px;
  width: 100%;
}

.ios-chip-btn {
  background: var(--ios-card);
  border: 1px solid var(--ios-separator);
  border-radius: 16px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--ios-text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  box-shadow: var(--ios-card-shadow);
  transition: all 0.15s;
}
.ios-chip-btn:hover {
  background: var(--ios-secondary-bg);
  color: var(--ios-text-primary);
}

.ios-status-text {
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  min-height: 16px;
  margin-top: 2px;
}


/* ════════════════════════════════════════════════════════════
   4. iOS RECENTS & SETTINGS PAGES
════════════════════════════════════════════════════════════ */
.ios-tab-page {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 24px;
}

.ios-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 8px 4px;
}

.ios-page-header h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.ios-btn-text {
  background: none;
  border: none;
  color: var(--ios-blue);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

/* Grouped Lists (iOS Settings & Contacts style) */
.ios-section-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--ios-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 12px 2px 12px;
}

.ios-grouped-card, .ios-grouped-list {
  background: var(--ios-card);
  border-radius: 12px;
  border: 1px solid var(--ios-separator);
  box-shadow: var(--ios-card-shadow);
  overflow: hidden;
}

.ios-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 1px solid var(--ios-separator);
  font-size: 15px;
}
.ios-row:last-child {
  border-bottom: none;
}

.row-label {
  font-weight: 500;
  color: var(--ios-text-primary);
}

.row-value {
  font-weight: 400;
  color: var(--ios-text-secondary);
  text-align: right;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--ios-separator);
  gap: 12px;
  transition: background 0.15s;
}
.history-item:last-child { border-bottom: none; }
.history-item:hover {
  background: var(--ios-tertiary-bg);
}

.h-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.h-number {
  font-size: 16px;
  font-weight: 600;
  color: var(--ios-text-primary);
  letter-spacing: -0.2px;
}

.h-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
}

.h-time {
  color: var(--ios-text-secondary);
}

.h-duration {
  font-weight: 600;
  color: var(--ios-text-primary);
  background: var(--ios-secondary-bg);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 11px;
}

.h-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.h-badge.answered {
  background: var(--ios-green-light);
  color: var(--ios-green);
}
.h-badge.failed {
  background: var(--ios-red-light);
  color: var(--ios-red);
}
.h-badge.calling {
  background: var(--ios-blue-light);
  color: var(--ios-blue);
}

.h-error-msg {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #DC2626;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  padding: 3px 8px;
  border-radius: 8px;
  font-weight: 500;
  margin-top: 4px;
  max-width: 100%;
  word-break: break-word;
  line-height: 1.3;
}

/* Floating iOS Toast Notification Banner */
.ios-toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%) translateY(-30px);
  background: rgba(15, 23, 42, 0.92);
  color: #FFFFFF;
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  padding: 10px 18px;
  border-radius: 22px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  z-index: 2500;
  opacity: 0;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.24s ease;
  pointer-events: none;
  max-width: 88%;
  text-align: center;
  box-sizing: border-box;
}

.ios-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.ios-toast.error {
  background: rgba(220, 38, 38, 0.94);
  box-shadow: 0 8px 24px rgba(220, 38, 38, 0.35);
}

.ios-toast.success {
  background: rgba(22, 163, 74, 0.94);
  box-shadow: 0 8px 24px rgba(22, 163, 74, 0.35);
}

.ios-toast.warn {
  background: rgba(217, 119, 6, 0.94);
  box-shadow: 0 8px 24px rgba(217, 119, 6, 0.35);
}


.btn-recents-call {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--ios-green);
  color: #FFFFFF;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(52, 199, 89, 0.35);
  flex-shrink: 0;
  transition: transform 0.08s, opacity 0.1s;
}
.btn-recents-call:active {
  transform: scale(0.92);
  opacity: 0.9;
}
.btn-recents-call svg {
  width: 18px;
  height: 18px;
}


.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--ios-text-secondary);
}
.empty-icon { font-size: 36px; margin-bottom: 8px; }

.ios-logout-wrap {
  margin-top: 12px;
  padding: 0 4px;
}

.ios-logout-btn {
  width: 100%;
  background: var(--ios-card);
  border: 1px solid var(--ios-separator);
  border-radius: 12px;
  color: var(--ios-red);
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--ios-card-shadow);
  transition: background 0.15s;
}
.ios-logout-btn:active {
  background: var(--ios-red-light);
}

/* ════════════════════════════════════════════════════════════
   5. iOS BOTTOM TAB BAR (MOBILE ONLY)
════════════════════════════════════════════════════════════ */
.bottomnav {
  display: none;
  height: var(--tabbar-h);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid var(--ios-separator);
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 30;
}

.bot-btn {
  flex: 1;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--ios-text-secondary);
  font-size: 10px;
  font-weight: 500;
  padding: 6px 0;
  transition: color 0.15s, transform 0.1s;
}

.bot-btn:active { transform: scale(0.95); }
.bot-btn.active {
  color: var(--ios-blue);
  font-weight: 600;
}

/* ════════════════════════════════════════════════════════════
   6. TRANSPARENT CONNECTING CALL MODAL (FROSTED GLASS)
════════════════════════════════════════════════════════════ */
.connecting-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  z-index: 950;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeInConnecting 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.connecting-overlay.hidden {
  display: none !important;
}

@keyframes fadeInConnecting {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.connecting-card {
  width: 100%;
  max-width: 310px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(35px) saturate(190%);
  -webkit-backdrop-filter: blur(35px) saturate(190%);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 24px;
  padding: 26px 20px 20px 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22), 0 4px 14px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  box-sizing: border-box;
}

.connecting-loader-wrap {
  position: relative;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pulsing-halo {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(52, 199, 89, 0.35) 0%, rgba(52, 199, 89, 0) 70%);
  animation: pulseHalo 1.8s ease-in-out infinite;
}

@keyframes pulseHalo {
  0% { transform: scale(0.92); opacity: 0.5; }
  50% { transform: scale(1.18); opacity: 1; }
  100% { transform: scale(0.92); opacity: 0.5; }
}

.spinning-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3.5px solid rgba(52, 199, 89, 0.16);
  border-top-color: var(--ios-green);
  border-right-color: var(--ios-green);
  animation: spinHalo 0.85s cubic-bezier(0.5, 0.1, 0.4, 0.9) infinite;
}

@keyframes spinHalo {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.connecting-center-icon {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--ios-green);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(52, 199, 89, 0.4);
  z-index: 2;
}

.connecting-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: 100%;
}

.connecting-pill-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--ios-green);
  background: var(--ios-green-light);
  padding: 3px 9px;
  border-radius: 12px;
  text-transform: uppercase;
}

.connecting-phone-text {
  font-size: 20px;
  font-weight: 700;
  color: var(--ios-text-primary);
  letter-spacing: -0.3px;
  word-break: break-word;
}

.connecting-sub-status {
  font-size: 13px;
  font-weight: 500;
  color: var(--ios-text-secondary);
}

.btn-cancel-connecting {
  background: var(--ios-red-light);
  border: 1px solid rgba(255, 59, 48, 0.2);
  color: var(--ios-red);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
  width: 100%;
  justify-content: center;
}

.btn-cancel-connecting:hover {
  background: rgba(255, 59, 48, 0.2);
}

.btn-cancel-connecting:active {
  transform: scale(0.97);
}

/* ════════════════════════════════════════════════════════════
   7. ACTIVE CALL SCREEN (iOS IN-CALL EXPERIENCE)
════════════════════════════════════════════════════════════ */
.call-overlay {
  position: fixed;
  inset: 0;
  background: rgba(242, 242, 247, 0.95);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}


.ios-incall-view {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 36px;
}

.incall-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.caller-avatar-circle {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--ios-card);
  border: 1px solid var(--ios-separator);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ios-text-secondary);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
  margin-bottom: 16px;
}

.incall-name {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--ios-text-primary);
}

.incall-status {
  font-size: 14px;
  font-weight: 500;
  color: var(--ios-text-secondary);
  margin-top: 4px;
}

.incall-timer {
  font-size: 32px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ios-green);
  margin-top: 8px;
}

.incall-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px 20px;
  width: 100%;
  max-width: 290px;
  margin: 0 auto;
  justify-items: center;
}

.incall-circle-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--ios-text-primary);
  user-select: none;
}

.btn-bubble {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--ios-card);
  border: 1px solid var(--ios-separator);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ios-text-primary);
  box-shadow: var(--ios-card-shadow);
  transition: all 0.15s;
}

.incall-circle-btn:active .btn-bubble {
  transform: scale(0.92);
  background: var(--ios-secondary-bg);
}

.incall-circle-btn.active .btn-bubble {
  background: #1C1C1E;
  color: #FFFFFF;
  border-color: #1C1C1E;
}

.incall-circle-btn.speaker-on .btn-bubble {
  background: var(--ios-blue);
  color: #FFFFFF;
  border-color: var(--ios-blue);
}

.incall-circle-btn.silenced .btn-bubble {
  background: var(--ios-red);
  color: #FFFFFF;
  border-color: var(--ios-red);
}


.btn-endcall-ios {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--ios-red);
  color: #FFFFFF;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(255, 59, 48, 0.4);
  transition: transform 0.08s;
}
.btn-endcall-ios:active {
  transform: scale(0.92);
}

/* ════════════════════════════════════════════════════════════
   7. MINIMALIST TERMINAL LOG SHEET
════════════════════════════════════════════════════════════ */
#logToggleWrap {
  position: fixed;
  bottom: 74px;
  right: 14px;
  z-index: 50;
}

#logToggleBtn {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid var(--ios-separator);
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ios-text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--ios-card-shadow);
}

.log-panel {
  position: fixed;
  bottom: 124px;
  right: 14px;
  width: 340px;
  max-height: 250px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid var(--ios-separator);
  border-radius: 16px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  z-index: 99;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--ios-separator);
  font-size: 12px;
  font-weight: 600;
}

.log-title {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot-green {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ios-green);
}

.log-btn-mini {
  background: none;
  border: none;
  color: var(--ios-blue);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 6px;
}

.log-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  font-family: ui-monospace, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #FAFAFC;
}

.log-line { color: var(--ios-text-secondary); }
.log-line.ok   { color: var(--ios-green); font-weight: 600; }
.log-line.err  { color: var(--ios-red); font-weight: 600; }
.log-line.warn { color: var(--ios-amber); font-weight: 600; }
.log-line.info { color: var(--ios-blue); font-weight: 600; }

/* ════════════════════════════════════════════════════════════
   8. MOBILE RESPONSIVE MEDIA QUERIES (BALANCED iOS PROPORTIONS)
════════════════════════════════════════════════════════════ */
@media (max-width: 680px) {
  .sidebar { display: none; }
  .bottomnav { display: flex; }
  
  .content {
    padding: 10px 14px;
    padding-bottom: calc(var(--tabbar-h) + 14px);
  }
  
  #logToggleWrap {
    bottom: calc(var(--tabbar-h) + 12px);
    right: 12px;
  }
  
  .log-panel {
    bottom: calc(var(--tabbar-h) + 48px);
    right: 12px;
    left: 12px;
    width: auto;
  }

  .ios-dialer-container {
    padding-top: 4px;
    gap: 8px;
    padding-bottom: 8px;
    max-width: 350px;
  }

  .ios-info-card {
    padding: 8px 12px;
  }

  .ios-display-wrap {
    min-height: 44px;
    margin: 2px 0;
  }

  #dialInput {
    font-size: 27px;
  }

  .ios-util-bar {
    margin-top: 2px;
    gap: 8px;
  }

  .ios-chip-btn {
    padding: 5px 12px;
    font-size: 12px;
  }

  .ios-keypad {
    gap: 10px 20px !important;
    max-width: 280px;
    margin: 6px auto 0 auto;
  }

  .ios-key {
    width: 66px;
    height: 66px;
  }

  .ios-key .digit {
    font-size: 28px;
  }

  .ios-key .digit.star {
    font-size: 32px;
    margin-top: 2px;
  }

  .ios-key .letters {
    font-size: 9px;
    letter-spacing: 1.5px;
  }

  .ios-call-action-row {
    margin-top: 6px;
    max-width: 280px;
  }

  .action-spacer {
    width: 66px;
  }

  .btn-call-ios {
    width: 66px;
    height: 66px;
    box-shadow: 0 4px 16px rgba(52, 199, 89, 0.45);
  }

  .btn-call-ios svg {
    width: 28px;
    height: 28px;
  }

  .ios-status-text {
    font-size: 12px;
    min-height: 16px;
    margin-top: 2px;
  }
}

/* Fallback only for extremely short landscape/small viewports (< 580px height) */
@media (max-height: 580px) and (max-width: 680px) {
  .ios-header {
    height: 42px;
    padding: 0 10px;
  }
  .content {
    padding: 4px 8px;
    padding-bottom: calc(var(--tabbar-h) + 6px);
  }
  .ios-dialer-container {
    gap: 4px;
  }
  .ios-info-card {
    padding: 4px 8px;
  }
  .ios-display-wrap {
    min-height: 34px;
  }
  #dialInput {
    font-size: 22px;
  }
  .ios-keypad {
    gap: 6px 14px !important;
    max-width: 250px;
  }
  .ios-key {
    width: 58px;
    height: 58px;
  }
  .ios-key .digit {
    font-size: 24px;
  }
  .btn-call-ios {
    width: 58px;
    height: 58px;
  }
}

@media (min-width: 681px) {
  #logToggleWrap {
    bottom: 16px;
  }
}


