/* ===== HCM App — Shared Styles ===== */
:root {
  --primary: #1E3A5F;
  --primary-dark: #152B47;
  --primary-light: #2A5080;
  --secondary: #D4A017;
  --secondary-light: #F0C850;
  --bg: #F5F7FA;
  --bg-card: #FFFFFF;
  --text: #1A2332;
  --text-muted: #6B7A8D;
  --border: #E2E8F0;
  --success: #22C55E;
  --warning: #F59E0B;
  --danger: #EF4444;
  --info: #3B82F6;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.12);
  --sidebar-width: 260px;
  --header-height: 60px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; }
a { color: var(--primary); text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ===== Login Page ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
}

.login-card {
  background: white;
  border-radius: 16px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-logo { font-size: 32px; font-weight: 800; color: var(--primary); margin-bottom: 4px; }
.login-subtitle { font-size: 14px; color: var(--text-muted); margin-bottom: 32px; }

.form-group { margin-bottom: 20px; text-align: left; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13,115,119,0.1);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border: none; border-radius: var(--radius);
  font-size: 14px; font-weight: 600; transition: all 0.2s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--secondary); color: white; }
.btn-secondary:hover { background: #B8890F; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #DC2626; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #16A34A; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.login-btn { width: 100%; padding: 12px; font-size: 16px; margin-top: 8px; }
.login-error { color: var(--danger); font-size: 13px; margin-top: 12px; display: none; }
.login-footer { margin-top: 24px; font-size: 12px; color: var(--text-muted); }

/* Language toggle */
.lang-toggle {
  position: absolute; top: 20px; right: 20px; display: flex; gap: 4px;
  background: rgba(255,255,255,0.15); border-radius: 20px; padding: 3px;
}
.lang-btn {
  padding: 6px 14px; border: none; border-radius: 16px;
  font-size: 12px; font-weight: 600; background: transparent; color: rgba(255,255,255,0.7); cursor: pointer;
}
.lang-btn.active { background: white; color: var(--primary); }

/* ===== App Layout ===== */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width); background: var(--primary-dark); color: white;
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
}

.sidebar-header {
  padding: 20px 24px; border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-logo { font-size: 24px; font-weight: 800; }
.sidebar-user { font-size: 12px; color: rgba(255,255,255,0.6); margin-top: 4px; }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  border-radius: var(--radius); color: rgba(255,255,255,0.7); font-size: 14px;
  cursor: pointer; transition: all 0.2s; margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,0.1); color: white; }
.nav-item.active { background: var(--primary); color: white; }
.nav-item .nav-icon { font-size: 18px; width: 24px; text-align: center; }
.nav-section { font-size: 11px; text-transform: uppercase; color: rgba(255,255,255,0.4); padding: 16px 16px 8px; font-weight: 600; letter-spacing: 0.5px; }

.sidebar-footer {
  padding: 16px 12px; border-top: 1px solid rgba(255,255,255,0.1);
}

.main-content {
  flex: 1; margin-left: var(--sidebar-width); padding: 24px 32px; min-height: 100vh;
}

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-title { font-size: 24px; font-weight: 700; }

/* ===== Cards ===== */
.card {
  background: var(--bg-card); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 24px; margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 16px; font-weight: 700; }

/* Stat cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border);
  padding: 20px; box-shadow: var(--shadow);
}
.stat-value { font-size: 28px; font-weight: 800; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ===== Tables ===== */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
th { font-weight: 600; color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; background: var(--bg); }
tr:hover td { background: rgba(13,115,119,0.03); }

