/* ================================================================
   theme.css — Internship Data Entry System
   Brand: Gold accent · Navy ink · Warm cream paper
   Fonts: Fraunces (display) · IBM Plex Sans (body) · IBM Plex Mono (data)
   ================================================================ */

/* ---- Google Fonts ---- */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

/* ---- Design Tokens ---- */
:root {
  /* Gold family */
  --gold:         #B5852E;
  --gold-deep:    #946A1E;
  --gold-amber:   #A9791F;
  --gold-highlight:#E9C878;
  --gold-tint:    #F6EFDC;

  /* Navy / ink family */
  --navy:         #122A43;
  --navy-mid:     #2E4C6B;
  --navy-dark:    #0C1E30;
  --slate:        #3A506B;
  --slate-soft:   #6E7A86;

  /* Cream / paper surfaces */
  --cream:        #F6F2E9;
  --panel:        #FCFAF3;
  --wash:         #F3EEE0;
  --hover:        #FBF8F0;
  --card:         #FFFFFF;

  /* Lines */
  --line:         #E4DCC9;
  --line-strong:  #D6CCB4;

  /* Semantic */
  --danger:       #B23A2E;
  --success:      #1F7A52;
  --success-deep: #175E40;
  --purple:       #6a1b9a;
  --blue:         #1565c0;
  --cyan:         #0e7490;
  --warning-bg:   #fff3cd;
  --warning-text: #856404;

  /* Aliases (backward compat with old var names) */
  --primary:      var(--navy);
  --accent:       var(--gold);
  --ink:          var(--navy);
  --ink-soft:     var(--slate);

  /* Layout */
  --radius:       10px;
  --shadow:       0 1px 0 rgba(18,42,67,.04), 0 10px 34px -24px rgba(18,42,67,.12);
  --nav-width:    240px;
  --nav-collapsed:0px;

  /* Type scale */
  --font-display: 'Fraunces', serif;
  --font-body:    'IBM Plex Sans', system-ui, sans-serif;
  --font-mono:    'IBM Plex Mono', ui-monospace, 'Consolas', monospace;
}

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

body {
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--navy);
  line-height: 1.55;
  min-height: 100vh;
}

/* ================================================================
   LAYOUT: Sidebar + Main
   ================================================================ */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ---- Left Navigation ---- */
.sidebar {
  width: var(--nav-width);
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
  transition: transform .25s cubic-bezier(.4,0,.2,1), width .25s cubic-bezier(.4,0,.2,1);
  box-shadow: 4px 0 24px rgba(12,30,48,.2);
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar.collapsed {
  transform: translateX(calc(-1 * var(--nav-width)));
}

.sidebar-brand {
  padding: 1.25rem 1.2rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: .75rem;
}
.sidebar-brand img {
  width: 32px; height: 32px;
  border-radius: 6px;
  flex-shrink: 0;
}
.sidebar-brand .brand-text {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: .95rem;
  letter-spacing: -.01em;
  line-height: 1.2;
  color: #fff;
}
.sidebar-brand .brand-sub {
  font-family: var(--font-mono);
  font-size: .6rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--gold-highlight);
  margin-top: 2px;
}

/* Gold accent bar under brand */
.sidebar-brand::after {
  content: none;
}
.sidebar-accent {
  height: 3px;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold) 40%, var(--gold-highlight) 70%, var(--gold-deep));
  flex-shrink: 0;
}

/* Nav links */
.sidebar-nav {
  padding: .75rem 0;
  flex: 1;
}
.nav-section {
  padding: 0 .75rem;
  margin-bottom: .25rem;
}
.nav-section-label {
  font-family: var(--font-mono);
  font-size: .58rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: rgba(255,255,255,.35);
  padding: .6rem .55rem .3rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .55rem .75rem;
  border-radius: 8px;
  color: rgba(255,255,255,.72);
  text-decoration: none;
  font-size: .84rem;
  font-weight: 500;
  transition: all .12s;
  margin: 1px 0;
}
.nav-link:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
}
.nav-link.active {
  background: rgba(181,133,46,.18);
  color: var(--gold-highlight);
  font-weight: 600;
}
.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  width: 3px;
  height: 24px;
  background: var(--gold);
  border-radius: 0 3px 3px 0;
}
.nav-link .nav-icon {
  font-size: 1rem;
  width: 1.25rem;
  text-align: center;
  flex-shrink: 0;
}

/* Sidebar footer */
.sidebar-footer {
  padding: .75rem 1rem;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: .78rem;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: .5rem;
  color: rgba(255,255,255,.6);
}
.sidebar-user .user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--navy-mid);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: .7rem;
  color: var(--gold-highlight);
  flex-shrink: 0;
}
.sidebar-user .user-name {
  font-weight: 600;
  color: rgba(255,255,255,.85);
}

