/* ═══════════════════════════════════════════════════════════════
   Last Seen Online — Phone UI Styles
   ═══════════════════════════════════════════════════════════════ */

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

:root {
  --phone-w: 375px;
  --phone-h: 667px;
  --bezel: 12px;
  --radius: 40px;
  --bg-dark: #0a0a0f;
  --bubble-in: #2a2a3a;
  --bubble-out: #0b84fe;
  --text-primary: #f0f0f5;
  --text-secondary: #8e8e93;
  --text-dim: #636366;
  --accent: #0b84fe;
  --separator: rgba(255,255,255,0.08);
  --screen-bg: #000000;
}

body {
  background: var(--bg-dark);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', sans-serif;
  color: var(--text-primary);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.back-link {
  position: fixed;
  top: 16px;
  left: 16px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  z-index: 1000;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.back-link:hover { opacity: 1; }

.mute-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 50%;
  width: 36px; height: 36px;
  font-size: 16px;
  cursor: pointer;
  z-index: 1000;
  color: var(--text-primary);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.mute-btn:hover { background: rgba(255,255,255,0.15); }

/* ── Phone Frame ── */
#phone-container {
  display: flex;
  justify-content: center;
  align-items: center;
}

#phone {
  width: var(--phone-w);
  height: var(--phone-h);
  position: relative;
  filter: drop-shadow(0 20px 60px rgba(0,0,0,0.6));
}

#phone-bezel {
  width: 100%;
  height: 100%;
  background: #1a1a1a;
  border-radius: var(--radius);
  padding: var(--bezel);
  position: relative;
  overflow: hidden;
}

#phone-notch {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 150px;
  height: 28px;
  background: #1a1a1a;
  border-radius: 0 0 18px 18px;
  z-index: 50;
}

#phone-screen {
  width: 100%;
  height: 100%;
  background: var(--screen-bg);
  border-radius: calc(var(--radius) - var(--bezel));
  overflow: hidden;
  position: relative;
}

/* ── Screens ── */
.screen {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: none;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.screen.active {
  display: flex;
  opacity: 1;
}
.screen.slide-in {
  display: flex;
  animation: slideIn 0.3s ease forwards;
}
.screen.slide-out {
  animation: slideOut 0.3s ease forwards;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes slideOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(-30%); opacity: 0; }
}

/* ── Lock Screen ── */
#lockScreen {
  background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
}

.lock-time {
  font-size: 72px;
  font-weight: 200;
  letter-spacing: -2px;
  margin-bottom: 4px;
}
.lock-date {
  font-size: 16px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-bottom: 40px;
}

.lock-notifications {
  width: 85%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: auto;
  margin-top: 20px;
  max-height: 200px;
  overflow: hidden;
}
.lock-notif {
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(20px);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}
.lock-notif-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600;
  flex-shrink: 0;
}
.lock-notif-text { flex: 1; }
.lock-notif-text strong { display: block; font-size: 13px; }
.lock-notif-text span { color: var(--text-secondary); font-size: 12px; display: block; margin-top: 2px; }

.lock-swipe {
  margin-top: auto;
  margin-bottom: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  animation: pulse 2s ease-in-out infinite;
}
.lock-swipe span {
  font-size: 13px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.swipe-indicator {
  width: 36px; height: 5px;
  background: rgba(255,255,255,0.4);
  border-radius: 3px;
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-4px); }
}

