/* ====== Base ====== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #1f2937 0, #020617 55%, #020617 100%);
  color: #e5e7eb;
  height: 100%;
}

/* ====== Layout global ====== */
.app-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px;
  max-width: 1100px;
  margin: 0 auto;
}

.app-header {
  text-align: center;
  margin-bottom: 24px;
}

.app-header h1 {
  font-size: 2.4rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0;
}

.app-header .subtitle {
  margin-top: 8px;
  color: #9ca3af;
}

/* Écrans (home / main) */
.screen { display: none; }
.screen-active { display: block; }

/* ====== Card ====== */
.card {
  background: rgba(15, 23, 42, 0.95);
  border-radius: 16px;
  padding: 20px 22px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(148, 163, 184, 0.18);
  backdrop-filter: blur(24px);
}

.card h2 {
  margin-top: 0;
  margin-bottom: 14px;
  font-size: 1.2rem;
}

.card-title-row{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* ====== Home screen ====== */
.home-card{
  max-width: 520px;
  margin: 0 auto;
  text-align: center;
}

.home-text{
  margin-top: 4px;
  margin-bottom: 18px;
  color: #cbd5e1;
}

.promo-buttons{
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
}

.promo-btn{
  min-width: 160px;
  padding: 14px 18px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.9);
  color: #e5e7eb;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease, border-color 0.1s ease, background 0.1s ease;
}

.promo-btn-main{
  background: linear-gradient(135deg, #38bdf8, #0ea5e9);
  color: #0b1120;
  border-color: transparent;
}

.promo-btn-main:hover{
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(56, 189, 248, 0.4);
}

.promo-btn-disabled{
  opacity: 0.5;
  cursor: not-allowed;
}

.promo-sub{
  font-size: 0.8rem;
  font-weight: 400;
  display: block;
  margin-top: 4px;
  opacity: 0.9;
}

.home-note{
  margin-top: 18px;
  font-size: 0.9rem;
  color: #9ca3af;
}

/* ====== Topbar (écran principal) ====== */
.topbar{
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.topbar-right{
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ✅ Badge mieux centré */
.badge{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.5);
  font-size: 0.85rem;
  line-height: 1;
  white-space: nowrap;
}

/* Boutons semestre */
.semester-switch{
  display: inline-flex;
  align-items: center;
  background: rgba(15, 23, 42, 0.9);
  border-radius: 999px;
  padding: 2px;
  border: 1px solid rgba(148, 163, 184, 0.5);
}

.sem-btn{
  border: none;
  background: transparent;
  color: #cbd5e1;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.9rem;
  cursor: pointer;
  line-height: 1;
}

.sem-btn-active{
  background: #0ea5e9;
  color: #0b1120;
}

/* ====== Grid principal ====== */
.app-main-grid{
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.4fr);
  gap: 20px;
  align-items: stretch;
}

@media (max-width: 840px) {
  .app-main-grid{
    grid-template-columns: 1fr;
  }
}

/* ====== Liste matières ====== */
#subjects-card {
  display: flex;
  flex-direction: column;
}

.subjects-list{
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 auto;
  overflow-y: auto;
}

.subject-row{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(55, 65, 81, 0.9);
}

