/* layout.css — Header, Bottom Nav, Containers & Utilities — Redesigned */

/* ================================================
   CONTAINER
   ================================================ */
.container {
  width: 100%;
  max-width: var(--container-max-width);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-4);
  padding-right: var(--space-4);
}

@media (min-width: 640px) {
  .container {
    padding-left: var(--space-6);
    padding-right: var(--space-6);
  }
}

/* ================================================
   APP HEADER
   ================================================ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background-color: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: var(--space-4);
}

/* Brand */
.brand-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.brand-logo {
  height: 36px;
  width: auto;
  object-fit: contain;
}

.brand-title-wrap {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.brand-name {
  font-weight: 800;
  font-size: var(--font-size-sm);
  color: var(--primary-color);
  letter-spacing: -0.3px;
}

.brand-tagline {
  font-size: var(--font-size-2xs);
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 2px;
}

/* Desktop Nav */
.header-nav {
  display: none;
  align-items: center;
  gap: var(--space-1);
}

.nav-link {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-muted);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav-link svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.nav-link:hover {
  color: var(--primary-color);
  background-color: var(--surface-hover);
}

.nav-link.active {
  color: var(--primary-color);
  font-weight: 600;
  background-color: var(--primary-subtle);
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* User Pill */
.user-menu-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 5px var(--space-3) 5px 5px;
  border-radius: var(--radius-pill);
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.user-menu-pill:hover {
  border-color: var(--border-hover);
  background-color: var(--surface-hover);
  box-shadow: var(--shadow-xs);
}

.user-avatar-circle {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-pill);
  background: var(--primary-gradient);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-xs);
  font-weight: 700;
  flex-shrink: 0;
}

.user-display-name {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--text-main);
  max-width: 110px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ================================================
   MOBILE BOTTOM NAVIGATION
   ================================================ */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background-color: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -4px 16px rgba(91, 33, 182, 0.06);
  z-index: 100;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  padding: var(--space-1) 0 env(safe-area-inset-bottom, 0);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-light);
  flex: 1;
  position: relative;
  transition: all var(--transition-fast);
  border-radius: var(--radius-sm);
  margin: 4px 2px;
}

.bottom-nav-item .icon {
  width: 22px;
  height: 22px;
  stroke-width: 1.8;
  transition: all var(--transition-fast);
}

.bottom-nav-item .nav-label {
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.2px;
}

.bottom-nav-item.active {
  color: var(--primary-color);
}

.bottom-nav-item.active .icon {
  stroke-width: 2.2;
}

.bottom-nav-item.active .nav-label {
  font-weight: 700;
}

.bottom-nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  background: var(--primary-color);
  border-radius: 0 0 var(--radius-xs) var(--radius-xs);
}

/* ================================================
   MAIN CONTENT
   ================================================ */
.main-content {
  flex: 1;
  padding-top: var(--space-6);
  padding-bottom: calc(var(--bottom-nav-height) + var(--space-10));
}

/* ================================================
   RESPONSIVE BREAKPOINTS
   ================================================ */
@media (min-width: 768px) {
  .header-nav {
    display: flex;
  }

  .mobile-bottom-nav {
    display: none;
  }

  .main-content {
    padding-bottom: var(--space-16);
  }
}

/* ================================================
   BUTTONS — Unified, consistent system
   ================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-family);
  font-weight: 600;
  font-size: var(--font-size-sm);
  line-height: 1;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-btn);
  border: 1.5px solid transparent;
  transition: all var(--transition-normal);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  letter-spacing: -0.1px;
}

.btn svg {
  flex-shrink: 0;
}

/* Primary */
.btn-primary {
  background: var(--primary-gradient);
  color: #FFFFFF;
  border-color: transparent;
  box-shadow: var(--shadow-btn);
}

.btn-primary:hover {
  background: var(--primary-gradient-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-btn-hover);
}

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

/* Outline */
.btn-outline {
  border-color: var(--border-color);
  background-color: var(--surface-color);
  color: var(--text-secondary);
}

.btn-outline:hover {
  background-color: var(--surface-hover);
  border-color: var(--border-hover);
  color: var(--primary-color);
}