/* ── Home Screen / Contact List ── */
#homeScreen {
  background: var(--screen-bg);
}
.home-header {
  padding: 44px 16px 8px;
}
.status-bar {
  display: flex;
  justify-content: space-between;
  padding: 4px 4px 8px;
  font-size: 12px;
  color: var(--text-secondary);
}
.home-title {
  font-size: 32px;
  font-weight: 700;
  padding: 4px 0 12px;
}
.contact-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.contact-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--separator);
  cursor: pointer;
  transition: background 0.15s;
}
.contact-item:active {
  background: rgba(255,255,255,0.05);
}
.contact-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 600;
  flex-shrink: 0;
  color: #fff;
}
.contact-info {
  flex: 1;
  min-width: 0;
}
.contact-name {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 2px;
}
.contact-preview {
  font-size: 14px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.contact-meta {
  text-align: right;
  flex-shrink: 0;
}
.contact-time {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.contact-badge {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  margin-left: auto;
}
.contact-badge.hidden { display: none; }
.contact-check {
  font-size: 16px;
  color: #30d158;
  margin-left: auto;
}
.contact-check.hidden { display: none; }

/* ── Chat View ── */
#chatScreen {
  background: var(--screen-bg);
}
.chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 40px 12px 10px;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--separator);
  z-index: 10;
}
.chat-back {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
}
.chat-header-info {
  display: flex;
  align-items: center;
  gap: 8px;
}
.chat-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600;
  color: #fff;
}
.chat-name {
  font-size: 15px;
  font-weight: 600;
}
.chat-last-seen {
  font-size: 11px;
  color: var(--text-dim);
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.chat-input-fake {
  padding: 8px 16px 28px;
  border-top: 1px solid var(--separator);
  font-size: 14px;
  color: var(--text-dim);
}

/* ── Message Bubbles ── */
.msg {
  max-width: 78%;
  padding: 8px 12px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.35;
  word-wrap: break-word;
  animation: bubbleIn 0.25s ease;
  position: relative;
}
@keyframes bubbleIn {
  from { opacity: 0; transform: scale(0.92) translateY(6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.msg-in {
  align-self: flex-start;
  background: var(--bubble-in);
  border-bottom-left-radius: 6px;
  color: var(--text-primary);
}
.msg-out {
  align-self: flex-end;
  background: var(--bubble-out);
  border-bottom-right-radius: 6px;
  color: #fff;
}
.msg-system {
  align-self: center;
  background: none;
  color: var(--text-dim);
  font-size: 12px;
  padding: 8px 0;
  text-align: center;
  max-width: 90%;
}
.msg-timestamp-header {
  align-self: center;
  color: var(--text-dim);
  font-size: 11px;
  padding: 12px 0 4px;
  text-align: center;
}

/* Read receipts */
.msg-read {
  font-size: 11px;
  color: var(--accent);
  text-align: right;
  padding: 1px 4px 0;
  align-self: flex-end;
}
.msg-read.gray { color: var(--text-dim); }
.msg-delivered {
  font-size: 11px;
  color: var(--text-dim);
  text-align: right;
  padding: 1px 4px 0;
  align-self: flex-end;
}

/* Typing Indicator */
.typing-indicator {
  align-self: flex-start;
  background: var(--bubble-in);
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  padding: 12px 16px;
  display: flex;
  gap: 4px;
  align-items: center;
}
.typing-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ── Thought Bubble ── */
.thought-bubble {
  position: absolute;
  bottom: 60px; left: 50%;
  transform: translateX(-50%) scale(0.9);
  background: rgba(45,45,65,0.95);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 14px 18px;
  max-width: 85%;
  font-size: 14px;
  font-style: italic;
  color: rgba(255,255,255,0.8);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s, transform 0.4s;
  z-index: 30;
  text-align: center;
}
.thought-bubble::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px; height: 12px;
  background: rgba(45,45,65,0.95);
  border-radius: 50%;
}
.thought-bubble.visible {
  opacity: 1;
  transform: translateX(-50%) scale(1);
  pointer-events: auto;
}

/* ── Choice Overlay ── */
.choice-overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(20px);
  border-radius: 20px 20px 0 0;
  padding: 20px 16px 32px;
  transform: translateY(100%);
  transition: transform 0.35s ease;
  z-index: 40;
}
.choice-overlay.visible {
  transform: translateY(0);
}
.choice-prompt {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 14px;
  text-align: center;
  font-style: italic;
}
.choice-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.choice-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-align: left;
}
.choice-btn:hover {
  background: rgba(255,255,255,0.14);
  border-color: rgba(255,255,255,0.2);
}
.choice-btn:active {
  background: var(--accent);
  border-color: var(--accent);
}

/* ── Notes Screen ── */
#notesScreen, #noteDetail {
  background: var(--screen-bg);
}
.notes-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 40px 12px 12px;
  border-bottom: 1px solid var(--separator);
}
.notes-header h2 {
  font-size: 18px;
  font-weight: 600;
}
.notes-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.note-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--separator);
  cursor: pointer;
  transition: background 0.15s;
}
.note-item:active { background: rgba(255,255,255,0.05); }
.note-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 3px;
}
.note-preview {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.note-date {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}
.note-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--text-primary);
}
.note-content .crossed {
  text-decoration: line-through;
  color: var(--text-dim);
}
.note-content .unsent {
  color: var(--text-secondary);
  font-style: italic;
  border-left: 2px solid var(--text-dim);
  padding-left: 10px;
  margin: 8px 0;
}
.note-content .incomplete {
  color: var(--text-dim);
  animation: blink 1.2s step-end infinite;
}
@keyframes blink {
  50% { opacity: 0; }
}

/* ── Ending Screen ── */
#endingScreen {
  background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
  align-items: center;
  justify-content: center;
}
.ending-lock {
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 1;
  transition: opacity 1s;
}
.ending-notification {
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(20px);
  border-radius: 14px;
  padding: 14px 18px;
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 40px;
  opacity: 0;
  transform: translateY(10px);
  animation: notifAppear 0.6s ease 2s forwards;
}
@keyframes notifAppear {
  to { opacity: 1; transform: translateY(0); }
}
.notif-icon { font-size: 24px; }
.notif-text strong { display: block; font-size: 14px; }
.notif-text span { color: var(--text-secondary); font-size: 13px; }

.ending-fade {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.5s ease;
}
.ending-fade.visible {
  opacity: 1;
  pointer-events: auto;
}
.ending-title {
  font-size: 28px;
  font-weight: 200;
  letter-spacing: 2px;
}
.ending-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  font-style: italic;
}
.ending-score {
  font-size: 14px;
  color: var(--text-dim);
  margin-top: 8px;
}
.ending-btn {
  margin-top: 24px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 12px;
  padding: 12px 28px;
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}
.ending-btn:hover { background: rgba(255,255,255,0.18); }
.ending-buttons {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}
.ending-buttons .ending-btn {
  margin-top: 0;
}

/* ── Mobile Responsive ── */
@media (max-width: 420px) {
  body { align-items: flex-start; }
  .back-link { display: none; }
  #phone {
    width: 100vw;
    height: 100vh;
    filter: none;
  }
  #phone-bezel {
    border-radius: 0;
    padding: 0;
  }
  #phone-notch { display: none; }
  #phone-screen { border-radius: 0; }
  .mute-btn { top: auto; bottom: 16px; right: 16px; }
  :root {
    --radius: 0px;
    --bezel: 0px;
  }
}

/* ── Scrollbar Styling ── */
.chat-messages::-webkit-scrollbar,
.contact-list::-webkit-scrollbar,
.notes-list::-webkit-scrollbar {
  width: 3px;
}
.chat-messages::-webkit-scrollbar-thumb,
.contact-list::-webkit-scrollbar-thumb,
.notes-list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 3px;
}
