/* ═══════════════════════════════════════════
   GATE — Global styles
   Matches BARN's purple brand language
════════════════════════════════════════════ */

/* Google Fonts — DM Sans (matches BARN's clean sans) */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&display=swap');

/* ── Brand tokens ─────────────────────────── */
:root {
  --brand:        #6B4EBA;
  --brand-dark:   #5A3FA3;
  --brand-light:  #EDE9F8;
  --brand-mid:    #AFA9EC;
  --brand-border: rgba(107, 78, 186, 0.2);

  --bg-page:      #F0EEF8;
  --bg-card:      #FFFFFF;
  --bg-hover:     #F7F5FD;

  --text-primary:   #1A1523;
  --text-secondary: #6B6582;
  --text-tertiary:  #9E99AF;

  --border:       rgba(107, 78, 186, 0.15);
  --border-hover: rgba(107, 78, 186, 0.3);

  --radius-sm:  8px;
  --radius-md:  12px;
  --radius-lg:  16px;
  --radius-xl:  20px;

  --shadow-card: 0 1px 3px rgba(107, 78, 186, 0.06), 0 4px 16px rgba(107, 78, 186, 0.04);
}

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

html, body {
  height: 100%;
  font-family: 'DM Sans', sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* ── Utilities ───────────────────────────── */
.hidden { display: none !important; }

.screen {
  min-height: 100vh;
  width: 100%;
}

/* ═══════════════════════════════════════════
   LOGIN SCREEN
════════════════════════════════════════════ */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--bg-page);
}

.login-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 40px 32px 36px;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  box-shadow: var(--shadow-card);
  border: 0.5px solid var(--border);
}

.brand-badge {
  width: 68px;
  height: 68px;
  border-radius: 18px;
  background: var(--brand);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 1px;
  line-height: 1.15;
  text-transform: uppercase;
}

.login-copy { text-align: center; }

.login-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.login-sub {
  margin-top: 6px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.login-divider {
  width: 100%;
  height: 0.5px;
  background: var(--border);
}

.ms-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 13px 20px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.ms-btn:hover  { background: var(--brand-dark); }
.ms-btn:active { transform: scale(0.98); }
.ms-btn:disabled { opacity: 0.65; cursor: not-allowed; transform: none; }

.ms-logo {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.login-footer {
  font-size: 12px;
  color: var(--text-tertiary);
  text-align: center;
}

/* ═══════════════════════════════════════════
   TOP BAR
════════════════════════════════════════════ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 52px;
}

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

.topbar-badge {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--brand);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
  line-height: 1.15;
  text-transform: uppercase;
  flex-shrink: 0;
}

.topbar-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

.topbar-tagline {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-left: 2px;
}

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

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--brand-light);
  border: 0.5px solid var(--brand-border);
  border-radius: 99px;
  padding: 4px 12px 4px 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.signout-btn {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  cursor: pointer;
  transition: all 0.12s;
}

.signout-btn:hover {
  background: var(--brand-light);
  color: var(--brand);
  border-color: var(--brand-border);
}

/* ═══════════════════════════════════════════
   PORTAL BODY
════════════════════════════════════════════ */
.portal-body {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 24px 48px;
}

/* ── Search + filter row ───────────────── */
.search-row {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
  align-items: center;
  flex-wrap: wrap;
}

.search-wrap {
  flex: 1;
  min-width: 200px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  height: 40px;
  transition: border-color 0.15s;
}

.search-wrap:focus-within {
  border-color: var(--brand-mid);
  outline: 2px solid var(--brand-light);
}

.search-icon {
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

#search-input {
  flex: 1;
  border: none;
  background: none;
  outline: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
}

#search-input::placeholder { color: var(--text-tertiary); }

.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.12s;
}

.chip:hover:not(.active) {
  border-color: var(--brand-mid);
  color: var(--brand);
  background: var(--brand-light);
}

.chip.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

/* ── Section headers ───────────────────── */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 14px;
}

.section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-tertiary);
}

.section-count {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ── App grid ──────────────────────────── */
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}

.app-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 16px 14px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.app-card:hover {
  border-color: var(--brand-mid);
  box-shadow: 0 4px 20px rgba(107, 78, 186, 0.12);
  transform: translateY(-1px);
}

.app-card:active { transform: translateY(0); }

.app-icon {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.app-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.app-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2px;
}

.app-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 3px 8px;
  border-radius: 99px;
}

.tag-ops     { background: #FDEEE8; color: #93380F; }
.tag-data    { background: #EAF3DE; color: #2F5C0A; }
.tag-hr      { background: #E6F1FB; color: #134D8C; }
.tag-finance { background: #FEF3DA; color: #7A4500; }
.tag-default { background: var(--brand-light); color: var(--brand-dark); }

.app-arrow {
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-tertiary);
  font-size: 14px;
}

/* ── Recent section ────────────────────── */
.recent-section { margin-top: 8px; }

.recent-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.recent-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s;
  text-decoration: none;
  color: inherit;
}

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

.recent-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}

.recent-info { flex: 1; }

.recent-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.recent-time {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 1px;
}

.recent-arrow {
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
}

/* ═══════════════════════════════════════════
   TOAST
════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: var(--brand);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideUp 0.25s ease;
  z-index: 200;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ═══════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════════ */
@media (max-width: 600px) {
  .topbar-tagline { display: none; }
  .portal-body { padding: 16px 16px 40px; }
  .search-row { flex-direction: column; align-items: stretch; }
  .search-wrap { min-width: unset; }
  .app-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .login-card { padding: 32px 20px 28px; }
}

/* ═══════════════════════════════════════════
   LOADING STATE
════════════════════════════════════════════ */
.skeleton {
  background: linear-gradient(90deg, #ece9f5 25%, #f5f3fb 50%, #ece9f5 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-md);
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
