/* ===== RESET & VARIABLES ===== */
*,*::before,*::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #f75f16;
  --primary-dark: #d94e0d;
  --primary-light: #fff3ee;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --sidebar-bg: #1e293b;
  --sidebar-hover: #334155;
  --header-bg: #ffffff;
  --body-bg: #f1f5f9;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --sidebar-w: 260px;
  --header-h: 60px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--body-bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

/* ===== AUTH SCREEN ===== */
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
}

.auth-container {
  background: #fff;
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 25px 60px rgba(0,0,0,.35);
}

.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo .logo-icon { font-size: 48px; margin-bottom: 4px; }
.auth-logo h1 { font-size: 26px; color: var(--primary); letter-spacing: -.5px; }
.auth-logo p { color: var(--text-light); font-size: 14px; margin-top: 4px; }

.auth-form h2 { margin-bottom: 18px; text-align: center; font-size: 20px; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 500; font-size: 14px; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(247,95,22,.12);
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .1s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-success { background: var(--success); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--body-bg); }
.btn-full { width: 100%; padding: 13px; font-size: 15px; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

.auth-switch { text-align: center; margin-top: 18px; font-size: 14px; color: var(--text-light); }
.auth-switch a { color: var(--primary); cursor: pointer; font-weight: 600; }
.auth-switch a:hover { text-decoration: underline; }

.error-msg {
  background: #fef2f2;
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 8px;
  margin-top: 14px;
  text-align: center;
  font-size: 14px;
}

/* ===== DASHBOARD LAYOUT ===== */
.dashboard { display: flex; flex-direction: column; height: 100vh; }

/* ===== TOP NAVIGATION BAR (Facebook-style) ===== */
.topnav {
  background: var(--header-bg);
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 4px rgba(0,0,0,.06);
  position: sticky;
  top: 0;
  z-index: 200;
  flex-shrink: 0;
}

/* Left: Logo */
.topnav-left { display: flex; align-items: center; min-width: 180px; }
.topnav-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-decoration: none;
}
.topnav-logo .logo-icon-sm { font-size: 28px; }
.topnav-logo h2 { font-size: 20px; font-weight: 800; color: var(--primary); letter-spacing: -.5px; white-space: nowrap; }

/* Center: Nav buttons */
.topnav-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: 1;
  max-width: 600px;
  margin: 0 auto;
}
.topnav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 20px;
  min-width: 80px;
  margin-top: 4px;
  height: var(--header-h);
  border-radius: 8px;
  color: var(--text-light);
  text-decoration: none;
  cursor: pointer;
  position: relative;
  transition: background .15s, color .15s;
  border-bottom: 3px solid transparent;
  border-top: 3px solid transparent;
}
.topnav-btn:hover {
  background: var(--body-bg);
  color: var(--primary);
}
.topnav-btn.active {
  color: var(--primary);
  background: transparent;
  border-bottom-color: var(--primary);
  border-radius: 0;
}
.topnav-icon { font-size: 20px; line-height: 1; }
.topnav-label { font-size: 11px; font-weight: 500; margin-top: 2px; white-space: nowrap; }

/* Right: User info */
.topnav-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 180px;
  justify-content: flex-end;
}
.topnav-logout {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--body-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  transition: background .15s;
  text-decoration: none;
}
.topnav-logout:hover { background: var(--border); }

.user-name { font-weight: 500; font-size: 14px; }
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

/* ===== MOBILE BOTTOM NAV ===== */
.bottomnav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--header-bg);
  border-top: 1px solid var(--border);
  z-index: 200;
  justify-content: space-around;
  padding: 6px 0;
  box-shadow: 0 -1px 4px rgba(0,0,0,.06);
}
.bottomnav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 40px;
  border-radius: 8px;
  font-size: 20px;
  color: var(--text-light);
  text-decoration: none;
  cursor: pointer;
  transition: color .15s;
}
.bottomnav-btn.active { color: var(--primary); }

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* iframe */
.content-wrapper { flex: 1; overflow: hidden; position: relative; }
.content-frame { width: 100%; height: 100%; border: none; background: var(--body-bg); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .topnav-center { display: none; }
  .topnav-left .topnav-logo h2 { display: none; }
  .user-name { display: none; }
  .bottomnav { display: flex; }
  .main-content { padding-bottom: 52px; }
}

