/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: #f8f9fa; color: #1a1a2e; }
a { text-decoration: none; color: inherit; }
button, input, textarea, select { font-family: inherit; }

/* ===== APP LAYOUT ===== */
.app-layout {
  display: grid;
  grid-template-columns: 260px 1fr 480px;
  height: 100vh;
  overflow: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
  background: #fafafa;
  color: #000;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #fafafa;
  overflow: hidden;
}

.sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid #fafafa;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.logo-text {
  font-size: 20px;
  font-weight: 700;
  color: #000;
}

.btn-new-chat {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  background: #3b5bdb;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s;
}

.btn-new-chat:hover { background: #2f4ac7; }

.sidebar-history {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
}

.history-label {
  font-size: 11px;
  color: #666;
  padding: 4px 8px 8px;
  letter-spacing: 0.5px;
}

.history-item {
  display: flex;
  align-items: center;
  border-radius: 6px;
  margin-bottom: 2px;
  transition: background 0.15s;
}

.history-item:hover, .history-item.active {
  background: #e2e2e2;
}

.history-link {
  flex: 1;
  padding: 8px 10px;
  font-size: 13px;
  color: #000;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-delete {
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 16px;
  opacity: 0;
  transition: opacity 0.15s;
}

.history-item:hover .history-delete { opacity: 1; }
.history-delete:hover { color: #ff4757; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid #e8e8f0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.user-avatar {
  width: 36px;
  height: 36px;
  background: #3b5bdb;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: white;
  flex-shrink: 0;
}

.user-details { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: #000; }
.user-plan { font-size: 11px; color: #888; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.btn-signout {
  width: 100%;
  margin-top: 8px;
  padding: 7px;
  background: #f5f5f5;
  color: #555;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-signout:hover { background: #ffe0e0; color: #c0392b; border-color: #f5c6c6; }

.auth-links {
  display: flex;
  gap: 8px;
}

.btn-signin {
  flex: 1;
  display: block;
  padding: 9px;
  background: #3b5bdb;
  color: white;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  transition: background 0.2s;
}
.btn-signin:hover { background: #2f4ac7; }

.btn-signup {
  flex: 1;
  display: block;
  padding: 9px;
  background: white;
  color: #3b5bdb;
  border: 1px solid #3b5bdb;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  transition: all 0.2s;
}
.btn-signup:hover { background: #f0f4ff; }

/* ===== DEVISE EXTRA STYLES ===== */
.devise-subtitle {
  font-size: 14px;
  color: #888;
  margin-bottom: 24px;
  margin-top: -4px;
}

.devise-logo {
  text-align: center;
  margin-bottom: 20px;
}

.field-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #555;
}

.field-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.field-hint {
  font-size: 12px;
  color: #888;
  margin-left: 4px;
}

.devise-links {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  font-size: 13px;
}

.devise-links a {
  color: #3b5bdb;
  transition: color 0.15s;
}
.devise-links a:hover { color: #2f4ac7; text-decoration: underline; }

.btn-signout {
  font-size: 12px;
  color: #888;
  cursor: pointer;
}
.btn-signout:hover { color: #ff4757; }

.btn-signin {
  display: block;
  padding: 8px 16px;
  background: #3b5bdb;
  color: white;
  border-radius: 6px;
  text-align: center;
  font-size: 13px;
}

/* ===== CHAT PANEL ===== */
.chat-panel {
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 1px solid #e8e8f0;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 24px;
  border-bottom: 1px solid #f0f0f8;
  font-size: 14px;
  font-weight: 600;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: #2ed573;
  border-radius: 50%;
}

.status-badge {
  background: #e8fff0;
  color: #2ed573;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 500;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.welcome-message {
  background: #f0f4ff;
  border-radius: 12px 12px 12px 4px;
  padding: 16px 20px;
  max-width: 80%;
  font-size: 14px;
  line-height: 1.6;
  color: #444;
}

.message { display: flex; }

.message-user { justify-content: flex-end; }
.message-assistant { justify-content: flex-start; }

.message-user .message-bubble {
  background: #3b5bdb;
  color: white;
  border-radius: 18px 18px 4px 18px;
  padding: 12px 18px;
  max-width: 75%;
  font-size: 14px;
  line-height: 1.5;
}

.message-assistant .message-bubble {
  background: #f5f5f8;
  color: #333;
  border-radius: 4px 18px 18px 18px;
  padding: 12px 18px;
  max-width: 80%;
  font-size: 14px;
  line-height: 1.5;
}

.chat-input-area {
  padding: 16px 24px 20px;
  border-top: 1px solid #f0f0f8;
}

.chat-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: #f8f9ff;
  border: 1px solid #e0e0f0;
  border-radius: 12px;
  padding: 10px 14px;
}

.chat-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  resize: none;
  font-size: 14px;
  line-height: 2.5;
  color: #333;
  max-height: 120px;
}

.chat-input::placeholder { color: #aaa; }

.chat-submit {
  background: #3b5bdb;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  transition: background 0.2s;
  flex-shrink: 0;
}

.chat-submit:hover { background: #2f4ac7; }

/* ===== JOBS PANEL ===== */
.jobs-panel {
  background: #fafafa;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.jobs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e8e8f0;
  background: white;
}

.jobs-header h2 { font-size: 16px; font-weight: 700; }

.jobs-count {
  background: #3b5bdb;
  color: white;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
}

.jobs-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.jobs-empty {
  text-align: center;
  color: #999;
  padding: 40px 20px;
  font-size: 14px;
}

/* ===== JOB CARD ===== */
.job-card {
  background: white;
  border-radius: 12px;
  padding: 16px;
  border: 1px solid #ebebf5;
  transition: box-shadow 0.2s, transform 0.2s;
  cursor: pointer;
}

.job-card:hover {
  box-shadow: 0 4px 16px rgba(59, 91, 219, 0.12);
  transform: translateY(-1px);
}

.job-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.company-logo {
  width: 40px;
  height: 40px;
  background: #f0f4ff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #999;
  flex-shrink: 0;
  border: 1px solid #e0e8ff;
}

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

.job-title {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #1a1a2e;
  margin-bottom: 4px;
  line-height: 1.3;
}

.job-title:hover { color: #3b5bdb; }

.job-meta {
  font-size: 12px;
  color: #888;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.separator { color: #ccc; }

.job-salary {
  font-size: 14px;
  font-weight: 700;
  color: #2ed573;
  white-space: nowrap;
}

.job-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.tag {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 500;
}

.tag-skill {
  background: #eef2ff;
  color: #3b5bdb;
}

.job-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: #888;
}

.job-type {
  display: flex;
  align-items: center;
  gap: 4px;
}

.job-type::before {
  content: "⏱";
  font-size: 11px;
}

/* ===== FLASH MESSAGES ===== */
.flash {
  position: fixed;
  top: 16px;
  right: 16px;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 9999;
  animation: slideIn 0.3s ease;
}

.flash-notice { background: #e8fff0; color: #2ed573; border: 1px solid #b3f0cc; }
.flash-alert  { background: #fff0f0; color: #ff4757; border: 1px solid #ffc0c0; }

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

/* ===== DEVISE FORMS ===== */
.devise-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f4ff;
}

.devise-card {
  background: white;
  padding: 40px;
  border-radius: 16px;
  width: 400px;
  box-shadow: 0 8px 40px rgba(59, 91, 219, 0.12);
}

.devise-card h2 {
  text-align: center;
  margin-bottom: 28px;
  font-size: 24px;
  color: #1a1a2e;
}

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: #555; }
.field input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #dde1ef;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.field input:focus { border-color: #3b5bdb; }

.devise-actions {
  margin-top: 20px;
}

.btn-primary {
  display: block;
  width: 100%;
  padding: 12px;
  background: #3b5bdb;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background 0.2s;
}

.btn-primary:hover { background: #2f4ac7; }

.devise-links {
  margin-top: 16px;
  text-align: center;
  font-size: 13px;
  color: #888;
}

.devise-links a { color: #3b5bdb; }
.devise-links a:hover { text-decoration: underline; }

.error-messages {
  background: #fff0f0;
  border: 1px solid #ffd0d0;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: 13px;
  color: #cc0000;
}

/* ===== SIDEBAR USER PROFILE LINK ===== */
.user-avatar { cursor: pointer; transition: opacity 0.15s; }
.user-avatar:hover { opacity: 0.85; }
.user-profile-link { color: inherit; }
.user-profile-link:hover { color: #3b5bdb; }

/* ===== PROFILE PAGE ===== */
.profile-layout {
  max-width: 800px;
  margin: 40px auto;
  padding: 0 24px 60px;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 20px;
  background: white;
  border-radius: 16px;
  padding: 28px 32px;
  border: 1px solid #e8e8f0;
  margin-bottom: 20px;
}

.profile-avatar {
  width: 72px;
  height: 72px;
  background: #3b5bdb;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.profile-header-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.profile-username {
  font-size: 22px;
  font-weight: 700;
  color: #1a1a2e;
}

.profile-email {
  font-size: 14px;
  color: #666;
}

.profile-status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  width: fit-content;
}

.profile-status--active { background: #e8f5e9; color: #2e7d32; }
.profile-status--inactive { background: #f5f5f5; color: #888; }
.profile-status--banned { background: #ffebee; color: #c62828; }

.btn-back {
  padding: 8px 16px;
  background: #f0f4ff;
  color: #3b5bdb;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.2s;
  white-space: nowrap;
}
.btn-back:hover { background: #dce4ff; }

.profile-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border: 1px solid #e8e8f0;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-number {
  font-size: 26px;
  font-weight: 700;
  color: #3b5bdb;
}

.stat-label {
  font-size: 12px;
  color: #888;
}

.profile-section {
  background: white;
  border-radius: 16px;
  border: 1px solid #e8e8f0;
  padding: 28px 32px;
}

.profile-section-title {
  font-size: 16px;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f0f0f5;
}

.profile-empty {
  text-align: center;
  padding: 40px 0;
  color: #888;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.applications-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.application-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border: 1px solid #f0f0f5;
  border-radius: 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.application-card:hover {
  border-color: #c5cae9;
  box-shadow: 0 2px 8px rgba(59,91,219,0.06);
}

.application-job-info {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
}

.application-company-logo {
  width: 44px;
  height: 44px;
  background: #f0f4ff;
  color: #3b5bdb;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
}

.application-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.application-job-title {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a2e;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.application-job-title a { color: inherit; }
.application-job-title a:hover { color: #3b5bdb; }

.application-meta {
  font-size: 12px;
  color: #888;
  display: flex;
  align-items: center;
  gap: 4px;
}

.application-salary { color: #2e7d32; font-weight: 500; }

.sep { color: #ddd; }

.application-skills {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.application-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.application-status {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.application-status--delivered { background: #e3f2fd; color: #1565c0; }
.application-status--approved  { background: #e8f5e9; color: #2e7d32; }
.application-status--rejected  { background: #ffebee; color: #c62828; }
.application-status--failed    { background: #fff3e0; color: #e65100; }

.application-date {
  font-size: 11px;
  color: #aaa;
}

/* ===== JOB DETAIL PAGE ===== */
.job-detail-layout {
  max-width: 900px;
  margin: 40px auto;
  padding: 0 20px;
}

.job-detail-card {
  background: white;
  border-radius: 16px;
  padding: 40px;
  border: 1px solid #e8e8f0;
}

/* ===== APPLY BUTTON & BADGE ===== */
.btn-apply {
  margin-left: auto;
  padding: 6px 14px;
  background: #3b5bdb;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}
.btn-apply:hover { background: #2f4ac7; }

.applied-badge {
  margin-left: auto;
  padding: 4px 10px;
  background: #e8f5e9;
  color: #2e7d32;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

/* ===== APPLY MODAL ===== */
.apply-modal-dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  width: 480px;
  max-width: 95vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
}

.apply-modal-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
}

.apply-modal-content {
  padding: 28px 32px 32px;
}

.apply-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.apply-modal-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: #1a1a2e;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 22px;
  color: #888;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}
.modal-close-btn:hover { background: #f0f0f0; color: #333; }

.apply-form .form-group {
  margin-bottom: 18px;
}

.apply-form .form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #444;
  margin-bottom: 6px;
}

.apply-form .form-group input[type="text"],
.apply-form .form-group input[type="email"],
.apply-form .form-group input[type="tel"] {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #dde1ef;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  background: #fafbff;
}
.apply-form .form-group input:focus { border-color: #3b5bdb; background: white; }

.required { color: #e53e3e; margin-left: 2px; }

.file-upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px;
  border: 2px dashed #c5cae9;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: #fafbff;
  text-align: center;
}
.file-upload-area:hover { border-color: #3b5bdb; background: #f0f4ff; }

.file-input-hidden {
  display: none;
}

.upload-icon {
  color: #7986cb;
  width: 28px;
  height: 28px;
}

.file-label-text {
  font-size: 13px;
  color: #666;
}

.file-label-error {
  color: #e53e3e !important;
}

.apply-form-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  justify-content: flex-end;
}

.btn-modal-cancel {
  padding: 10px 20px;
  background: #f0f0f5;
  color: #555;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-modal-cancel:hover { background: #e2e2ea; }

.btn-modal-submit {
  padding: 10px 24px;
  background: #3b5bdb;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-modal-submit:hover { background: #2f4ac7; }
