/* =====================================================
   CNJobs — home.css FINAL v2
   Original + Mobile merged + Profile panel fixed
   ===================================================== */

:root {
  --primary-blue: #0a4aa1;
  --dark-blue: #084a83;
  --left-bg: #f3fbff;
  --mid-bg: #ffffff;
  --right-bg: #0a3e6f;
}

body {
  font-family: Arial, Helvetica, sans-serif;
  margin: 0;
  background: #e9f1ff;
  color: #173247;
  overflow-x: hidden;
}

* { box-sizing: border-box; scrollbar-width: thin; }

.search-bar-full {
  background: #fff; padding: 8px; margin: 0;
  border-radius: 10px; display: flex; gap: 10px;
  align-items: center; box-shadow: 0 0 6px rgba(0,0,0,0.08);
}
.search-bar-full input,
.search-bar-full select {
  padding: 8px; border-radius: 6px; border: 1px solid #d0e0f5;
}

/* PAGE GRID */
body:not(.logged-in) .page-grid {
  display: grid !important;
  grid-template-columns: 260px 350px 1fr !important;
  gap: 8px; padding: 10px; align-items: start;
}
body.logged-in .page-grid {
  display: grid !important;
  grid-template-columns: 260px 330px 1fr 280px !important;
  gap: 8px; padding: 10px; align-items: start;
}
.page-grid { grid-auto-rows: 1fr; align-items: stretch !important; }
.page-grid > * { min-height: 0; display: flex; flex-direction: column; }