/* ===== GLOBAL LOADING BAR ===== */
#global-loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  z-index: 999999;
  pointer-events: none;
  opacity: 0;
}
#global-loading-bar .loading-bar-inner {
  height: 100%;
  width: 30%;
  border-radius: 0 2px 2px 0;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark), var(--primary));
  box-shadow: 0 0 8px var(--primary);
}
#global-loading-bar.loading-bar-active {
  opacity: 1;
}
#global-loading-bar.loading-bar-active .loading-bar-inner {
  animation: loadingSlide 1.2s cubic-bezier(.4,0,.6,1) infinite;
}
#global-loading-bar.loading-bar-done {
  opacity: 0;
  transition: opacity .3s;
}
@keyframes loadingSlide {
  0%   { transform: translateX(-100%); }
  50%  { transform: translateX(250%); }
  100% { transform: translateX(-100%); }
}

/* ===== TOAST NOTIFICATIONS ===== */
#toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 300px;
  max-width: 440px;
  padding: 14px 18px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 30px rgba(0,0,0,.12);
  font-size: 14px;
  color: var(--text);
  transform: translateX(120%);
  opacity: 0;
  transition: transform .35s cubic-bezier(.4,0,.2,1), opacity .35s;
}
.toast-visible { transform: translateX(0); opacity: 1; }
.toast-icon {
  flex-shrink: 0;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-size: 14px; font-weight: 700; color: #fff;
}
.toast-error .toast-icon  { background: var(--danger); }
.toast-success .toast-icon { background: var(--success); }
.toast-warning .toast-icon { background: var(--warning); }
.toast-info .toast-icon    { background: var(--primary); }
.toast-msg { flex: 1; line-height: 1.4; }
.toast-close {
  background: none; border: none; cursor: pointer;
  font-size: 18px; color: var(--text-light);
  padding: 0 0 0 6px;
}

/* ===== CONFIRM DIALOG ===== */
.toast-overlay {
  position: fixed; inset: 0;
  z-index: 100000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.35);
  opacity: 0;
  transition: opacity .25s;
}
.toast-overlay-visible { opacity: 1; }
.toast-dialog {
  background: #fff;
  border-radius: 16px;
  padding: 32px 28px 24px;
  width: 380px;
  max-width: 92vw;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
  transform: scale(.9);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}
.toast-overlay-visible .toast-dialog { transform: scale(1); }
.toast-dialog-icon {
  width: 48px; height: 48px;
  margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: #fef3c7;
  font-size: 22px;
}
.toast-dialog-msg {
  font-size: 15px;
  color: var(--text);
  margin-bottom: 24px;
  line-height: 1.6;
}
.toast-dialog-btns {
  display: flex; gap: 12px; justify-content: center;
}
.toast-btn {
  padding: 10px 28px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .1s;
}
.toast-btn:active { transform: scale(.96); }
.toast-btn-cancel {
  background: var(--body-bg);
  color: var(--text-light);
}
.toast-btn-cancel:hover { background: var(--border); }
.toast-btn-ok {
  background: var(--danger);
  color: #fff;
}
.toast-btn-ok:hover { background: #dc2626; }

/* ===== FULLSCREEN POPUP ===== */
.popup-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0;
  transition: opacity .25s ease;
}
.popup-overlay.popup-visible { opacity: 1; }

.popup-container {
  width: 100%; max-width: 600px; height: 95vh;
  background: var(--card-bg, #fff);
  border-radius: 18px 18px 0 0;
  display: flex; flex-direction: column;
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.22,1,.36,1);
  overflow: hidden;
  box-shadow: 0 -4px 32px rgba(0,0,0,.18);
}
.popup-visible .popup-container { transform: translateY(0); }

.popup-header {
  display: flex; align-items: center; justify-content: flex-end;
  padding: 10px 14px 6px;
  flex-shrink: 0;
}
.popup-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-light, #64748b);
  padding: 6px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.popup-close:hover { background: var(--border, #e2e8f0); }

.popup-body {
  flex: 1; overflow: hidden;
}
.popup-iframe {
  width: 100%; height: 100%; border: none;
}
@media (max-width: 640px) {
  .popup-container { max-width: 100%; height: 100vh; border-radius: 0; }
}

/* ===== FULLSCREEN IFRAME OVERLAY ===== */
.fullscreen-overlay {
  position: fixed; inset: 0; z-index: 9500;
  background: #fff;
  opacity: 0;
  transition: opacity .25s ease;
  display: flex; flex-direction: column;
}
.fullscreen-overlay.fullscreen-visible { opacity: 1; }

.fullscreen-close {
  position: fixed; top: 12px; right: 12px; z-index: 9600;
  background: rgba(0,0,0,.55); border: none; cursor: pointer;
  color: #fff; width: 40px; height: 40px;
  border-radius: 50%; display: flex;
  align-items: center; justify-content: center;
  transition: background .2s, transform .15s;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.fullscreen-close:hover { background: rgba(0,0,0,.75); transform: scale(1.1); }

.fullscreen-body {
  flex: 1; width: 100%; height: 100%;
}
.fullscreen-iframe {
  width: 100%; height: 100%; border: none;
}
