/* ═══════════════════════════════════════════════════════════════
   FHORT Assessment — app.css
   Paleta: PDF brand (#5f7d7a) domina. Fons blanc. Font Montserrat.
   ═══════════════════════════════════════════════════════════════ */

/* ── Montserrat (fitxers locals) ─────────────────────────────── */
@font-face {
  font-family: 'Montserrat';
  src: url('../fonts/Montserrat-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Montserrat';
  src: url('../fonts/Montserrat-SemiBold.ttf') format('truetype');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

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

:root {
  /* Brand principal — paleta del PDF */
  --green:        #5f7d7a;   /* SCORE_BOX_FILL / títols PDF */
  --green-light:  #e1e5e4;   /* TITLE_BAR_FILL del PDF */
  --green-mid:    #b2bdbc;   /* MIDLINE_COLOR del PDF */
  --green-dark:   #4a6361;   /* hover / pressed */
  --green-xlight: #f2f4f4;   /* fons molt suau */

  /* Backward compat: qualsevol var(--purple) existent passa a verd */
  --purple:       #5f7d7a;
  --purple-light: #e1e5e4;

  /* Semàntiques */
  --success:       #0F6E56;
  --success-light: #E1F5EE;
  --teal:          #0F6E56;
  --teal-light:   #E1F5EE;
  --danger:        #A32D2D;
  --danger-light:  #FCEBEB;
  --warning:       #854F0B;
  --warning-light: #FAEEDA;

  /* Neutrals */
  --text:       #1a1a1a;
  --text-muted: #5F5E5A;
  --border:     #d1dad9;
  --bg:         #FFFFFF;
  --bg-subtle:  #F5F6F6;
  --white:      #FFFFFF;

  /* Layout */
  --sidebar-w:  224px;
  --radius:     8px;
  --radius-lg:  12px;
  --shadow:     0 1px 3px rgba(0,0,0,.07);
  --shadow-md:  0 4px 16px rgba(0,0,0,.09);
}

/* ── Base ────────────────────────────────────────────────────── */
body {
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ═══════════════════════════════════════════════════════════════
   LAYOUT — Sidebar + contingut
   ═══════════════════════════════════════════════════════════════ */

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

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  transition: transform .25s ease;
}

/* Logo */
.sidebar-logo {
  padding: 1.5rem 1.25rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-logo img {
  width: 100%;
  max-width: 168px;
  height: auto;
  display: block;
}

/* Navegació */
.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
  overflow-y: auto;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: .75rem 1.25rem .25rem;
  opacity: .7;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .55rem 1.25rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all .15s;
  gap: .5rem;
}

.sidebar-nav a .nav-icon {
  font-size: 15px;
  flex-shrink: 0;
  margin-right: .1rem;
}

.sidebar-nav a:hover {
  color: var(--green);
  background: var(--green-light);
  border-left-color: var(--green);
}

.sidebar-nav a.active {
  color: var(--green);
  background: var(--green-light);
  border-left-color: var(--green);
  font-weight: 600;
}

/* Footer sidebar */
.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

/* Usuari */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: .6rem;
}
.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--green-light);
  color: var(--green);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid var(--green-mid);
}
.sidebar-user-info { overflow: hidden; }
.sidebar-user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-email {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Accions footer */
.sidebar-footer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}

/* Selector idioma */
.sidebar-lang-select {
  display: flex;
  align-items: center;
  gap: .3rem;
  color: var(--text-muted);
}
.lang-select-input {
  font-size: 11px;
  font-family: inherit;
  color: var(--text-muted);
  border: none;
  background: transparent;
  cursor: pointer;
  outline: none;
  padding: 0;
}
.lang-select-input:hover { color: var(--green); }

/* Logout */
.sidebar-logout {
  display: flex;
  align-items: center;
  gap: .3rem;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: color .15s;
}
.sidebar-logout:hover { color: var(--danger); }

/* Badge de crèdits al sidebar */
.credits-badge {
  background: var(--green-light);
  color: var(--green);
  font-size: 11px;
  font-weight: 600;
  padding: .15rem .5rem;
  border-radius: 20px;
  margin-left: auto;
  flex-shrink: 0;
}

/* ── Main content ─────────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg);
  padding: 2rem 2.5rem;
}

/* ── Containers ──────────────────────────────────────────────── */
.container {
  max-width: 1200px;
  margin: 0 auto;
}

