/* base.css — variables, reset, shared components */

/* Matches the PowerApps colour scheme:
   Primary blue #3860B2 (RGBA 56,96,178)
   Header blue  #88A0D1 (RGBA 136,160,209)
   Background   #F1F4F9 (RGBA 241,244,249)
   Dark border  #00126B (RGBA 0,18,107)        */

:root {
  --primary:       #3860B2;
  --primary-dark:  #2a4f9e;
  --primary-light: #88A0D1;
  --bg:            #F1F4F9;
  --surface:       #ffffff;
  --border:        #c8d0e8;
  --border-dark:   #00126B;
  --text:          #111827;
  --muted:         #64748b;
  --hover-fill:    #BAC2E2;

  /* Due-date colour coding (matches PowerApps) */
  --overdue-high:  #FF4500;   /* >14 days: OrangeRed  */
  --overdue-mid:   #E9967A;   /* >7 days:  DarkSalmon */
  --overdue-low:   #FFB6C1;   /* >0 days:  Pink       */

  --danger:        #dc2626;
  --success:       #16a34a;

  --font:          'Open Sans', system-ui, sans-serif;
  --radius:        3px;
  --shadow:        0 1px 3px rgba(0,0,0,.1);
  --shadow-lg:     0 4px 16px rgba(0,0,0,.12);

  --header-height: 45px;
}

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

body {
  font-family: var(--font);
  font-size:   14px;
  color:       var(--text);
  background:  var(--bg);
  line-height: 1.5;
}

.hidden { display: none !important; }

/* ---- Buttons ---- */

.btn {
  display:         inline-flex;
  align-items:     center;
  gap:             0.3em;
  padding:         0.45rem 1rem;
  font-family:     var(--font);
  font-size:       0.9rem;
  font-weight:     600;
  border:          none;
  border-radius:   var(--radius);
  cursor:          pointer;
  transition:      background 0.15s, opacity 0.15s;
  white-space:     nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: #cbd5e1; }

.btn-ghost { background: transparent; color: var(--primary); }
.btn-ghost:hover:not(:disabled) { background: rgba(56,96,178,.1); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-icon {
  background: transparent;
  border:     none;
  cursor:     pointer;
  color:      var(--primary);
  padding:    0.3rem;
  border-radius: var(--radius);
  display:    inline-flex;
  align-items: center;
}
.btn-icon:hover { background: rgba(56,96,178,.1); }

.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.82rem; }
.btn-xs { padding: 0.2rem 0.5rem;  font-size: 0.75rem; }

/* ---- Forms ---- */

.form-row {
  display:   flex;
  gap:       1rem;
  flex-wrap: wrap;
}

.form-group {
  display:        flex;
  flex-direction: column;
  gap:            0.25rem;
}

.form-group label {
  font-size:      0.78rem;
  font-weight:    600;
  color:          var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
  width:         100%;
  padding:       0.4rem 0.6rem;
  border:        1px solid var(--border);
  border-radius: var(--radius);
  font-family:   var(--font);
  font-size:     0.9rem;
  color:         var(--text);
  background:    var(--surface);
  transition:    border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline:      none;
  border-color: var(--primary);
}
input:hover, select:hover { border-color: var(--hover-fill); }

input[type="number"] { width: auto; }

/* ---- Toggle ---- */

.toggle-group {
  display:     inline-flex;
  border:      1px solid var(--border-dark);
  border-radius: var(--radius);
  overflow:    hidden;
}
.toggle-group button {
  padding:     0.3rem 0.9rem;
  font-family: var(--font);
  font-size:   0.82rem;
  font-weight: 600;
  border:      none;
  cursor:      pointer;
  background:  var(--surface);
  color:       var(--primary);
  transition:  background 0.15s, color 0.15s;
}
.toggle-group button.active {
  background: var(--primary);
  color:      #fff;
}

/* ---- Loading overlay ---- */

#loading-overlay {
  position:        fixed;
  inset:           0;
  background:      rgba(241,244,249,.85);
  display:         flex;
  flex-direction:  column;
  align-items:     center;
  justify-content: center;
  gap:             1rem;
  z-index:         9999;
}

.loading-spinner {
  width:         40px;
  height:        40px;
  border:        4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation:     spin 0.7s linear infinite;
}

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

#loading-message {
  font-size:   0.9rem;
  color:       var(--muted);
}

/* ---- Inline spinner (inside a container) ---- */

.inline-spinner {
  padding:    2rem;
  text-align: center;
  color:      var(--muted);
  font-size:  0.88rem;
}

/* ---- Error / info banners ---- */

.error-banner {
  padding:       0.75rem 1rem;
  background:    #fee2e2;
  border:        1px solid #fca5a5;
  border-radius: var(--radius);
  color:         var(--danger);
  font-size:     0.88rem;
  margin:        0.5rem 0;
}

.info-banner {
  padding:       0.75rem 1rem;
  background:    #eff6ff;
  border:        1px solid #bfdbfe;
  border-radius: var(--radius);
  color:         var(--primary);
  font-size:     0.88rem;
  margin:        0.5rem 0;
}

/* ---- Confirmation dialog ---- */

.confirm-bar {
  display:       inline-flex;
  align-items:   center;
  gap:           0.5rem;
  padding:       0.4rem 0.75rem;
  background:    var(--surface);
  border:        1px solid var(--border-dark);
  border-radius: var(--radius);
  font-size:     0.85rem;
  box-shadow:    var(--shadow);
}

/* ---- Toast notification ---- */

#toast {
  position:      fixed;
  bottom:        5.5rem;   /* above feedback pill */
  left:          50%;
  transform:     translateX(-50%);
  min-width:     260px;
  max-width:     480px;
  padding:       0.7rem 1.1rem;
  border-radius: var(--radius);
  font-size:     0.88rem;
  box-shadow:    var(--shadow);
  z-index:       9500;
  opacity:       0;
  transition:    opacity 0.2s;
  pointer-events: none;
  white-space:   pre-line;
}
#toast.visible       { opacity: 1; }
#toast.toast-error   { background: #fee2e2; border: 1px solid #fca5a5; color: var(--danger); }
#toast.toast-warn    { background: #fef9c3; border: 1px solid #fde047; color: #854d0e; }
#toast.toast-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: var(--primary); }

/* ---- Status badge ---- */

.status-badge {
  display:       inline-block;
  padding:       0.15rem 0.55rem;
  border-radius: var(--radius);
  font-size:     0.78rem;
  font-weight:   600;
  background:    #e2e8f0;
  color:         var(--text);
}

/* ---- Co-author invite dialog ---- */

.coauthor-dialog {
  border:        1px solid var(--border-dark);
  border-radius: var(--radius);
  box-shadow:    var(--shadow);
  padding:       1.5rem;
  min-width:     320px;
  max-width:     420px;
  background:    var(--surface);
}
.coauthor-dialog::backdrop {
  background: rgba(0,0,0,0.35);
}
.coauthor-dialog-title {
  margin:        0 0 0.5rem;
  font-size:     1rem;
  color:         var(--primary);
}
.coauthor-dialog-hint {
  margin:        0 0 1rem;
  font-size:     0.85rem;
  color:         var(--muted);
}
.coauthor-dialog-actions {
  display:       flex;
  justify-content: flex-end;
  gap:           0.5rem;
  margin-top:    1.25rem;
}