/* ---- Toggle Button ---- */
.nav-toggle {
  position: fixed;
  top: .75rem;
  left: .75rem;
  z-index: 60;
  width: 36px; height: 36px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  color: var(--navy);
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  transition: left .25s cubic-bezier(.4,0,.2,1), background .12s;
}
.nav-toggle:hover {
  background: var(--wash);
}
/* When sidebar open, push toggle to right edge of sidebar */
body:not(.nav-closed) .nav-toggle {
  left: calc(var(--nav-width) - 44px);
  background: var(--navy-mid);
  color: #fff;
  border-color: transparent;
}

/* ---- Main Content ---- */
.main-content {
  flex: 1;
  margin-left: var(--nav-width);
  transition: margin-left .25s cubic-bezier(.4,0,.2,1);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
body.nav-closed .main-content {
  margin-left: 0;
}
body.nav-closed .sidebar {
  transform: translateX(calc(-1 * var(--nav-width)));
}

/* Top bar */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: .6rem 1.5rem .6rem 3.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 48px;
  position: sticky;
  top: 0;
  z-index: 30;
}
body:not(.nav-closed) .topbar {
  padding-left: 1.5rem;
}
.topbar-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -.01em;
  color: var(--navy);
}
.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: .5rem;
}

/* Container */
main.container {
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2rem;
}

/* ================================================================
   TYPOGRAPHY
   ================================================================ */
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -.01em; }

.page-h1 {
  font-size: 1.4rem;
  color: var(--navy);
  margin: 0 0 1rem;
  padding-bottom: .5rem;
  border-bottom: 2px solid var(--gold);
  display: inline-block;
}

/* ================================================================
   BUTTONS
   ================================================================ */
.btn, .btn-primary, .btn-ghost, .btn-export, .btn-danger {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .45rem .9rem;
  border-radius: 8px;
  font: inherit;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--navy);
  text-decoration: none;
  transition: all .12s;
  white-space: nowrap;
}
.btn:hover { background: var(--wash); border-color: var(--line-strong); }

.btn-primary {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}
.btn-primary:hover { background: var(--navy-mid); border-color: var(--navy-mid); }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--slate);
}
.btn-ghost:hover { background: var(--wash); }

.btn-export {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}
.btn-export:hover { background: var(--success-deep); border-color: var(--success-deep); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover { background: #fdeceb; }

.btn-sm { font-size: .78rem; padding: .3rem .55rem; }

.link { color: var(--navy-mid); font-weight: 600; text-decoration: none; font-size: .82rem; cursor: pointer; }
.link:hover { text-decoration: underline; }
.link.danger { color: var(--danger); }

/* ================================================================
   CARDS & SURFACES
   ================================================================ */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.pad { padding: 1.2rem; }

/* ================================================================
   FORMULA BAR / FILTER BAR
   ================================================================ */
.formula-bar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .5rem .8rem;
  margin-bottom: .5rem;
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  align-items: center;
}
.fx {
  font-family: var(--font-mono);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--gold-deep);
  background: var(--gold-tint);
  padding: .25rem .5rem;
  border-radius: 5px;
  text-transform: uppercase;
  flex-shrink: 0;
}
.filters input, .filters select {
  padding: .38rem .55rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  font-size: .82rem;
  color: var(--navy);
  background: var(--card);
}
.filters input:focus, .filters select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(181,133,46,.12);
}
.count {
  font-family: var(--font-mono);
  font-size: .72rem;
  color: var(--slate-soft);
  letter-spacing: .04em;
  margin-left: auto;
}

/* ================================================================
   SHEET / TABLE (Excel-like)
   ================================================================ */
.sheet-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--card);
  max-height: 72vh;
}

table.sheet {
  width: 100%;
  border-collapse: collapse;
  font-size: .8rem;
}
table.sheet thead th {
  position: sticky;
  z-index: 5;
  background: var(--panel);
  color: var(--slate);
  font-weight: 700;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  padding: .45rem .5rem;
  text-align: left;
  border-bottom: 1.5px solid var(--line-strong);
  white-space: nowrap;
}

/* Column letter row */
.col-letters th {
  top: 0;
  font-family: var(--font-mono);
  font-size: .6rem;
  font-weight: 500;
  text-align: center;
  color: var(--slate-soft);
  padding: .2rem .3rem;
  background: var(--wash);
  border-bottom: 1px solid var(--line);
}
.field-row th {
  top: 24px;
}

/* Corner cell (row numbers) */
.corner {
  width: 36px;
  text-align: center;
  color: var(--slate-soft);
}

