/* ==========================================================================
   IPDC Unified Management Portal - Modern Responsive CSS
   Theme: Glassmorphism Dark & Light Theme Switcher
   ========================================================================== */

:root {
  /* Dark Mode Defaults */
  --bg-primary: #060a14;
  --bg-secondary: #0b1222;
  --bg-card: rgba(14, 23, 42, 0.78);
  --bg-card-hover: rgba(22, 34, 60, 0.88);
  --bg-surface: rgba(255, 255, 255, 0.035);
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(99, 102, 241, 0.35);

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

  --accent-primary: #6366f1; /* Indigo */
  --accent-cyan: #06b6d4;    /* Cyan */
  --accent-emerald: #10b981; /* Emerald */
  --accent-amber: #f59e0b;   /* Amber */
  --accent-rose: #f43f5e;    /* Rose */

  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.38);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.55);

  --font-main: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
  --font-brand: 'Outfit', 'Pretendard', sans-serif;
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.92);
  --bg-card-hover: #ffffff;
  --bg-surface: rgba(0, 0, 0, 0.03);
  --border: rgba(0, 0, 0, 0.09);
  --border-hover: rgba(99, 102, 241, 0.35);

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

  --accent-primary: #4f46e5;
  --accent-cyan: #0284c7;
  --accent-emerald: #059669;
  --accent-amber: #d97706;
  --accent-rose: #e11d48;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.12);
}

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

html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  position: relative;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Background Glow Orbs */
.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.45;
  transition: opacity 0.3s;
}
[data-theme="light"] .bg-glow { opacity: 0.18; }
.orb-1 {
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.4), transparent 70%);
  top: -100px;
  left: -80px;
}
.orb-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.35), transparent 70%);
  bottom: -120px;
  right: -100px;
}
.orb-3 {
  width: 380px;
  height: 380px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.25), transparent 70%);
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Header */
.portal-header {
  position: relative;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: rgba(11, 18, 34, 0.7);
  transition: background 0.3s;
}
[data-theme="light"] .portal-header {
  background: rgba(255, 255, 255, 0.85);
}
.portal-header-container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.35);
}
.brand-icon i { width: 22px; height: 22px; }
.brand-title {
  font-family: var(--font-brand);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-primary);
  line-height: 1.2;
}
.brand-title .dot { color: var(--accent-cyan); }
.brand-sub {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.2px;
}

.header-right-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.auth-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.75rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
}
.auth-status-pill.authed {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--accent-emerald);
}
.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
}
.auth-status-pill.authed .pulse-dot {
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}

/* Theme Toggle Button */
.theme-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}
.theme-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
  background: rgba(255, 255, 255, 0.08);
}
.theme-btn i { width: 17px; height: 17px; }

[data-theme="dark"] .sun-icon { display: block; }
[data-theme="dark"] .moon-icon { display: none; }
[data-theme="light"] .sun-icon { display: none; }
[data-theme="light"] .moon-icon { display: block; }

.btn-portal-logout {
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.25);
  color: var(--accent-rose);
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  font-size: 0.76rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-portal-logout:hover {
  background: rgba(244, 63, 94, 0.2);
}
.btn-portal-logout i { width: 14px; height: 14px; }

/* Main Area */
.portal-main {
  flex: 1;
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.5rem;
}

.portal-card {
  width: 100%;
  max-width: 1040px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: 24px;
  padding: 2.5rem 2.25rem;
  box-shadow: var(--shadow-lg);
  transition: all 0.3s;
}

.card-hero-header {
  text-align: center;
  margin-bottom: 2rem;
}
.hero-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.35);
  color: var(--accent-primary);
  border-radius: 9999px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin-bottom: 0.75rem;
}
.hero-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  margin-bottom: 0.5rem;
}
.hero-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

/* System Grid (3 Systems) */
.system-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  margin-bottom: 2rem;
}
@media (max-width: 960px) {
  .system-grid {
    grid-template-columns: 1fr;
  }
}

