/* ── Base App Styles & Modal / Drawer Overlays ─────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  background: var(--tg-sidebar);
}
body.call-app .auth-wrap { display: none !important; }
body:not(.call-app) .shell { display: none !important; }

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.brand-logo {
  width: 100px;
  height: 100px;
  object-fit: contain;
}
.brand-name {
  font-size: 26px;
  font-weight: 700;
  color: var(--tg-text);
}
.brand-name span {
  color: var(--tg-primary);
}

.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--tg-set-card);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--tg-shadow-md);
  border: 1px solid var(--tg-divider);
}

.tabs {
  display: flex;
  border-bottom: 2px solid var(--tg-divider);
  margin-bottom: 20px;
}
.tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: var(--tg-hint);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.tab.active {
  color: var(--tg-primary);
  border-bottom-color: var(--tg-primary);
}

.auth-form .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.auth-form .field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--tg-hint);
}
.auth-form .field input {
  height: 44px;
  background: var(--tg-search);
  border-radius: 10px;
  padding: 0 14px;
  font-size: 15px;
  color: var(--tg-text);
  border: 2px solid transparent;
}
.auth-form .field input:focus {
  background: var(--tg-sidebar);
  border-color: var(--tg-primary);
}

.auth-accounts {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--tg-divider);
}
.auth-accounts-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--tg-hint);
  margin-bottom: 10px;
}
.auth-acc-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 8px;
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  border: 0;
  background: transparent;
  color: inherit;
}
.auth-acc-row:hover,
.auth-acc-row:active {
  background: var(--tg-search);
}
.auth-acc-meta {
  min-width: 0;
  flex: 1;
}
.auth-acc-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--tg-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.auth-acc-user {
  font-size: 13px;
  color: var(--tg-hint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.auth-cancel-add {
  width: 100%;
  margin-top: 12px;
}

.btn-primary {
  height: 44px;
  background: var(--tg-primary);
  color: #ffffff;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  width: 100%;
  margin-top: 14px;
}
.btn-primary:hover {
  background: var(--tg-primary-hover);
}
.btn-primary:active {
  transform: scale(0.98);
}

.btn-ghost {
  height: 36px;
  padding: 0 14px;
  background: transparent;
  color: var(--tg-primary);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-ghost:hover {
  background: var(--tg-hover);
}

.btn-danger {
  background: var(--tg-danger);
  color: #ffffff;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.err {
  color: var(--tg-danger);
  font-size: 13px;
  margin-top: 8px;
  font-weight: 500;
}

/* ── Modal Dialog System ────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: tgPopIn 0.15s ease;
}

.modal-card {
  width: 100%;
  max-width: 440px;
  background: var(--tg-set-card);
  border-radius: 16px;
  box-shadow: var(--tg-shadow-lg);
  overflow: hidden;
  border: 1px solid var(--tg-divider);
  display: flex;
  flex-direction: column;
}

.modal-head {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--tg-divider);
}
.modal-head h3 {
  font-size: 17px;
  font-weight: 600;
}

.modal-body {
  padding: 20px;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-actions {
  padding: 12px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--tg-divider);
}

/* ── Toast Notification System ──────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.82);
  color: #ffffff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--tg-shadow-md);
  z-index: 13000;
  backdrop-filter: blur(8px);
  animation: tgPopIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

/* ── Left Navigation Drawer (Side Menu) ─────────────────────────── */
.drawer-bg {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 40;
}

.rail {
  position: fixed !important;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(300px, 86vw) !important;
  transform: translateX(-105%);
  transition: transform 0.22s cubic-bezier(0.33, 1, 0.68, 1);
  background: var(--tg-sidebar) !important;
  border-right: none !important;
  display: flex;
  flex-direction: column;
  z-index: 45 !important;
  box-shadow: var(--tg-shadow-lg);
  overflow-y: auto;
}
.rail.open {
  transform: translateX(0);
}

.drawer-hero {
  background: linear-gradient(135deg, #3390ec, #5b8def);
  color: #ffffff;
  padding: 22px 20px 18px;
  display: flex;
  flex-direction: column;
  position: relative;
  flex-shrink: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Roboto", "Segoe UI", "Apple Color Emoji", sans-serif;
}
[data-theme="dark"] .drawer-hero {
  background: linear-gradient(135deg, #2b5278, #17212b);
}

.drawer-hero .av {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  font-size: 26px;
  font-weight: 600;
  color: #ffffff;
}
.drawer-hero .name {
  font-family: -apple-system, BlinkMacSystemFont, "Roboto", "Segoe UI", "Apple Color Emoji", sans-serif;
  font-size: 16px;
  font-weight: 600;
  margin-top: 12px;
  letter-spacing: -0.2px;
  line-height: 1.3;
  color: #ffffff;
}
.drawer-hero .uname {
  font-family: -apple-system, BlinkMacSystemFont, "Roboto", "Segoe UI", "Apple Color Emoji", sans-serif;
  font-size: 13px;
  font-weight: 400;
  opacity: 0.85;
  margin-top: 2px;
  line-height: 1.3;
  color: rgba(255, 255, 255, 0.9);
}

.rail-btn {
  display: flex;
  align-items: center;
  height: 48px;
  min-height: 48px;
  padding: 0 20px;
  gap: 22px;
  color: var(--tg-text);
  font-family: -apple-system, BlinkMacSystemFont, "Roboto", "Segoe UI", "Apple Color Emoji", sans-serif;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.15px;
  line-height: 1.4;
  cursor: pointer;
  transition: background 0.12s ease;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
}
.rail-btn:hover {
  background: var(--tg-hover);
}
.rail-btn svg {
  width: 22px !important;
  height: 22px !important;
  max-width: 22px !important;
  max-height: 22px !important;
  color: var(--tg-hint);
  flex-shrink: 0 !important;
  display: block;
}
.rail-btn span {
  font-family: -apple-system, BlinkMacSystemFont, "Roboto", "Segoe UI", "Apple Color Emoji", sans-serif;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.15px;
  color: var(--tg-text);
  line-height: 1.4;
  flex: 1;
  text-align: left;
}

/* ── Lightbox / Media Viewer ────────────────────────────────────── */
.media-view {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.94);
  backdrop-filter: blur(12px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.media-view img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

@media (max-width: 900px) {
  .auth-wrap {
    justify-content: flex-start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: calc(16px + env(safe-area-inset-top, 0px)) 16px calc(24px + env(safe-area-inset-bottom, 0px));
    min-height: 100dvh;
  }
  .auth-form .field input,
  .auth-form .field textarea,
  .modal-card input,
  .modal-card textarea {
    font-size: 16px;
  }
  .toast {
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    max-width: calc(100% - 32px);
    left: 50%;
  }
  .rail {
    width: min(300px, 92%) !important;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .drawer-hero {
    padding-top: calc(18px + env(safe-area-inset-top, 0px));
  }
  .modal-card {
    max-width: calc(100% - 24px);
    max-height: calc(100dvh - 32px);
  }
  .media-view img {
    max-width: calc(100% - 24px);
    max-height: calc(100dvh - 48px);
  }
}

@media (max-width: 420px) {
  .brand-logo {
    width: 64px;
    height: 64px;
  }
  .brand-name {
    font-size: 22px;
  }
  .auth-card {
    padding: 18px 16px;
  }
}
