/* Portal SEI – Global Styles */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ──────────────────────────────────────────────────────────── */
h1, h2, h3, h4 { font-weight: 600; line-height: 1.3; }
a { color: var(--brand-lt); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: 'Cascadia Code', 'Consolas', monospace; font-size: 0.85em; }
img { max-width: 100%; display: block; }

/* ── Flash messages ──────────────────────────────────────────────────────── */
.flash-container { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }

.flash {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  border: 1px solid transparent;
  animation: flashIn 0.2s ease;
}
@keyframes flashIn { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:none; } }

.flash-success { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.flash-error   { background: var(--danger-bg);  color: var(--danger);  border-color: var(--danger-border); }
.flash-warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-border); }
.flash-info    { background: var(--info-bg);    color: var(--info);    border-color: var(--info-border); }

.flash-icon { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.flash-icon svg { width: 18px; height: 18px; }
.flash-text { flex: 1; }
.flash-close {
  background: none; border: none; cursor: pointer; opacity: 0.5;
  font-size: 16px; line-height: 1; padding: 0; flex-shrink: 0;
  color: inherit;
}
.flash-close:hover { opacity: 1; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn-primary,
.btn-secondary,
.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, box-shadow 0.15s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}
.btn-primary   { background: var(--brand);  color: #fff; }
.btn-primary:hover   { background: var(--brand-lt); text-decoration: none; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1.5px solid var(--border); }
.btn-secondary:hover { background: var(--bg); text-decoration: none; }
.btn-danger    { background: var(--danger);  color: #fff; }
.btn-danger:hover    { opacity: 0.88; text-decoration: none; }
.btn-full { width: 100%; justify-content: center; }
.btn-sm   { padding: 6px 12px; font-size: 13px; }
button:disabled, .btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--font);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  appearance: none;
}
.field input:focus,
.field select:focus,
.field textarea:focus  { border-color: var(--border-focus); background: var(--surface); }
.field textarea { resize: vertical; min-height: 80px; }

.field-password-wrap { position: relative; }
.field-password-wrap input { padding-right: 42px; }
.toggle-password {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--text-muted);
  display: flex; align-items: center; padding: 4px;
}
.toggle-password svg { width: 18px; height: 18px; }
.toggle-password:hover { color: var(--text); }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 15px; font-weight: 600; }
.card-body  { padding: 20px; }
.card-body.p-0 { padding: 0; }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  padding: 10px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-purple { background: #EDE9FE; color: #5B21B6; }
.badge-blue   { background: #DBEAFE; color: #1E40AF; }
.badge-green  { background: var(--success-bg); color: var(--success); }
.badge-orange { background: var(--warning-bg); color: var(--warning); }
.badge-gray   { background: var(--surface-2); color: var(--text-muted); }
.badge-code   { background: var(--surface-2); color: var(--text); font-family: monospace; }

/* ── Utility classes ─────────────────────────────────────────────────────── */
.text-muted  { color: var(--text-muted); }
.text-sm     { font-size: 13px; }
.text-center { text-align: center; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }

.empty-state {
  text-align: center;
  padding: 32px 20px;
  color: var(--text-muted);
  font-size: 14px;
}
.empty-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  gap: 12px;
}
.empty-hero svg { width: 48px; height: 48px; color: var(--text-light); }
.empty-hero h3  { font-size: 18px; color: var(--text); }
.empty-hero p   { color: var(--text-muted); font-size: 14px; max-width: 360px; }

/* ── Error pages ─────────────────────────────────────────────────────────── */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 12px;
  text-align: center;
}
.error-code  { font-size: 80px; font-weight: 800; color: var(--brand); line-height: 1; }
.error-title { font-size: 22px; }
.error-desc  { color: var(--text-muted); font-size: 15px; }

/* ── Stat cards ──────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.stat-card  {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-icon svg { width: 24px; height: 24px; }
.stat-blue   { background: var(--info-bg);    color: var(--info); }
.stat-green  { background: var(--success-bg); color: var(--success); }
.stat-orange { background: var(--warning-bg); color: var(--warning); }
.stat-purple { background: #EDE9FE; color: #5B21B6; }
.stat-value  { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label  { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal {
  display: none;
  position: fixed; inset: 0;
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal.open { display: flex; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.45);
  animation: fadeIn .2s ease;
}
.modal-box {
  position: relative;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp .2s ease;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-title  { font-size: 16px; font-weight: 600; }
.modal-close  {
  background: none; border: none; cursor: pointer;
  font-size: 20px; color: var(--text-muted); line-height: 1; padding: 2px;
}
.modal-close:hover { color: var(--text); }
.modal-body   { padding: 20px 24px; }
.modal-footer {
  padding: 12px 24px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--border);
}
@keyframes fadeIn  { from { opacity:0; } to { opacity:1; } }
@keyframes slideUp { from { transform:translateY(16px); opacity:0; } to { transform:none; opacity:1; } }

/* ── Page header with action button ─────────────────────────────────────── */
.page-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}
.page-actions h2 { font-size: 16px; font-weight: 600; }

/* ── Filter bar ──────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: flex-end;
}
.filter-bar .field { margin-bottom: 0; flex: 1; min-width: 140px; }
.filter-bar .field input,
.filter-bar .field select { padding: 8px 12px; }

/* ── Toggle switch ───────────────────────────────────────────────────────── */
.toggle-form { display: inline; }
.toggle-btn {
  background: none; border: none; cursor: pointer;
  font-size: 13px; font-weight: 600;
  padding: 4px 10px; border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.toggle-btn.active   { color: var(--success); background: var(--success-bg); }
.toggle-btn.inactive { color: var(--text-muted); background: var(--surface-2); }

/* ── Color swatch picker ─────────────────────────────────────────────────── */
.color-field { display: flex; align-items: center; gap: 10px; }
.color-field input[type="color"] {
  width: 44px; height: 36px;
  border-radius: 6px; border: 1.5px solid var(--border);
  padding: 2px; cursor: pointer; background: var(--bg);
}
.color-field input[type="text"] { flex: 1; }

/* ── Section title inside card ───────────────────────────────────────────── */
.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ── Inline preview iframe ───────────────────────────────────────────────── */
.pbi-preview {
  width: 100%; height: 300px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--brand);
}

/* ── Access user list ────────────────────────────────────────────────────── */
.access-list { display: flex; flex-direction: column; gap: 8px; }
.access-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  gap: 12px;
}
.access-item-info { min-width: 0; }
.access-item-name  { font-size: 14px; font-weight: 600; }
.access-item-email { font-size: 12px; color: var(--text-muted); }

/* ── Project grid ────────────────────────────────────────────────────────── */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--card-accent, var(--brand));
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.15s;
}
.project-card:hover { box-shadow: var(--shadow); }
.project-card-logos { display: flex; align-items: center; gap: 12px; padding: 16px 16px 0; }
.project-logo { height: 40px; width: auto; max-width: 100px; object-fit: contain; }
.project-card-body { padding: 12px 16px; flex: 1; }
.project-card-name { font-size: 15px; font-weight: 600; }
.project-card-desc { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.project-card-meta { display: flex; gap: 12px; margin-top: 10px; font-size: 12px; color: var(--text-muted); }
.project-card-actions { padding: 12px 16px; border-top: 1px solid var(--border); }