.system-card {
  background: var(--bg-surface);
  border: 2px solid var(--border);
  border-radius: 18px;
  padding: 1.35rem 1.25rem;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  position: relative;
  user-select: none;
}
.system-card:hover {
  border-color: var(--border-hover);
  background: rgba(255, 255, 255, 0.05);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
[data-theme="light"] .system-card:hover {
  background: #ffffff;
}

.system-card.active {
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.07);
  box-shadow: 0 0 24px rgba(99, 102, 241, 0.2);
}
[data-theme="light"] .system-card.active {
  background: #ffffff;
  border-color: var(--accent-primary);
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.15);
}

.system-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.system-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: transform 0.2s;
}
.system-card:hover .system-icon { transform: scale(1.06); }
.system-icon.kpi {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}
.system-icon.budget {
  background: linear-gradient(135deg, #06b6d4, #10b981);
  box-shadow: 0 4px 14px rgba(6, 182, 212, 0.35);
}
.system-icon.blog {
  background: linear-gradient(135deg, #f59e0b, #ec4899);
  box-shadow: 0 4px 14px rgba(236, 72, 153, 0.35);
}
.system-icon i { width: 22px; height: 22px; }

.system-radio {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.system-card.active .system-radio {
  border-color: var(--accent-primary);
}
.radio-circle {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: transparent;
  transition: all 0.2s;
}
.system-card.active .radio-circle {
  background: var(--accent-primary);
  box-shadow: 0 0 8px var(--accent-primary);
}

.system-name-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.45rem;
}
.system-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-primary);
}
.system-path-tag {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.system-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.45;
  margin-bottom: 0.85rem;
  min-height: 48px;
}

.system-badges {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.badge-feature {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
}
.system-card.active .badge-feature {
  color: var(--accent-primary);
  border-color: rgba(99, 102, 241, 0.25);
  background: rgba(99, 102, 241, 0.05);
}

/* Login Form Area */
.portal-login-form {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
[data-theme="light"] .portal-login-form {
  background: rgba(0, 0, 0, 0.02);
}

.form-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.65rem;
}
.form-title-row label {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.form-title-row label i { width: 15px; height: 15px; color: var(--accent-primary); }
.form-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.password-input-group {
  position: relative;
  display: flex;
  align-items: center;
}
.input-icon {
  position: absolute;
  left: 1rem;
  color: var(--text-muted);
  width: 18px;
  height: 18px;
  pointer-events: none;
}
.portal-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 3rem 0.9rem 2.75rem;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: all 0.2s;
}
[data-theme="light"] .portal-input {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.15);
}
.portal-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

.btn-toggle-pw {
  position: absolute;
  right: 0.75rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-toggle-pw:hover { color: var(--text-primary); }
.btn-toggle-pw i { width: 18px; height: 18px; }

.portal-error-text {
  min-height: 1.3rem;
  font-size: 0.8rem;
  color: var(--accent-rose);
  font-weight: 700;
  margin-top: 0.5rem;
  padding-left: 0.25rem;
}

.btn-portal-submit {
  width: 100%;
  margin-top: 0.5rem;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  border: none;
  color: #fff;
  padding: 0.95rem 1.5rem;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.35);
  transition: all 0.2s;
}
.btn-portal-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(99, 102, 241, 0.45);
}
.btn-portal-submit:active { transform: translateY(0); }
.btn-portal-submit i { width: 20px; height: 20px; }

