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

body {
  font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
  background: #f0f2f5;
  color: #1a1a2e;
  height: 100vh;
  overflow: hidden;
}

/* ======= LOGIN ======= */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

#login-box {
  background: #fff;
  border-radius: 20px;
  padding: 50px 40px;
  width: 380px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-icon {
  font-size: 3rem;
  margin-bottom: 10px;
}

#login-box h1 {
  font-size: 1.5rem;
  color: #1a1a2e;
  margin-bottom: 6px;
}

#login-box p {
  color: #888;
  font-size: 0.9rem;
  margin-bottom: 25px;
}

.developer-credit {
  color: #aaa !important;
  font-size: 0.7rem !important;
  font-weight: 400;
  margin-bottom: 4px !important;
}

#login-box input {
  display: block;
  width: 100%;
  padding: 12px 16px;
  margin-bottom: 14px;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  direction: rtl;
  outline: none;
  transition: border-color 0.2s;
}

#login-box input:focus {
  border-color: #4361ee;
}

#login-btn {
  width: 100%;
  padding: 12px;
  background: #4361ee;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 5px;
}

#login-btn:hover {
  background: #3a56d4;
}

#login-error {
  margin-top: 15px;
  color: #e74c3c;
  font-size: 0.9rem;
  font-weight: 600;
}

#app {
  display: flex;
  height: 100vh;
}

.hidden {
  display: none !important;
}

/* ======= SIDEBAR ======= */
#sidebar {
  width: 280px;
  min-width: 280px;
  background: #1a1a2e;
  color: #eee;
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  overflow-y: auto;
}

#sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px 15px;
  border-bottom: 1px solid #333;
  margin-bottom: 15px;
}

#sidebar h1 {
  font-size: 1.3rem;
}

#logout-btn {
  background: none;
  border: 1px solid #555;
  border-radius: 8px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 0.85rem;
  color: #ccc;
  transition: all 0.2s;
}

#logout-btn:hover {
  background: #e74c3c;
  border-color: #e74c3c;
  color: #fff;
}

#add-job-form {
  display: flex;
  gap: 8px;
  padding: 0 15px;
  margin-bottom: 15px;
}

#job-title-input {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: #2a2a4a;
  color: #fff;
  font-size: 0.9rem;
  outline: none;
}

#job-title-input::placeholder {
  color: #888;
}

#job-title-input:focus {
  background: #333366;
}

#add-job-btn {
  padding: 8px 14px;
  background: #4361ee;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.2s;
}

#add-job-btn:hover {
  background: #3a56d4;
}

#jobs-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
}

.job-item {
  padding: 12px 20px;
  cursor: pointer;
  border-right: 3px solid transparent;
  transition: all 0.2s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.job-item:hover {
  background: #2a2a4a;
}

.job-item.active {
  background: #2a2a4a;
  border-right-color: #4361ee;
}

.job-item .job-name {
  font-size: 0.95rem;
}

.job-item .candidate-count {
  background: #4361ee;
  color: #fff;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 12px;
  min-width: 24px;
  text-align: center;
}

/* ======= MAIN CONTENT ======= */
#main-content {
  flex: 1;
  overflow-y: auto;
  padding: 30px;
}

#welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #888;
}

.welcome-icon {
  font-size: 4rem;
  margin-bottom: 15px;
}

#welcome-screen h2 {
  font-size: 1.5rem;
  color: #555;
  margin-bottom: 8px;
}

/* Job Header */
#job-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
  padding-bottom: 15px;
  border-bottom: 2px solid #e0e0e0;
}

#job-title-display {
  font-size: 1.6rem;
  color: #1a1a2e;
}

#job-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

#upload-label {
  padding: 10px 18px;
  background: #4361ee;
  color: #fff;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.2s;
}

#upload-label:hover {
  background: #3a56d4;
}

#upload-label input {
  display: none;
}

#delete-job-btn {
  padding: 10px 14px;
  background: transparent;
  border: 1px solid #ddd;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s;
}

#delete-job-btn:hover {
  background: #fee;
  border-color: #e74c3c;
}