.container-sm {
  max-width: 460px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* ═══════════════════════════════════════════════════════════════
   LAYOUT — Pàgines no autenticades (login, register…)
   ═══════════════════════════════════════════════════════════════ */

.auth-wrapper {
  min-height: 100vh;
  background: var(--bg-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.auth-wrapper .container-sm {
  width: 100%;
  padding: 0;
}

/* ═══════════════════════════════════════════════════════════════
   COMPONENTS
   ═══════════════════════════════════════════════════════════════ */

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

/* ── Alerts / Flash ──────────────────────────────────────────── */
.alerts { margin-bottom: 1.5rem; }
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: .5rem;
  font-weight: 500;
}
.alert-success { background: var(--success-light); color: var(--success); }
.alert-danger  { background: var(--danger-light);  color: var(--danger); }
.alert-warning { background: var(--warning-light); color: var(--warning); }
.alert-info    { background: var(--green-light);   color: var(--green); }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .6rem 1.25rem;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all .15s;
  letter-spacing: .01em;
  white-space: nowrap;
}
.btn:hover         { opacity: .88; transform: translateY(-1px); }
.btn:active        { transform: translateY(0); opacity: 1; }
.btn-primary       { background: var(--green);   color: var(--white); }
.btn-primary:hover { background: var(--green-dark); opacity: 1; }
.btn-outline       { background: var(--white); color: var(--text); border-color: var(--border); }
.btn-outline:hover { border-color: var(--green); color: var(--green); opacity: 1; }
.btn-danger        { background: var(--danger); color: var(--white); }
.btn-sm            { padding: .35rem .85rem; font-size: 11px; }
.btn-block         { width: 100%; justify-content: center; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: .4rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.form-control {
  width: 100%;
  padding: .65rem .9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--white);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(95,125,122,.14);
}
.form-control::placeholder { color: var(--text-muted); opacity: .6; }
.form-error { font-size: 12px; color: var(--danger); margin-top: .3rem; font-weight: 500; }
.form-select { /* alias */
  width: 100%;
  padding: .6rem .85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--white);
  outline: none;
}
.form-select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(95,125,122,.14); }

/* ── Tables ──────────────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th {
  text-align: left;
  padding: .6rem .85rem;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  border-bottom: 2px solid var(--border);
  background: var(--bg-subtle);
}
.table th:first-child { border-radius: var(--radius) 0 0 0; }
.table th:last-child  { border-radius: 0 var(--radius) 0 0; }
.table td {
  padding: .8rem .85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--green-xlight); }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .22rem .65rem;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: .02em;
}
/* Noms nous */
.badge-green   { background: var(--green-light);   color: var(--green); }
.badge-success { background: var(--success-light); color: var(--success); }
/* Aliases backward compat */
.badge-purple  { background: var(--green-light);   color: var(--green); }
.badge-teal    { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger  { background: var(--danger-light);  color: var(--danger); }
.badge-gray    { background: var(--bg-subtle);     color: var(--text-muted); border: 1px solid var(--border); }

/* ── Page header ─────────────────────────────────────────────── */
.page-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.page-header h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -.3px;
}
.page-header p {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: .3rem;
}

/* ── Stat cards ──────────────────────────────────────────────── */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px;
  height: 100%;
  background: var(--green);
  border-radius: 0 0 0 var(--radius-lg);
}
.stat-label {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
}
.stat-value {
  font-size: 28px;
  font-weight: 600;
  margin-top: .2rem;
  color: var(--green);
  letter-spacing: -.5px;
  line-height: 1.1;
}

/* ── Utilities ───────────────────────────────────────────────── */
.text-muted      { color: var(--text-muted); }
.text-sm         { font-size: 12px; }
.text-green      { color: var(--green); }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex            { display: flex; align-items: center; }
.gap-1           { gap: .5rem; }
.justify-between { justify-content: space-between; }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */

/* Tablet (768-1023px) */
@media (max-width: 1023px) {
  :root { --sidebar-w: 200px; }
  .main-content { padding: 1.5rem 2rem; }
}

/* Mòbil (<768px) — sidebar oculta, topbar visible */
@media (max-width: 767px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-md); }
  .main-content { margin-left: 0; padding: 1rem 1.25rem; }

  .mobile-topbar {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding: .75rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 99;
  }

  .mobile-topbar img { height: 28px; }

  .mobile-menu-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: .25rem;
    color: var(--text-muted);
    font-size: 22px;
    line-height: 1;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    z-index: 99;
  }
  .sidebar-overlay.open { display: block; }
}

@media (min-width: 768px) {
  .mobile-topbar { display: none !important; }
  .sidebar-overlay { display: none !important; }
}
