/* ============================================================================
   CANDIDATE PORTAL — Styles (v3 — Full Overhaul)
   Matches recruiter dashboard design system
   ============================================================================ */

:root {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: rgba(99, 102, 241, 0.08);
  --success: #10b981;
  --success-hover: #059669;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --warning: #f59e0b;
  --bg: #f8fafc;
  --bg-secondary: #f1f5f9;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-full: 9999px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ============================================================================
   LOGIN VIEW
   ============================================================================ */

#login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.login-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 40px 32px;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
}

.login-brand {
  font-size: 22px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
}

.login-card h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 28px;
}

.login-card label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.login-card input[type="email"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  margin-bottom: 16px;
  color: var(--text);
  background: var(--card-bg);
  height: 48px;
}

.login-card input[type="email"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.login-card input[type="email"]::placeholder {
  color: var(--text-muted);
}

/* ============================================================================
   BUTTONS
   ============================================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
  height: 48px;
  font-size: 15px;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

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

.btn-ghost {
  background: none;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--bg-secondary);
  color: var(--text);
  border-color: var(--text-muted);
}

.btn-sm { padding: 8px 16px; font-size: 13px; height: auto; }

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover { background: var(--danger-hover); }

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 14px;
  cursor: pointer;
  padding: 8px 0;
  font-family: inherit;
  font-weight: 500;
}

.btn-link:hover { text-decoration: underline; }

/* ============================================================================
   CODE INPUT
   ============================================================================ */

.code-sent-msg {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.code-inputs {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 20px;
}

.code-digit {
  width: 44px;
  height: 48px;
  text-align: center;
  font-size: 22px;
  font-weight: 600;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'SF Mono', Monaco, 'Courier New', monospace;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  color: var(--text);
  background: var(--card-bg);
}

.code-digit:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 8px;
}

.success {
  color: var(--success);
  font-size: 13px;
  margin-top: 8px;
}

/* ============================================================================
   DASHBOARD — HEADER
   ============================================================================ */

.dash-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.dash-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 1;
  min-width: 0;
}

.dash-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.dash-logo { flex-shrink: 0; }

.dash-brand-text {
  font-size: 17px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.3px;
}

/* Tab navigation in header center */
.dash-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.dash-tab {
  position: relative;
  background: none;
  border: none;
  padding: 16px 16px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.15s;
  white-space: nowrap;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.dash-tab:hover {
  color: var(--text);
}

.dash-tab.active {
  color: var(--primary);
  font-weight: 600;
}

.dash-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 8px;
  right: 8px;
  height: 2px;
  background: var(--primary);
  border-radius: 2px 2px 0 0;
}

.tab-badge {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  flex-shrink: 0;
}

.tab-badge.hidden { display: none; }

/* Header right */
.dash-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.logout-link {
  background: none;
  border: none;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 0;
}

.logout-link:hover {
  color: var(--text-secondary);
  text-decoration: underline;
}

/* ============================================================================
   DASHBOARD — MAIN CONTENT
   ============================================================================ */

.dash-main {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 24px 80px;
}

/* Tab panels */
.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ============================================================================
   APPLICATION SECTIONS & CARDS
   ============================================================================ */

.app-section {
  margin-bottom: 28px;
}

.section-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--primary);
  margin-bottom: 12px;
  padding-left: 2px;
}

.section-label-action { color: var(--danger); }
.section-label-muted { color: var(--text-muted); }

.app-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.app-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 18px 20px;
  border: 1px solid var(--border);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
  position: relative;
}

.app-card:hover {
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}

.app-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.company-initial {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  color: #fff;
  flex-shrink: 0;
}

.company-logo-img {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
}

.app-card-info {
  flex: 1;
  min-width: 0;
}

.app-card-top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.app-card-job {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.3;
}

.new-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
}

.app-card-company {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.app-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.app-card-date {
  font-size: 12px;
  color: var(--text-muted);
}

/* ============================================================================
   STATUS PILLS
   ============================================================================ */

.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.pill-applied {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.pill-screening {
  background: #dbeafe;
  color: #1e40af;
}

.pill-reviewed {
  background: #dbeafe;
  color: #1e40af;
}

.pill-interview {
  background: #e0e7ff;
  color: #3730a3;
}

.pill-offer {
  background: #fef3c7;
  color: #92400e;
}

.pill-hired {
  background: #dcfce7;
  color: #166534;
}

.pill-rejected {
  background: #fee2e2;
  color: #991b1b;
}

.pill-completed {
  background: #f0fdf4;
  color: #15803d;
}

/* ============================================================================
   ACTION BANNER
   ============================================================================ */

.action-banner {
  margin-top: 14px;
  border-left: 3px solid var(--primary);
  background: var(--primary-light);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.action-banner-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.action-banner-text .action-expiry {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-top: 2px;
}

.btn-action {
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border: none;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.15s;
}

.btn-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

/* Rejected card style */
.app-card.rejected {
  opacity: 0.65;
}

.reject-reason {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
  font-style: italic;
}

/* ============================================================================
   MESSAGES TAB
   ============================================================================ */

.messages-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.messages-empty svg {
  margin-bottom: 16px;
  opacity: 0.5;
}

.messages-empty p {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--text-secondary);
}

.messages-empty .messages-empty-sub {
  font-size: 13px;
  color: var(--text-muted);
}

/* Message thread card */
.msg-thread-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: box-shadow 0.15s, border-color 0.15s;
  overflow: hidden;
  margin-bottom: 10px;
}

.msg-thread-card:hover {
  border-color: #cbd5e1;
}

.msg-thread-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  cursor: pointer;
  transition: background 0.1s;
  user-select: none;
}