#upload-status {
  padding: 12px 18px;
  border-radius: 10px;
  margin-bottom: 20px;
  font-size: 0.9rem;
  animation: fadeIn 0.3s;
}

#upload-status.success {
  background: #d4edda;
  color: #155724;
}

#upload-status.error {
  background: #f8d7da;
  color: #721c24;
}

#upload-status.loading {
  background: #fff3cd;
  color: #856404;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Candidates Grid */
#candidates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.candidate-card {
  background: #fff;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
}

.candidate-card:hover {
  box-shadow: 0 4px 16px rgba(67, 97, 238, 0.15);
  border-color: #4361ee;
  transform: translateY(-2px);
}

.candidate-card .card-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 12px;
}

.candidate-card .card-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: #555;
}

.candidate-card .card-info span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.candidate-card .card-file {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #eee;
  font-size: 0.8rem;
  color: #888;
}

.candidate-card .has-notes {
  display: inline-block;
  margin-top: 8px;
  background: #fff3cd;
  color: #856404;
  padding: 2px 10px;
  border-radius: 8px;
  font-size: 0.75rem;
}

#no-candidates {
  text-align: center;
  color: #999;
  padding: 60px 0;
  font-size: 1rem;
}

/* ======= MODAL ======= */
#candidate-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

#modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
}

#modal-content {
  position: relative;
  background: #fff;
  border-radius: 16px;
  width: 90%;
  max-width: 850px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  animation: modalIn 0.3s;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

#modal-close {
  position: absolute;
  top: 15px;
  left: 15px;
  background: none;
  border: none;
  font-size: 1.8rem;
  cursor: pointer;
  color: #888;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
}

#modal-close:hover {
  background: #f0f0f0;
}

#modal-body {
  padding: 30px;
}

#modal-info h2 {
  font-size: 1.5rem;
  color: #1a1a2e;
  margin-bottom: 20px;
}

#modal-details {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 25px;
}

.detail-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
}

.detail-label {
  font-weight: 600;
  color: #555;
  min-width: 100px;
}

.detail-value {
  color: #1a1a2e;
}

#modal-resume-section {
  margin-bottom: 25px;
}

#modal-resume-section h3 {
  font-size: 1.1rem;
  margin-bottom: 12px;
  color: #333;
}

#modal-resume-preview {
  background: #f8f9fa;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 18px;
  max-height: 250px;
  overflow-y: auto;
  font-size: 0.85rem;
  line-height: 1.6;
  white-space: pre-wrap;
  direction: rtl;
  margin-bottom: 12px;
  color: #444;
}

#modal-resume-download {
  display: inline-block;
  padding: 8px 16px;
  background: #e8ecff;
  color: #4361ee;
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.2s;
}

#modal-resume-download:hover {
  background: #d0d8ff;
}

/* Notes */
#modal-notes-section {
  border-top: 2px solid #f0f0f0;
  padding-top: 20px;
}

#modal-notes-section h3 {
  font-size: 1.1rem;
  margin-bottom: 12px;
  color: #333;
}

#modal-notes {
  width: 100%;
  min-height: 120px;
  padding: 14px;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
  outline: none;
  direction: rtl;
  line-height: 1.6;
  transition: border-color 0.2s;
}

#modal-notes:focus {
  border-color: #4361ee;
}

#save-notes-btn {
  margin-top: 10px;
  padding: 10px 22px;
  background: #4361ee;
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.2s;
}

#save-notes-btn:hover {
  background: #3a56d4;
}

#notes-saved-msg {
  margin-right: 12px;
  color: #28a745;
  font-size: 0.9rem;
  font-weight: 600;
}

/* Card bottom row */
.card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

.delete-candidate-btn {
  background: none;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
  opacity: 0;
}

.candidate-card:hover .delete-candidate-btn {
  opacity: 1;
}

.delete-candidate-btn:hover {
  background: #fee;
  border-color: #e74c3c;
}

/* Modal delete button */
#delete-candidate-btn {
  padding: 10px 22px;
  background: #e74c3c;
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.2s;
  margin-right: auto;
}

#delete-candidate-btn:hover {
  background: #c0392b;
}