/* PANEL BASE */
.left-box, .middle-left-box, .middle-right-box, .right-box {
  flex: 1 1 auto; min-height: 0;
  max-height: calc(125vh - 250px) !important;
  overflow-y: auto; overflow-x: hidden;
  background: #fff; border-radius: 12px;
  padding: 14px 0; box-shadow: 0 0 4px rgba(0,0,0,0.07);
}
body:not(.logged-in) .left-box { background: var(--left-bg); box-shadow: 0 0 2px rgba(0,0,0,0.08); }
.right-box { background: var(--right-bg) !important; color: #fff !important; }
.middle-right-box { background: #f8fdfc; }
.middle-right-box h3 { margin-top: 0; }

#jobList { display: block; height: 100%; min-height: 0; }
#jobPreview {
  display: flex; flex-direction: column;
  height: 100%; min-height: 0; overflow-y: auto;
  padding: 22px; background: var(--mid-bg);
}
html, body { height: 100%; }

/* JOB LIST */
.panel-heading { font-size: 18px; font-weight: 700; margin-bottom: 12px; }
.left-tabs { display: flex; gap: 8px; margin-bottom: 15px; }
.left-tabs .tab-btn { padding: 6px 12px; background: #fff; border-radius: 6px; border: 1px solid #c4d7f2; cursor: pointer; }
.left-tabs .tab-btn:hover { background: #e9f3ff; border-color: var(--primary-blue); }
.job-row { padding: 10px; border-bottom: 1px solid #d9e6f5; cursor: pointer; }
.job-row:hover { background: #f5faff; }
.job-active { background: #e8f1ff; border-left: 3px solid var(--primary-blue); }

/* WIDGETS */
.widgets-container { padding: 10px; }
.widget-title { font-size: 20px; margin-bottom: 12px; font-weight: 700; }
.widget-list { list-style: none; padding: 0; margin: 0; }
.widget-list li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.2); }
.widget-subtitle { margin-top: 14px; margin-bottom: 6px; opacity: 0.9; }
.widget-link { cursor: pointer; opacity: 0.85; margin-bottom: 6px; }
.widget-link:hover { opacity: 1; text-decoration: underline; }

/* PROFILE BLOCK */
.profile-block { display: flex; gap: 14px; align-items: center; background: #fff; padding: 14px; border-radius: 10px; box-shadow: 0 1px 6px rgba(0,0,0,0.06); }
.profile-photo { flex: 0 0 80px; width: 80px; height: 80px; border-radius: 10px; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.profile-photo img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 6px; }
.profile-info { flex: 1 1 auto; min-width: 0; }
.profile-name { font-weight: 700; margin-bottom: 6px; }
.profile-meta { font-size: 13px; color: #3b566c; }
.profile-links { margin-top: 8px; }
.profile-links a { color: var(--primary-blue); text-decoration: none; margin-right: 12px; font-size: 13px; display: inline-block; margin-top: 8px; }
.profile-links a:hover { text-decoration: underline; }
.profile-stats { margin-top: 8px; font-size: 14px; }

/* FILTERS */
.job-filters-container { background: white; border-radius: 12px; padding: 16px 0; box-shadow: 0 2px 8px rgba(0,0,0,0.08); margin-top: 20px; }
.filter-list { display: flex; flex-direction: column; }
.filter-link { padding: 14px 24px; font-size: 15px; font-weight: 500; color: #374151; text-decoration: none; display: flex; align-items: center; justify-content: space-between; transition: all 0.2s ease; border-left: 3px solid transparent; position: relative; }
.filter-link:hover { background: #f9fafb; color: #1e40af; border-left-color: #3b82f6; }
.filter-link.active { background: #eff6ff; color: #1e40af; border-left-color: #3b82f6; font-weight: 600; }
.filter-link.active::after { content: ''; position: absolute; right: 20px; width: 6px; height: 6px; background: #3b82f6; border-radius: 50%; }
.filter-count { font-size: 13px; color: #6b7280; font-weight: 500; }
.filter-link.active .filter-count { color: #1e40af; }

/* JOB PREVIEW */
.job-preview-container { padding: 0; }
.job-preview-container h2 { font-size: 24px; font-weight: 700; color: #111827; margin: 0 0 12px 0; }
.job-preview-container .job-meta { color: #6b7280; margin-bottom: 16px; }
.job-preview-container hr { border: none; border-top: 1px solid #e5e7eb; margin: 16px 0; }
.job-preview-container .job-description { font-size: 15px; line-height: 1.7; color: #4b5563; }
.job-preview-container .d-flex { display: flex; gap: 12px; flex-wrap: wrap; }

/* BUTTONS */
.btn { padding: 10px 20px; border-radius: 6px; font-size: 14px; font-weight: 500; border: none; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; transition: all 0.3s; }
.btn-primary { background: #3b82f6; color: white; }
.btn-primary:hover { background: #2563eb; }
.btn-secondary { background: #6b7280; color: white; }
.btn-secondary:hover { background: #4b5563; }
.btn-outline-secondary { background: white; color: #6b7280; border: 2px solid #d1d5db; }
.btn-outline-secondary:hover { background: #f9fafb; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* APPLY POPUP */
.apply-popup { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.55); display: none; justify-content: center; align-items: center; z-index: 2000; }
.apply-popup.show { display: flex; }
.apply-popup-card { width: 420px; background: #fff; padding: 20px; border-radius: 12px; box-shadow: 0 0 10px rgba(0,0,0,0.2); }
.apply-close { float: right; background: none; border: none; font-size: 22px; cursor: pointer; }
.apply-textarea, .apply-input { width: 100%; margin-top: 8px; padding: 8px; border-radius: 6px; border: 1px solid #cfd8e5; }
.apply-actions { display: flex; justify-content: space-between; margin-top: 20px; }
.apply-msg { margin-top: 12px; padding: 8px; font-weight: bold; }
.apply-msg.success { color: green; }
.apply-msg.error { color: red; }

/* NOTIFICATIONS */
#notification-container { position: fixed; top: 20px; right: 20px; z-index: 10000; max-width: 350px; }

/* ═══════════════════════════════════════════
   MOBILE ELEMENTS — HIDDEN BY DEFAULT
   (shown via JS style.display or media query)
   ═══════════════════════════════════════════ */
.mob-bottom-nav  { display: none; }
.mob-back-bar    { display: none; }

/* KEY FIX: profile panel hidden globally */
/* JS will set style.display='block' directly */
#mobProfilePanel {
  display: none;
}

/* =====================================================
   DESKTOP RESPONSIVE
   ===================================================== */
@media (max-width: 1200px) {
  body.logged-in .page-grid {
    grid-template-columns: 240px 300px 1fr 260px !important;
  }
}
@media (max-width: 1100px) {
  body.logged-in .page-grid {
    grid-template-columns: 220px 280px 1fr !important;
  }
  .right-panel { display: none; }
}

/* =====================================================
   MOBILE + TABLET (<1024px)
   ===================================================== */
@media (max-width: 1023px) {

  .left-panel, .right-panel { display: none !important; }

  body.logged-in .page-grid,
  body:not(.logged-in) .page-grid {
    display: block !important;
    padding: 0 !important;
    gap: 0 !important;
  }
  .page-grid > * { display: block; }

  .mid-left-panel { display: block !important; padding-bottom: 60px; }
  .middle-left-box {
    max-height: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
  .panel-heading {
    padding: 12px 14px 8px;
    font-size: 16px;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 0;
  }
  .job-row { padding: 12px 14px !important; }

  /* Job detail panel */
  .mid-right-panel {
    display: none !important;
    position: fixed !important;
    top: 0 !important; left: 0 !important;
    width: 100% !important; height: 100% !important;
    z-index: 500 !important;
    background: #fff !important;
    padding-bottom: 60px !important;
    overflow-y: auto !important;
  }
  .mid-right-panel.mob-detail-open { display: block !important; }
  .middle-right-box {
    max-height: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    overflow-y: auto !important;
    height: 100% !important;
  }
  #jobPreview {
    padding: 14px !important;
    min-height: calc(100vh - 60px) !important;
  }

  /* Back bar */
  .mob-back-bar {
    display: flex;
    align-items: center; gap: 10px;
    padding: 10px 14px;
    background: #0d4c90; color: #fff;
    position: sticky; top: 0; z-index: 10;
  }
  .mob-back-btn {
    background: none; border: none; color: #fff;
    font-size: 20px; cursor: pointer; padding: 0;
    display: flex; align-items: center; gap: 6px;
    font-family: inherit;
  }
  .mob-back-label { font-size: 13px; font-weight: 600; color: #fff; }

  /* Bottom Nav */
  .mob-bottom-nav {
    display: flex !important;
    position: fixed; bottom: 0; left: 0;
    width: 100%; height: 56px;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    z-index: 600;
    box-shadow: 0 -2px 10px rgba(0,0,0,.08);
  }
  .mob-nav-item {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 2px; cursor: pointer; border: none;
    background: none; padding: 0; font-family: inherit;
    color: #9ca3af; transition: color .15s; position: relative;
  }
  .mob-nav-item.active { color: #0d4c90; border-top: 2px solid #0d4c90; }
  .mob-nav-item i { font-size: 20px; }
  .mob-nav-label { font-size: 9px; font-weight: 500; }
  .mob-nav-badge {
    position: absolute; top: 4px; right: calc(50% - 18px);
    background: #ef4444; color: #fff;
    font-size: 8px; font-weight: 700;
    min-width: 14px; height: 14px; border-radius: 99px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 3px; border: 1.5px solid #fff;
  }

  /* Profile panel — positioned fixed, JS controls display */
  #mobProfilePanel {
    position: fixed !important;
    top: 0 !important; left: 0 !important;
    width: 100% !important; height: 100% !important;
    overflow-y: auto !important;
    z-index: 490 !important;
    background: #fff !important;
    padding: 16px 14px 70px !important;
  }

  .mob-profile-avatar {
    width: 56px; height: 56px; border-radius: 50%;
    background: #e5e7eb; display: flex;
    align-items: center; justify-content: center;
    font-size: 22px; font-weight: 600; color: #374151;
    margin: 0 auto 8px; overflow: hidden;
    border: 2px solid #e2e8f0;
  }
  .mob-profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
  .mob-profile-name { text-align: center; font-size: 15px; font-weight: 600; color: #1e293b; margin-bottom: 4px; }
  .mob-profile-plan { text-align: center; margin-bottom: 12px; }
  .mob-profile-plan span { background: #f1f5f9; color: #64748b; font-size: 11px; padding: 3px 10px; border-radius: 99px; }
  .mob-progress-wrap { margin-bottom: 14px; background: #f8fafc; border-radius: 10px; padding: 12px 14px; }
  .mob-progress-label { display: flex; justify-content: space-between; font-size: 12px; color: #64748b; margin-bottom: 6px; }
  .mob-progress-bar { height: 6px; background: #e2e8f0; border-radius: 99px; overflow: hidden; }
  .mob-progress-fill { height: 100%; border-radius: 99px; transition: width .3s; }
  .mob-progress-hint { font-size: 10px; color: #ef4444; margin-top: 5px; }
  .mob-stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
  .mob-stat-box { background: #f8fafc; border-radius: 10px; padding: 10px; text-align: center; border: 1px solid #e2e8f0; }
  .mob-stat-num { font-size: 20px; font-weight: 600; color: #1e293b; }
  .mob-stat-label { font-size: 10px; color: #94a3b8; margin-top: 2px; }
  .mob-profile-btn { display: block; width: 100%; padding: 12px; border-radius: 10px; text-align: center; font-size: 14px; font-weight: 600; border: none; cursor: pointer; font-family: inherit; text-decoration: none; margin-bottom: 8px; }
  .mob-btn-primary { background: #0d4c90; color: #fff; }
  .mob-btn-upgrade { background: #f59e0b; color: #1c1917; }
  .mob-btn-outline { background: #fff !important; color: #0d4c90 !important; border: 1.5px solid #0d4c90 !important; }

  /* Search bar mobile */
  .sb-form { flex-wrap: wrap !important; }
  .sb-text { flex: 1 1 100% !important; order: -1 !important; }
  .sb-mode, .sb-jtype, .sb-ind, .sb-qual, .sb-state, .sb-city {
    flex: 1 1 calc(33% - 6px) !important;
    max-width: none !important;
  }
  .sb-btn-search { flex: 1 !important; order: 10 !important; justify-content: center !important; }
  .sb-btn-clear { order: 10 !important; }
}

@media (max-width: 520px) {
  .sb-mode, .sb-jtype, .sb-ind, .sb-qual, .sb-state, .sb-city {
    flex: 1 1 calc(50% - 6px) !important;
  }
}