/* ==========================================================================
   Đông Hòa Group — Minimalist White App UI
   ========================================================================== */

:root {
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-hover: #f8fafc;

  --border-light: #e2e8f0;
  --border-focus: #3b82f6;

  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;

  --accent: #2563eb;
  --accent-soft: #eff6ff;

  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.04);
  --shadow-card: 0 12px 32px -8px rgba(15, 23, 42, 0.07), 0 2px 6px rgba(15, 23, 42, 0.03);
  --shadow-float: 0 20px 44px -12px rgba(15, 23, 42, 0.14);

  --font-sans: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --transition: 200ms cubic-bezier(0.22, 1, 0.36, 1);
}

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

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   Loading Screen (Minimal White Splash)
   ========================================================================== */
.loader-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

.loader-screen.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-logo-wrap {
  position: relative;
  width: 96px;
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.loader-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2.5px solid #e2e8f0;
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

.loader-icon {
  width: 68px;
  height: 68px;
  border-radius: 18px;
  object-fit: cover;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.16);
}

.loader-title {
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.loader-bar-track {
  width: 180px;
  height: 4px;
  background: var(--bg-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.loader-bar-fill {
  width: 0%;
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--accent);
  transition: width 0.12s linear;
}

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

/* ==========================================================================
   App Shell & Top Bar
   ========================================================================== */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.45s ease, transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.app-shell.is-ready {
  opacity: 1;
  transform: translateY(0);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-light);
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  color: inherit;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: var(--shadow-sm);
}

.brand-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary {
  padding: 10px 18px;
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.24);
}

.btn-primary:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}

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

.btn-soft {
  padding: 10px 16px;
  color: var(--text-primary);
  background: var(--bg-subtle);
}

.btn-soft:hover {
  background: #e2e8f0;
}

.btn-ghost {
  padding: 9px 14px;
  color: var(--text-secondary);
  background: transparent;
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--bg-subtle);
}

.btn-lg {
  padding: 13px 24px;
  font-size: 0.95rem;
  border-radius: 14px;
}

.btn-full {
  width: 100%;
}

/* Dropdown Menu */
.menu-dropdown-wrap {
  position: relative;
}

.dropdown-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 248px;
  padding: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-float);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(0.98);
  transition: all 0.18s ease;
  z-index: 100;
}

.dropdown-panel.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background var(--transition);
}

.dropdown-item:hover {
  background: var(--bg-subtle);
}

.dropdown-item-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ==========================================================================
   Main Container & Stepper
   ========================================================================== */
.main-container {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 36px 20px 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.flow-stepper {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  margin-bottom: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-sm);
}

.step-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: transparent;
  font-family: inherit;
  transition: all var(--transition);
}

.step-chip.is-active {
  color: var(--accent);
  background: var(--accent-soft);
}

.step-chip.is-completed {
  color: #059669;
}

.step-arrow {
  color: var(--border-light);
  font-size: 0.85rem;
}

/* Views */
.view-section {
  width: 100%;
  display: none;
  animation: fadeUp 0.3s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.view-section.is-active {
  display: block;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   View 1: Trang chủ (Minimal App Card)
   ========================================================================== */
.app-home-card {
  max-width: 440px;
  margin: 12px auto 0;
  padding: 44px 32px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  text-align: center;
}

.home-app-icon {
  width: 76px;
  height: 76px;
  border-radius: 20px;
  object-fit: cover;
  margin-bottom: 20px;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.16);
}

.home-title {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.home-sub {
  font-size: 0.94rem;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

/* ==========================================================================
   View 2: Chọn phòng ban (App Tiles)
   ========================================================================== */
.section-heading {
  text-align: center;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 22px;
}

.dept-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  max-width: 560px;
  margin: 0 auto;
}

.dept-tile {
  padding: 22px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  font-family: inherit;
  color: inherit;
  transition: all var(--transition);
}

.dept-tile:hover {
  transform: translateY(-2px);
  border-color: #cbd5e1;
  box-shadow: var(--shadow-card);
}

.dept-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.dept-info {
  flex: 1;
}

.dept-info strong {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.dept-info span {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.dept-chevron {
  color: var(--text-muted);
  transition: transform var(--transition);
}

.dept-tile:hover .dept-chevron {
  transform: translateX(3px);
  color: var(--accent);
}

/* ==========================================================================
   View 3: Đăng nhập (Minimal App Sheet)
   ========================================================================== */
.login-card {
  max-width: 400px;
  margin: 0 auto;
  padding: 32px 28px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.login-dept-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 6px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  margin-bottom: 20px;
  font-size: 0.85rem;
  font-weight: 600;
}

.login-dept-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-heading {
  font-size: 1.35rem;
  font-weight: 800;
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.input-box {
  position: relative;
  display: flex;
  align-items: center;
}

.form-input {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.92rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus {
  outline: none;
  background: #ffffff;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.14);
}

.toggle-pw {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
}

.login-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 20px;
}

.login-back-row {
  margin-top: 14px;
  text-align: center;
}

/* Soft Department Icon Colors */
.bg-admin { background: #eef2ff; color: #4f46e5; }
.bg-sale { background: #eff6ff; color: #2563eb; }
.bg-mkt { background: #ecfeff; color: #0891b2; }
.bg-cskh { background: #ecfdf5; color: #059669; }

/* Responsive */
@media (max-width: 560px) {
  .topbar {
    padding: 12px 16px;
  }
  .dept-grid {
    grid-template-columns: 1fr;
  }
  .app-home-card {
    padding: 36px 22px;
  }
}