.notes-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

/* Editable fields */
.editable-field {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.95rem;
  font-family: inherit;
  color: #1a1a2e;
  outline: none;
  direction: rtl;
  flex: 1;
  transition: border-color 0.2s, background 0.2s;
  background: #f8f9fa;
}

.editable-field:focus {
  border-color: #4361ee;
  background: #fff;
}

.editable-name {
  font-size: 1.4rem;
  font-weight: 700;
  border: 2px solid transparent;
  background: transparent;
  padding: 4px 8px;
  width: 100%;
}

.editable-name:hover {
  border-color: #e0e0e0;
  background: #f8f9fa;
}

.editable-name:focus {
  border-color: #4361ee;
  background: #fff;
}

.name-row {
  margin-bottom: 15px;
}

#save-details-btn {
  margin-top: 12px;
  padding: 8px 18px;
  background: #28a745;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.2s;
}

#save-details-btn:hover {
  background: #218838;
}

#details-saved-msg {
  margin-right: 10px;
  color: #28a745;
  font-size: 0.85rem;
  font-weight: 600;
}

/* Job title wrapper */
#job-title-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

#rename-job-btn {
  background: none;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
  opacity: 0.5;
}

#rename-job-btn:hover {
  opacity: 1;
  border-color: #4361ee;
}

/* Move candidate */
.move-candidate {
  display: flex;
  align-items: center;
  gap: 8px;
}

#move-to-job {
  padding: 8px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.85rem;
  direction: rtl;
  outline: none;
  cursor: pointer;
}

#move-to-job:focus {
  border-color: #4361ee;
}

#move-candidate-btn {
  padding: 8px 16px;
  background: #ff9800;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.2s;
}

#move-candidate-btn:hover {
  background: #e68900;
}

/* ======= DRAG & DROP ======= */
.candidate-card[draggable="true"] {
  cursor: grab;
}

.candidate-card.dragging {
  opacity: 0.4;
  transform: scale(0.95);
  box-shadow: 0 0 20px rgba(67, 97, 238, 0.3);
}

.job-item.drag-over {
  background: rgba(67, 97, 238, 0.3) !important;
  border: 2px dashed #4361ee;
  transform: scale(1.03);
  transition: all 0.2s;
}

/* ======= MOBILE ======= */
@media (max-width: 768px) {
  body { overflow: auto; }

  #app {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }

  #sidebar {
    width: 100%;
    min-width: 100%;
    max-height: none;
    padding: 15px 0;
  }

  #sidebar-header {
    padding: 0 15px 10px;
  }

  #sidebar h1 { font-size: 1.1rem; }

  #add-job-form {
    padding: 0 10px;
    margin-bottom: 10px;
  }

  #jobs-list {
    display: flex;
    overflow-x: auto;
    padding: 0 10px;
    gap: 6px;
  }

  .job-item {
    padding: 8px 14px;
    white-space: nowrap;
    border-right: none;
    border-bottom: 3px solid transparent;
    border-radius: 8px;
    background: #2a2a4a;
    font-size: 0.85rem;
  }

  .job-item.active {
    border-bottom-color: #4361ee;
    border-right-color: transparent;
  }

  #main-content {
    padding: 15px;
    overflow-y: visible;
  }

  #job-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  #job-title-display { font-size: 1.2rem; }

  #job-actions {
    width: 100%;
    justify-content: flex-start;
  }

  #upload-label {
    padding: 8px 14px;
    font-size: 0.8rem;
  }

  #candidates-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .candidate-card {
    padding: 15px;
  }

  .delete-candidate-btn {
    opacity: 1;
  }

  /* Modal mobile */
  #modal-content {
    width: 95%;
    max-height: 90vh;
    border-radius: 12px;
  }

  #modal-body { padding: 20px 15px; }

  .detail-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .detail-label { min-width: auto; }

  .editable-field { width: 100%; }

  .notes-actions {
    flex-wrap: wrap;
  }

  .move-candidate {
    width: 100%;
  }

  #move-to-job { flex: 1; }

  #login-box {
    width: 90%;
    padding: 35px 25px;
  }
}