.msg-thread-header:hover {
  background: var(--bg-secondary);
}

.msg-thread-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
}

.msg-thread-info {
  flex: 1;
  min-width: 0;
}

.msg-thread-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-thread-company {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 1px;
}

.msg-thread-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.msg-thread-time {
  font-size: 11px;
  color: var(--text-muted);
}

.msg-unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
}

.msg-thread-chevron {
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform 0.2s;
}

.msg-thread-card.expanded .msg-thread-chevron {
  transform: rotate(180deg);
}

/* Thread body (messages) */
.msg-thread-body {
  display: none;
  border-top: 1px solid var(--border);
}

.msg-thread-card.expanded .msg-thread-body {
  display: block;
}

.msg-conversation {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 400px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Chat bubbles */
.chat-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.chat-bubble.from-recruiter {
  align-self: flex-start;
  background: var(--bg-secondary);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.chat-bubble.from-candidate {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-bubble-body {
  white-space: pre-wrap;
}

.chat-bubble-time {
  font-size: 11px;
  opacity: 0.55;
  margin-top: 4px;
}

.chat-bubble.from-candidate .chat-bubble-time {
  text-align: right;
}

/* Reply box */
.msg-reply-box {
  display: flex;
  gap: 8px;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.msg-reply-box textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.15s;
  color: var(--text);
  background: var(--card-bg);
}

.msg-reply-box textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.08);
}

.msg-reply-box textarea::placeholder {
  color: var(--text-muted);
}

.msg-reply-box .btn {
  align-self: flex-end;
}

.msg-reply-btn {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.msg-reply-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

.msg-reply-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================================================
   EMPTY / LOADING STATES
   ============================================================================ */

.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-icon {
  margin-bottom: 16px;
  color: var(--text-muted);
  opacity: 0.4;
}

.empty-state p {
  font-size: 15px;
  color: var(--text-secondary);
  font-weight: 500;
}

.empty-state .empty-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 400;
}

.loading-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 16px;
}

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

/* ============================================================================
   DELETE ACCOUNT
   ============================================================================ */

.delete-account-section {
  text-align: center;
  padding-top: 32px;
  margin-top: 32px;
  border-top: 1px solid var(--border);
}

.delete-account-link {
  background: none;
  border: none;
  font-size: 12px;
  font-family: inherit;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 0;
  transition: color 0.15s;
}

.delete-account-link:hover {
  color: var(--danger);
  text-decoration: underline;
}

.delete-account-note {
  font-size: 12px;
  color: var(--border);
  margin-top: 4px;
}

/* ============================================================================
   MODAL
   ============================================================================ */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  box-sizing: border-box;
}

.modal-content h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text);
}

.modal-content p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.modal-content ul {
  margin: 10px 0;
  padding-left: 20px;
  color: var(--text-secondary);
  font-size: 13px;
}

.modal-content li { margin-bottom: 4px; }

.delete-warning {
  color: var(--danger) !important;
  font-weight: 600;
  margin-top: 14px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  justify-content: flex-end;
}

/* ============================================================================
   RESPONSIVE — TABLET (≤768px)
   ============================================================================ */

@media (max-width: 768px) {
  .dash-header {
    height: auto;
    flex-wrap: wrap;
    padding: 0;
  }

  .dash-header-top {
    width: 100%;
    padding: 10px 16px;
    height: 48px;
  }

  .dash-tabs {
    position: static;
    transform: none;
    width: 100%;
    border-top: 1px solid var(--border);
    justify-content: center;
    gap: 0;
  }

  .dash-tab {
    flex: 1;
    justify-content: center;
    height: 44px;
    padding: 12px 8px;
    font-size: 13px;
  }

  .user-name { display: none; }
}

/* ============================================================================
   RESPONSIVE — MOBILE (≤480px)
   ============================================================================ */

@media (max-width: 480px) {
  .login-card {
    padding: 28px 20px;
    border-radius: var(--radius-sm);
  }

  .login-logo svg { width: 36px; height: 36px; }
  .login-brand { font-size: 20px; }
  .login-card h1 { font-size: 20px; }

  .code-digit {
    width: 40px;
    height: 44px;
    font-size: 18px;
  }

  .dash-main { padding: 20px 16px 80px; }

  .app-card { padding: 14px 16px; }

  .company-initial,
  .company-logo-img {
    width: 38px;
    height: 38px;
    font-size: 16px;
  }

  .app-card-job { font-size: 14px; }
  .app-card-company { font-size: 12px; }

  .app-card-top-row {
    flex-direction: column;
    gap: 6px;
  }

  .action-banner {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-action {
    width: 100%;
    text-align: center;
    display: block;
  }

  .chat-bubble { max-width: 85%; }

  .msg-thread-header { padding: 12px 14px; }
  .msg-conversation { padding: 12px 14px; }
  .msg-reply-box { padding: 10px 14px 14px; }

  .modal { padding: 12px; }
  .modal-content { padding: 24px 20px; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }
}
