/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --border: #e0e0e0;
  --primary: #1a73e8;
  --primary-hover: #1557b0;
  --text: #202124;
  --muted: #5f6368;
  --danger: #d93025;
  --radius: 8px;
  --shadow: 0 1px 4px rgba(0,0,0,.12);
}

body {
  font-family: 'Google Sans', Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  min-height: 100vh;
}

/* ── Utilities ── */
.hidden { display: none !important; }
.muted  { color: var(--muted); font-size: 13px; }
.mt-8   { margin-top: 8px; }
.error-msg { color: var(--danger); font-size: 13px; margin-top: 8px; }

/* ── Screens ── */
.screen { min-height: 100vh; }

/* ── Login ── */
.login-card {
  max-width: 380px;
  margin: 120px auto 0;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 40px 36px;
  text-align: center;
}

.logo {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 8px;
}

.tagline {
  color: var(--muted);
  margin-bottom: 32px;
  line-height: 1.5;
}

/* ── Topbar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-logo { font-weight: 700; font-size: 16px; }

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

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: none;
}

.user-email { color: var(--muted); font-size: 13px; }

/* ── App layout ── */
.app-layout {
  display: flex;
  height: calc(100vh - 56px);
}

/* ── Sidebar ── */
.sidebar {
  width: 260px;
  min-width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  margin-bottom: 12px;
}

.phone-list { display: flex; flex-direction: column; gap: 4px; }

.phone-item {
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s;
}

.phone-item:hover { background: var(--bg); }
.phone-item.active { background: #e8f0fe; border-color: var(--primary); }

.phone-number { font-weight: 600; }
.phone-owner  { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── Main panel ── */
.main-panel {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.messages-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.phone-title { font-size: 20px; font-weight: 600; }

.messages-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-input {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
  font-size: 13px;
  outline: none;
  width: 200px;
  transition: border-color .2s;
}

.search-input:focus { border-color: var(--primary); }

/* ── Message list ── */
.message-list { display: flex; flex-direction: column; gap: 8px; }

.message-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.message-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.message-sender {
  font-weight: 600;
  font-size: 13px;
}

.message-time {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  margin-left: 12px;
}

.message-body {
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Loading ── */
.loading {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

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

/* ── Load more ── */
.load-more { text-align: center; padding: 16px 0; }

/* ── Buttons ── */
button { cursor: pointer; font-family: inherit; }

.btn-ghost {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 13px;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: background .15s;
}

.btn-ghost:hover { background: #e8f0fe; }

.btn-secondary {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  transition: background .15s;
}

.btn-secondary:hover { background: var(--bg); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .sidebar { width: 100%; height: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .app-layout { flex-direction: column; height: auto; }
  .main-panel { padding: 12px; }
}