/* Outline Primary */
.btn-outline-primary {
  border-color: var(--primary-color);
  background: transparent;
  color: var(--primary-color);
}

.btn-outline-primary:hover {
  background-color: var(--primary-subtle);
  box-shadow: var(--shadow-glow);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background-color: var(--surface-hover);
  color: var(--primary-color);
}

/* Sizes */
.btn-sm {
  padding: 0.45rem 0.875rem;
  font-size: var(--font-size-xs);
  border-radius: var(--radius-btn-sm);
}

.btn-lg {
  padding: 0.875rem 1.75rem;
  font-size: var(--font-size-base);
  border-radius: var(--radius-btn-lg);
}

.btn-full {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ================================================
   BADGES — Consistent border-radius
   ================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0.2rem 0.55rem;
  font-size: var(--font-size-xs);
  font-weight: 600;
  border-radius: var(--radius-badge);
  line-height: 1.4;
  letter-spacing: 0.1px;
}

.badge-success {
  background-color: var(--success-subtle);
  color: var(--success-color);
}

.badge-warning {
  background-color: var(--warning-subtle);
  color: var(--warning-color);
}

.badge-danger {
  background-color: var(--danger-subtle);
  color: var(--danger-color);
}

.badge-primary {
  background-color: var(--primary-subtle);
  color: var(--primary-color);
}

.badge-neutral {
  background-color: var(--bg-color);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.badge-accent {
  background-color: var(--accent-subtle);
  color: var(--accent-color);
}

/* ================================================
   CARD
   ================================================ */
.card {
  background-color: var(--surface-color);
  border-radius: var(--radius-card);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-card);
  padding: var(--space-5);
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.card:hover {
  box-shadow: var(--shadow-card-hover);
  border-color: var(--border-hover);
}

/* ================================================
   SECTION HEADER
   ================================================ */
.portal-section {
  margin-bottom: var(--space-10);
}

.portal-section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-5);
  gap: var(--space-3);
}

.section-heading {
  font-size: var(--font-size-lg);
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  letter-spacing: -0.4px;
  line-height: var(--lh-snug);
}

.section-heading svg {
  width: 22px;
  height: 22px;
  color: var(--primary-color);
  flex-shrink: 0;
}

.section-sub {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-top: var(--space-1);
  font-weight: 400;
  line-height: var(--lh-relaxed);
}

/* ================================================
   FORM CONTROLS
   ================================================ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.form-label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-secondary);
}

.form-control {
  width: 100%;
  height: 46px;
  padding: 0 var(--space-4);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-input);
  background-color: var(--surface-color);
  color: var(--text-main);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
}

.form-control::placeholder {
  color: var(--text-placeholder);
}

.form-control:hover {
  border-color: var(--border-hover);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: var(--shadow-glow);
  background-color: var(--surface-color);
}

/* ================================================
   TOAST NOTIFICATIONS
   ================================================ */
#toast-container {
  position: fixed;
  top: calc(var(--header-height) + var(--space-3));
  right: var(--space-4);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: min(90vw, 360px);
  width: 100%;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  background-color: var(--surface-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-popup);
  border: 1px solid var(--border-color);
  padding: var(--space-3) var(--space-4);
  color: var(--text-main);
  animation: slideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  pointer-events: auto;
}

.toast-success { border-left: 4px solid var(--success-color); }
.toast-error   { border-left: 4px solid var(--danger-color); }
.toast-info    { border-left: 4px solid var(--primary-color); }

.toast-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 2px;
}

.toast-message {
  font-size: var(--font-size-sm);
  line-height: var(--lh-relaxed);
  flex: 1;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(16px) scale(0.96); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes fadeOut {
  to { opacity: 0; transform: translateX(8px); }
}

/* ================================================
   SPINNER
   ================================================ */
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #FFFFFF;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

.spinner-primary {
  border-color: var(--primary-subtle-deep);
  border-top-color: var(--primary-color);
}

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

/* ================================================
   UTILITIES
   ================================================ */
.text-muted   { color: var(--text-muted); }
.text-primary { color: var(--primary-color); }
.text-success { color: var(--success-color); }
.text-danger  { color: var(--danger-color); }

.font-medium  { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold    { font-weight: 700; }
.font-extrabold { font-weight: 800; }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