/* Active Auth Box (Already Logged In) */
.auth-active-box {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 18px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.active-notice {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.active-notice i { width: 22px; height: 22px; flex-shrink: 0; margin-top: 2px; }
.active-notice strong { display: block; font-size: 0.95rem; color: var(--text-primary); margin-bottom: 0.2rem; }
.active-notice span { font-size: 0.8rem; color: var(--text-secondary); }

.btn-enter-primary {
  width: 100%;
  background: linear-gradient(135deg, #10b981, #06b6d4);
  border: none;
  color: #fff;
  padding: 0.95rem 1.5rem;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.3);
  transition: all 0.2s;
  margin-bottom: 0.85rem;
}
.btn-enter-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(16, 185, 129, 0.4);
}
.btn-enter-primary i { width: 20px; height: 20px; }

.active-secondary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}
@media (max-width: 860px) {
  .active-secondary-grid {
    grid-template-columns: 1fr;
  }
}
.btn-quick-link {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-primary);
  text-decoration: none;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all 0.2s;
}
.btn-quick-link:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-hover);
}
.btn-quick-link i { width: 15px; height: 15px; color: var(--accent-cyan); }

/* Footer */
.portal-footer {
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.76rem;
  color: var(--text-muted);
}
.home-link {
  color: var(--text-secondary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
}
.home-link:hover { color: var(--accent-primary); }
.home-link i { width: 14px; height: 14px; }

/* Responsive Mobile Optimization */
@media (max-width: 640px) {
  .portal-header-container {
    padding: 0.65rem 0.85rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .brand-sub {
    display: none;
  }
  .brand-icon {
    width: 32px;
    height: 32px;
  }
  .brand-icon i {
    width: 18px;
    height: 18px;
  }
  .brand-title {
    font-size: 1rem;
  }
  .header-right-actions {
    gap: 0.4rem;
  }
  .auth-status-pill {
    padding: 0.25rem 0.55rem;
    font-size: 0.7rem;
  }
  .portal-main {
    padding: 1.25rem 0.75rem;
    width: 100%;
  }
  .portal-card {
    padding: 1.5rem 1rem;
    border-radius: 20px;
    width: 100%;
    max-width: 100%;
  }
  .hero-title {
    font-size: 1.35rem;
    word-break: keep-all;
  }
  .hero-desc {
    font-size: 0.8rem;
    word-break: keep-all;
  }
  .system-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }
  .system-card {
    padding: 1.1rem 1rem;
  }
  .system-desc {
    min-height: auto;
    font-size: 0.78rem;
    word-break: keep-all;
  }
  .active-secondary-grid {
    grid-template-columns: 1fr;
  }
  .portal-footer {
    flex-direction: column;
    gap: 0.65rem;
    text-align: center;
  }
}

@media (max-width: 380px) {
  .portal-header-container {
    padding: 0.5rem 0.65rem;
  }
  .portal-card {
    padding: 1.25rem 0.75rem;
  }
  .hero-title {
    font-size: 1.2rem;
  }
}

/* ==========================================================================
   Session Countdown Timer Pill
   ========================================================================== */
.session-timer-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  padding: 0.3rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.76rem;
  color: var(--text-secondary);
  user-select: none;
  transition: all 0.3s ease;
}
[data-theme="light"] .session-timer-pill {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.1);
  color: var(--text-primary);
}
.session-timer-pill i {
  width: 14px;
  height: 14px;
  color: var(--accent-cyan);
}
.session-timer-pill strong {
  font-family: 'Outfit', 'Inter', monospace;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: 0.5px;
  margin-left: 0.2rem;
}
.session-timer-pill .btn-extend-session {
  background: rgba(99, 102, 241, 0.18);
  border: 1px solid rgba(99, 102, 241, 0.4);
  color: var(--accent-primary);
  font-size: 0.68rem;
  font-weight: 800;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  margin-left: 0.15rem;
}
.session-timer-pill .btn-extend-session:hover {
  background: var(--accent-primary);
  color: #fff;
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.4);
}
.session-timer-pill.danger {
  border-color: rgba(244, 63, 94, 0.6);
  background: rgba(244, 63, 94, 0.12);
  animation: pulseTimer 1.2s infinite;
}
.session-timer-pill.danger i,
.session-timer-pill.danger strong {
  color: var(--accent-rose);
}
@keyframes pulseTimer {
  0%, 100% { box-shadow: 0 0 0 rgba(244, 63, 94, 0); }
  50% { box-shadow: 0 0 12px rgba(244, 63, 94, 0.35); }
}
