/* =========================================================================
   CSIR Project Hub - design system
   Colours sourced from branding/csir_colours.pdf (CSIR Corporate Identity).
   Primary blue is dominant (~80%); flag colours used as accents/status.
   ========================================================================= */
:root {
  /* Primary palette */
  --csir-blue: #00317A;          /* Pantone 2955 - primary */
  --csir-blue-700: #002a66;
  --csir-blue-900: #0C1F41;      /* deep navy */
  --csir-grey: #ACB6B6;          /* Pantone 7543 */
  --csir-red: #FF2126;           /* Pantone 179c */
  --csir-green: #06BC1D;         /* Pantone 3415c */
  --csir-yellow: #FFB005;        /* Pantone 1235c */
  /* Secondary accents */
  --csir-ocean: #005C8E;
  --csir-teal: #00B1BA;
  --csir-orange: #F4752C;

  /* Neutrals */
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e2e7ee;
  --text: #1d2430;
  --text-muted: #5d6b7e;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(12, 31, 65, .08), 0 6px 18px rgba(12, 31, 65, .06);
  --shadow-lg: 0 10px 30px rgba(12, 31, 65, .14);
  --font: "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, sans-serif;
}

* { box-sizing: border-box; }

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

a { color: var(--csir-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { color: var(--csir-blue-900); line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.3rem; }

/* ---------- Top navigation ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 3px solid var(--csir-blue);
  box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 50;
}
.topbar-inner {
  max-width: 1200px; margin: 0 auto; padding: .6rem 1.25rem;
  display: flex; align-items: center; gap: 1.5rem;
}
.brand { display: flex; align-items: center; gap: .8rem; }
.brand img { height: 42px; width: auto; display: block; }
.brand .brand-text { font-weight: 700; color: var(--csir-blue-900); font-size: 1.05rem; letter-spacing: .2px; }
.brand .brand-text small { display: block; font-weight: 500; font-size: .72rem; color: var(--text-muted); letter-spacing: .4px; text-transform: uppercase; }

.nav-links { display: flex; gap: .35rem; margin-left: auto; align-items: center; flex-wrap: wrap; }
.nav-links a {
  padding: .5rem .85rem; border-radius: var(--radius-sm);
  color: var(--csir-blue-900); font-weight: 600; font-size: .92rem;
}
.nav-links a:hover { background: #eef2f8; text-decoration: none; }
.nav-links a.active { background: var(--csir-blue); color: #fff; }

.user-chip {
  display: flex; align-items: center; gap: .55rem;
  padding-left: 1rem; border-left: 1px solid var(--border);
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--csir-blue); color: #fff; font-weight: 700; font-size: .8rem;
  display: grid; place-items: center;
}

/* ---------- Layout ---------- */
.container { max-width: 1200px; margin: 0 auto; padding: 1.75rem 1.25rem 3rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head .subtitle { color: var(--text-muted); margin-top: -.25rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .6rem 1.1rem; border-radius: var(--radius-sm);
  font-weight: 600; font-size: .92rem; cursor: pointer;
  border: 1px solid transparent; transition: .15s; text-decoration: none;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--csir-blue); color: #fff; }
.btn-primary:hover { background: var(--csir-blue-700); color: #fff; }
.btn-ghost { background: #fff; color: var(--csir-blue); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--csir-blue); }
.btn-danger { background: var(--csir-red); color: #fff; }
.btn-danger:hover { background: #d81b1f; color: #fff; }
.btn-success { background: var(--csir-green); color: #fff; }
.btn-sm { padding: .35rem .7rem; font-size: .82rem; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Cards & grid ---------- */
.grid { display: grid; gap: 1.1rem; }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; display: flex; flex-direction: column;
}
.card-body { padding: 1.1rem 1.2rem; flex: 1; }
.card-title { font-size: 1.08rem; font-weight: 700; color: var(--csir-blue-900); margin: 0 0 .35rem; }
.card-meta { color: var(--text-muted); font-size: .85rem; margin-bottom: .6rem; }
.card-foot { padding: .8rem 1.2rem; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: #fafbfd; }

/* coloured top stripe per listing type */
.card.type-project { border-top: 4px solid var(--csir-blue); }
.card.type-researcher { border-top: 4px solid var(--csir-green); }
.card.type-opportunity { border-top: 4px solid var(--csir-orange); }

/* ---------- Stat tiles (dashboard) ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.75rem; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.25rem; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat .num { font-size: 2rem; font-weight: 800; color: var(--csir-blue); line-height: 1; }
.stat .lbl { color: var(--text-muted); font-size: .85rem; margin-top: .35rem; }
.stat::after { content: ""; position: absolute; right: -18px; bottom: -18px; width: 70px; height: 70px; border-radius: 50%; background: rgba(0,49,122,.06); }

/* hero action cards on dashboard */
.action-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.1rem; }
.action-card {
  display: block; padding: 1.4rem; border-radius: var(--radius); color: #fff;
  box-shadow: var(--shadow); transition: .15s; position: relative; overflow: hidden;
}
.action-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); text-decoration: none; color: #fff; }
.action-card h3 { color: #fff; margin-bottom: .3rem; }
.action-card p { margin: 0; opacity: .92; font-size: .9rem; }
.action-card .ac-icon { font-size: 1.8rem; margin-bottom: .5rem; display: block; }
.ac-blue { background: linear-gradient(135deg, var(--csir-blue), var(--csir-ocean)); }
.ac-green { background: linear-gradient(135deg, var(--csir-green), #049a18); }
.ac-orange { background: linear-gradient(135deg, var(--csir-orange), #d85f1c); }

/* ---------- Icons & generated avatars ---------- */
.ic { vertical-align: -0.18em; flex: none; }
.gfx-avatar { display: block; }
.avatar { overflow: hidden; padding: 0; }
.avatar .gfx-avatar { width: 100%; height: 100%; }

/* inline heading with a leading icon */
.with-ic { display: inline-flex; align-items: center; gap: .5rem; }
h2.with-ic, h3.with-ic { display: flex; }

/* circular icon chip used on cards, stats and list rows */
.icon-chip {
  width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  color: #fff; flex: none;
}
.chip-blue { background: linear-gradient(135deg, var(--csir-blue), var(--csir-ocean)); }
.chip-green { background: linear-gradient(135deg, var(--csir-green), #049a18); }
.chip-orange { background: linear-gradient(135deg, var(--csir-orange), #d85f1c); }
.chip-red { background: linear-gradient(135deg, var(--csir-red), #c0151a); }
.chip-soft { background: #eef2f8; color: var(--csir-blue); }

/* meta line with a small leading icon */
.meta-ic { display: inline-flex; align-items: center; gap: .35rem; }

/* avatar badge inside action cards & empty states */
.ac-icon {
  width: 52px; height: 52px; border-radius: 14px; margin-bottom: .8rem;
  display: grid; place-items: center; color: #fff;
  background: rgba(255, 255, 255, .18); backdrop-filter: blur(2px);
}
.empty .big {
  width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 1rem;
  display: grid; place-items: center; background: #eef2f8; color: var(--csir-blue);
}

/* ---------- Badges / status ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .22rem .6rem; border-radius: 999px; font-size: .76rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .3px;
}
.badge-urgent { background: #ffe3e3; color: #c0151a; }
.badge-active { background: #e2f7e5; color: #07871a; }
.badge-completed { background: #eef1f5; color: #5d6b7e; }
.badge-work { background: #e6f0fb; color: var(--csir-blue); }
.badge-advice { background: #fff3d6; color: #9a6b00; }
.badge-data { background: #e0f6f7; color: #00797f; }
.badge-csir { background: var(--csir-blue); color: #fff; }
.badge-ext { background: var(--csir-grey); color: #1d2430; }

/* ---------- Bullet expertise ---------- */
ul.bullets { margin: .25rem 0; padding-left: 1.1rem; }
ul.bullets li { margin: .15rem 0; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .4rem 0; }
.chip { background: #eef2f8; color: var(--csir-blue-900); border-radius: 999px; padding: .25rem .7rem; font-size: .82rem; font-weight: 600; }

/* ---------- Months timeline (Apr -> Mar) ---------- */
.timeline { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; margin: .6rem 0; }
.timeline .month {
  text-align: center; padding: .5rem .2rem; border-radius: var(--radius-sm);
  font-size: .72rem; font-weight: 700; background: #eef1f5; color: var(--text-muted);
  border: 1px solid var(--border);
}
.timeline .month.on { background: var(--csir-green); color: #fff; border-color: var(--csir-green); }

/* ---------- Forms ---------- */
.form-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem 1.6rem; max-width: 880px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.4rem; }
.form-row { display: flex; flex-direction: column; gap: .3rem; margin-bottom: 1rem; }
.form-row.full { grid-column: 1 / -1; }
.form-row label { font-weight: 600; font-size: .9rem; color: var(--csir-blue-900); }
.form-input, input[type=text], input[type=email], input[type=number], input[type=date], input[type=password], textarea, select {
  width: 100%; padding: .6rem .7rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: inherit; font-size: .95rem; background: #fff; color: var(--text);
}
.form-input:focus, input:focus, textarea:focus, select:focus { outline: none; border-color: var(--csir-blue); box-shadow: 0 0 0 3px rgba(0,49,122,.12); }
.form-help { color: var(--text-muted); font-size: .8rem; }
.form-section-title { font-size: 1.05rem; font-weight: 700; color: var(--csir-blue); margin: 1.5rem 0 .5rem; padding-bottom: .35rem; border-bottom: 2px solid var(--border); }
.errorlist { color: var(--csir-red); list-style: none; padding: 0; margin: .2rem 0; font-size: .85rem; }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: .4rem; }
.checkbox-grid label { font-weight: 500; display: flex; align-items: center; gap: .35rem; background: #f4f6f9; padding: .4rem .55rem; border-radius: var(--radius-sm); cursor: pointer; }

/* ---------- Tables (admin panel & interest lists) ---------- */
.table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.table th, .table td { padding: .7rem .85rem; text-align: left; border-bottom: 1px solid var(--border); font-size: .9rem; }
.table th { background: var(--csir-blue); color: #fff; font-size: .8rem; text-transform: uppercase; letter-spacing: .4px; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #f7f9fc; }

/* ---------- Messages / alerts ---------- */
.messages { list-style: none; padding: 0; margin: 0 0 1.25rem; display: grid; gap: .5rem; }
.alert { padding: .75rem 1rem; border-radius: var(--radius-sm); border-left: 4px solid; font-size: .92rem; }
.alert.success { background: #e9f9ec; border-color: var(--csir-green); }
.alert.error { background: #ffe9e9; border-color: var(--csir-red); }
.alert.info { background: #e8f1fb; border-color: var(--csir-blue); }
.alert.warning { background: #fff6e0; border-color: var(--csir-yellow); }

/* ---------- Login ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem;
  background: linear-gradient(135deg, var(--csir-blue-900), var(--csir-blue) 60%, var(--csir-ocean)); }
.auth-card { background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); padding: 2.2rem; width: 100%; max-width: 420px; }
.auth-card .brand-logo { display: block; margin: 0 auto 1.2rem; height: 56px; }
.auth-card h1 { text-align: center; font-size: 1.4rem; }
.auth-sub { text-align: center; color: var(--text-muted); margin-bottom: 1.5rem; font-size: .92rem; }
.divider { display: flex; align-items: center; gap: .75rem; color: var(--text-muted); font-size: .8rem; margin: 1.25rem 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- Detail page ---------- */
.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; align-items: start; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: .4rem .8rem; margin: .8rem 0; }
.kv dt { font-weight: 600; color: var(--text-muted); font-size: .9rem; }
.kv dd { margin: 0; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px,1fr)); gap: .6rem; margin: .6rem 0; }
.gallery img { width: 100%; height: 110px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.file-list { list-style: none; padding: 0; margin: .5rem 0; }
.file-list li { padding: .5rem .7rem; background: #f7f9fc; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: .4rem; display: flex; justify-content: space-between; align-items: center; }

.empty { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty .big { font-size: 2.5rem; }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1.25rem; }
.toolbar form { display: flex; gap: .5rem; flex: 1; min-width: 240px; }
.pagination { display: flex; gap: .4rem; justify-content: center; margin-top: 1.75rem; }
.pagination a, .pagination span { padding: .4rem .75rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; }
.pagination .current { background: var(--csir-blue); color: #fff; border-color: var(--csir-blue); }

/* ---------- Footer ---------- */
.site-footer { text-align: center; padding: 1.5rem; color: var(--text-muted); font-size: .82rem; border-top: 1px solid var(--border); margin-top: 2rem; }

@media (max-width: 760px) {
  .form-grid, .detail-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .nav-links { gap: .1rem; }
  .nav-links a { padding: .45rem .55rem; font-size: .85rem; }
}