/* Body cells */
table.sheet td {
  padding: .4rem .5rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.sheet tbody tr:hover td { background: var(--hover); }

.rownum {
  font-family: var(--font-mono);
  font-size: .7rem;
  font-weight: 600;
  color: var(--slate-soft);
  text-align: center;
  width: 36px;
  background: var(--panel);
}
.mono { font-family: var(--font-mono); font-size: .78rem; }
.num { text-align: right; font-family: var(--font-mono); font-feature-settings: "tnum" 1; }
.center { text-align: center; }
.cell-name { font-weight: 600; }
.empty { text-align: center; color: var(--slate-soft); padding: 2rem !important; font-style: italic; }
.actions-col { white-space: nowrap; text-align: right; }

/* ================================================================
   FORMS
   ================================================================ */
.entry-form {
  max-width: 780px;
}
fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: 1rem;
  background: var(--card);
}
legend {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: .95rem;
  color: var(--navy);
  padding: 0 .5rem;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .6rem;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  font-size: .78rem;
  font-weight: 600;
  color: var(--slate);
}
.form-grid input, .form-grid select, .form-grid textarea {
  padding: .45rem .6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: .88rem;
  color: var(--navy);
  background: var(--card);
}
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(181,133,46,.12);
}
.form-actions {
  display: flex;
  gap: .5rem;
  padding-top: .5rem;
}

/* ================================================================
   FLASH / ALERTS
   ================================================================ */
.flash {
  padding: .7rem 1rem;
  border-radius: 8px;
  font-size: .88rem;
  font-weight: 500;
  margin-bottom: 1rem;
  background: var(--gold-tint);
  color: var(--gold-deep);
  border-left: 4px solid var(--gold);
}
.flash-err {
  background: #fdeceb;
  color: var(--danger);
  border-left-color: var(--danger);
}

/* ================================================================
   RESULT / STATUS
   ================================================================ */
.result {
  font-size: .88rem;
  padding: .5rem;
}
.result.err { color: var(--danger); }
.result.warn { color: var(--gold-amber); }

/* ================================================================
   GRID TOOLBAR
   ================================================================ */
.grid-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  align-items: center;
  padding: .5rem .8rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: .5rem;
}
.grid-toolbar .hint {
  font-size: .72rem;
  color: var(--slate-soft);
  margin-left: auto;
}

/* ================================================================
   STEPS
   ================================================================ */
ol.steps {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
  font-size: .88rem;
  line-height: 1.7;
}
ol.steps li { margin-bottom: .3rem; }
ol.steps code {
  font-family: var(--font-mono);
  font-size: .82rem;
  background: var(--wash);
  padding: .1rem .35rem;
  border-radius: 4px;
}

/* ================================================================
   UPLOAD FORM
   ================================================================ */
.upload-form {
  display: flex;
  gap: .5rem;
  align-items: center;
  margin-top: .5rem;
}

/* ================================================================
   INLINE DELETE
   ================================================================ */
.inline-del {
  display: inline;
}

/* ================================================================
   COURSE READOUT
   ================================================================ */
.course-readout {
  padding: .5rem 1rem;
  background: var(--gold-tint);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: .5rem;
  font-size: .82rem;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.5rem;
  color: var(--navy);
}
.course-readout b { color: var(--gold-deep); }

/* row highlight for missing docs */
tr.row-doc-pending td {
  background: #fffcf0 !important;
}
tr.row-doc-pending:hover td {
  background: #fff8e0 !important;
}

/* ================================================================
   LOGIN PAGE
   ================================================================ */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(145deg, var(--navy) 0%, var(--navy-dark) 100%);
}
.login-card {
  background: var(--card);
  border-radius: 16px;
  padding: 2.5rem 2.2rem;
  width: 380px;
  max-width: 92vw;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  text-align: center;
}
.login-card h1 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--navy);
  margin-bottom: .25rem;
}
.login-sub {
  color: var(--slate-soft);
  font-size: .88rem;
  margin-bottom: 1.5rem;
}
.login-logo {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  margin-bottom: .75rem;
}
.login-card label {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  text-align: left;
  font-size: .82rem;
  font-weight: 600;
  color: var(--slate);
  margin-bottom: .75rem;
}
.login-card input {
  padding: .55rem .7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: .95rem;
  color: var(--navy);
  width: 100%;
}
.login-card input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(181,133,46,.15);
}
.login-btn {
  width: 100%;
  padding: .65rem;
  margin-top: .5rem;
  font-size: .95rem;
}

/* ================================================================
   SELECTION HIGHLIGHT (grid)
   ================================================================ */
td.sel {
  background: rgba(181,133,46,.1) !important;
  outline: 2px solid var(--gold);
  outline-offset: -2px;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 768px) {
  :root { --nav-width: 260px; }
  .sidebar {
    transform: translateX(calc(-1 * var(--nav-width)));
  }
  body:not(.nav-closed) .sidebar {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0 !important;
  }
  body:not(.nav-closed) .main-content::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 40;
  }
  .nav-toggle { left: .75rem !important; }
  body:not(.nav-closed) .nav-toggle {
    left: calc(var(--nav-width) - 44px) !important;
  }
  main.container { padding: 1rem; }
  .topbar { padding-left: 3rem !important; }
}