.subject-main{
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.subject-code{
  font-size: 0.86rem;
  color: #93c5fd;
}

.subject-name{
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ✅ Bouton "+ Note" plus propre et centré */
.subject-row .btn-plus{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  border: none;
  font-size: 0.9rem;
  font-weight: 800;
  background: #22c55e;
  color: #022c22;
  cursor: pointer;
  line-height: 1;
  white-space: nowrap;
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.08s ease;
}

.subject-row .btn-plus:hover{
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(34, 197, 94, 0.4);
  filter: brightness(1.03);
}

/* ====== Boutons génériques ====== */
.btn-primary {
  padding: 10px 14px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, #38bdf8, #0ea5e9);
  color: #0b1120;
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.1s ease;
  line-height: 1;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(56, 189, 248, 0.35);
  filter: brightness(1.05);
}

.btn-primary:active { transform: translateY(0); box-shadow: none; }

.btn-ghost{
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: transparent;
  color: #cbd5e1;
  cursor: pointer;
  line-height: 1;
}

.btn-ghost:hover{
  border-color: rgba(56, 189, 248, 0.8);
}

.btn-ghost-small{
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: transparent;
  color: #cbd5e1;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
}

/* ====== Form elements ====== */
.form-row{
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.two-cols{
  flex-direction: row;
  gap: 10px;
}

.two-cols > div{ flex: 1; }

label{
  font-size: 0.88rem;
  color: #9ca3af;
}

input[type="text"],
input[type="number"],
select{
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #4b5563;
  background: rgba(15, 23, 42, 0.9);
  color: #e5e7eb;
  outline: none;
  font-size: 1rem;
}

input::placeholder{ color: #6b7280; }

input:focus,
select:focus{
  border-color: #38bdf8;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.4);
}

/* ====== Table notes ====== */
.table-wrapper {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(75, 85, 99, 0.8);
  max-height: 280px;
  overflow-y: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead {
  background: rgba(15, 23, 42, 0.95);
  position: sticky;
  top: 0;
  z-index: 1;
}

th, td {
  padding: 8px 10px;
  text-align: left;
  vertical-align: middle;
}

th {
  font-weight: 600;
  color: #9ca3af;
  border-bottom: 1px solid rgba(55, 65, 81, 0.9);
}

tbody tr:nth-child(even) { background-color: rgba(15, 23, 42, 0.80); }
tbody tr:nth-child(odd)  { background-color: rgba(15, 23, 42, 0.62); }

.row-actions{
  text-align: right;
  white-space: nowrap;
}

.icon-btn{
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: transparent;
  color: #cbd5e1;
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
  line-height: 1;
}

.icon-btn:hover{
  border-color: rgba(248, 113, 113, 0.9);
  color: #fecaca;
}

/* ====== Résultats & messages ====== */
.results {
  display: flex;
  justify-content: flex-end;
  gap: 20px;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px dashed rgba(55, 65, 81, 0.9);
  flex-wrap: wrap;
}

.result-item {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 0.88rem;
}

.result-item span { color: #9ca3af; }
.result-item strong { margin-top: 3px; font-size: 1rem; }

.msg{
  margin-top: 10px;
  min-height: 18px;
  font-size: 0.9rem;
  color: #9ca3af;
}

/* ====== Footer ====== */
.app-footer {
  margin-top: 24px;
  text-align: center;
  font-size: 0.8rem;
  color: #6b7280;
}

/* ====== Modale ====== */
.modal{
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 40;
}

.modal-open{
  opacity: 1;
  pointer-events: auto;
}

.modal-box{
  width: 100%;
  max-width: 520px;
  background: rgba(15, 23, 42, 1);
  border-radius: 18px;
  padding: 22px 22px 18px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.modal-box h3{
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 1.2rem;
}

.modal-actions{
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

.modal-actions button{
  min-width: 104px;
}

/* ====== Bulletin (moyennes par pôle) ====== */
.bulletin-section { margin-top: 18px; }

.bulletin-grid{
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bulletin-line{
  display:flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.75);
}

.bulletin-title{
  color:#cbd5e1;
  font-weight:700;
}

.bulletin-sub{
  color:#9ca3af;
  font-size:0.9rem;
}

.bulletin-value{
  font-weight:900;
  white-space: nowrap;
}

/* ====== Bulletin détaillé (pôles + matières) ====== */
.bulletin-pole{
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bulletin-subjects{
  margin-left: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bulletin-subject-line{
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(31, 41, 55, 0.9);
  font-size: 0.88rem;
}

/* ✅ empêche le texte de casser le layout */
.bulletin-subject-line > div:first-child{
  flex: 1 1 auto;
  min-width: 0;
}

.bulletin-subject-code{
  color: #93c5fd;
  font-weight: 700;
  margin-right: 6px;
  white-space: nowrap;
}

.bulletin-subject-meta{
  color: #9ca3af;
  font-size: 0.82rem;
  white-space: nowrap;
  flex: 0 0 auto;
  text-align: right;
}

/* ====== Couleurs des moyennes ====== */
.avg-good { color: #22c55e; }
.avg-mid  { color: #f59e0b; }
.avg-bad  { color: #ef4444; }
.avg-na   { color: #9ca3af; }

/* ====== Logo SmartNote ====== */
.app-logo {
  max-width: 260px;
  width: 100%;
  height: auto;
  margin: 0 auto 8px;
  display: block;
}

/* ====== Bouton soutien SmartNote ====== */
.support-btn {
  background: linear-gradient(135deg, #facc15, #eab308);
  color: #1f2937;
  font-weight: 800;
  border-color: transparent;
  box-shadow: 0 10px 22px rgba(250, 204, 21, 0.45);
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.support-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 26px rgba(250, 204, 21, 0.55);
  filter: brightness(1.05);
}