/* ===== Badges ===== */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 12px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
}
.badge-draft { background: #F1F5F9; color: #64748B; }
.badge-active { background: #DCFCE7; color: #166534; }
.badge-closed { background: #FEE2E2; color: #991B1B; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center;
  z-index: 1000; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: white; border-radius: 12px; padding: 32px; width: 90%; max-width: 560px;
  max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal-title { font-size: 20px; font-weight: 700; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }

/* ===== Pillar Scorecard ===== */
.pillar-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.pillar-card {
  background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border);
  padding: 20px; cursor: pointer; transition: all 0.2s; box-shadow: var(--shadow);
}
.pillar-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.pillar-name { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.pillar-score { font-size: 32px; font-weight: 800; }
.pillar-score.score-low { color: var(--danger); }
.pillar-score.score-mid { color: var(--warning); }
.pillar-score.score-high { color: var(--success); }
.pillar-bar { height: 6px; background: var(--border); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.pillar-bar-fill { height: 100%; border-radius: 3px; transition: width 0.5s ease; }

/* ===== Survey (public) ===== */
.survey-page {
  min-height: 100vh; background: var(--bg);
  display: flex; flex-direction: column; align-items: center;
}

.survey-header {
  width: 100%; background: var(--primary); color: white; padding: 20px 24px;
  text-align: center;
}
.survey-header h1 { font-size: 20px; font-weight: 700; }
.survey-header p { font-size: 13px; opacity: 0.8; margin-top: 4px; }

.survey-container {
  width: 100%; max-width: 720px; padding: 24px 16px;
}

.progress-bar-container { margin-bottom: 24px; }
.progress-label { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; display: flex; justify-content: space-between; }
.progress-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width 0.4s ease; }

.question-card {
  background: white; border-radius: var(--radius); border: 1px solid var(--border);
  padding: 24px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.question-number { font-size: 12px; color: var(--primary); font-weight: 700; margin-bottom: 8px; }
.question-text { font-size: 16px; font-weight: 500; margin-bottom: 16px; line-height: 1.5; }

.likert-scale { display: flex; gap: 8px; justify-content: space-between; }
.likert-option {
  flex: 1; text-align: center;
}
.likert-option input[type="radio"] { display: none; }
.likert-option label {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 8px;
  border: 2px solid var(--border); border-radius: var(--radius); cursor: pointer;
  transition: all 0.2s; font-size: 12px; color: var(--text-muted);
}
.likert-option label .likert-num { font-size: 18px; font-weight: 700; color: var(--text); }
.likert-option input:checked + label {
  border-color: var(--primary); background: rgba(13,115,119,0.05); color: var(--primary);
}
.likert-option input:checked + label .likert-num { color: var(--primary); }

.open-textarea {
  width: 100%; min-height: 100px; padding: 12px; border: 1px solid var(--border);
  border-radius: var(--radius); resize: vertical; font-size: 14px;
}

.survey-nav {
  display: flex; justify-content: space-between; margin-top: 24px; gap: 12px;
}

.thank-you-card {
  text-align: center; padding: 60px 40px;
  background: white; border-radius: 16px; box-shadow: var(--shadow-lg); margin-top: 40px;
}
.thank-you-icon { font-size: 64px; margin-bottom: 16px; }
.thank-you-title { font-size: 28px; font-weight: 700; color: var(--primary); margin-bottom: 12px; }

/* ===== Charts container ===== */
.chart-container { position: relative; height: 300px; margin: 16px 0; }
.chart-container-sm { height: 200px; }

/* ===== Question list (builder) ===== */
.question-list { list-style: none; }
.question-list-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 8px; background: white;
}
.question-list-item .q-order { font-weight: 700; color: var(--text-muted); min-width: 30px; }
.question-list-item .q-text { flex: 1; font-size: 14px; }
.question-list-item .q-pillar { font-size: 11px; color: var(--primary); font-weight: 600; }
.question-list-item .q-type { font-size: 11px; }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 24px; right: 24px; padding: 12px 24px;
  background: var(--text); color: white; border-radius: var(--radius);
  font-size: 14px; box-shadow: var(--shadow-lg); z-index: 9999;
  transform: translateY(100px); opacity: 0; transition: all 0.3s;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* ===== Score distribution bar ===== */
.dist-bar { display: flex; height: 24px; border-radius: 4px; overflow: hidden; gap: 1px; }
.dist-segment { transition: width 0.4s; display: flex; align-items: center; justify-content: center; font-size: 10px; color: white; font-weight: 600; }
.dist-1 { background: #EF4444; }
.dist-2 { background: #F97316; }
.dist-3 { background: #84CC16; }
.dist-4 { background: #22C55E; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .pillar-grid { grid-template-columns: 1fr; }
  .likert-scale { flex-wrap: wrap; }
  .likert-option { min-width: 60px; }
  .modal { padding: 24px 16px; width: 95%; }

  .mobile-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; background: var(--primary-dark); color: white;
    position: sticky; top: 0; z-index: 50;
  }
  .mobile-header .menu-btn { background: none; border: none; color: white; font-size: 24px; cursor: pointer; }
  .sidebar.mobile-open { display: flex; }
}

@media (min-width: 769px) {
  .mobile-header { display: none; }
}

/* ===== Loading spinner ===== */
.spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Tabs ===== */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 20px; gap: 4px; }
.tab {
  padding: 10px 20px; font-size: 14px; font-weight: 600; color: var(--text-muted);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.2s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ===== Hidden ===== */
.hidden { display: none !important; }
.view { display: none; }
.view.active { display: block; }
