/* ============================================================
   AKAZ CALCULATOR — CSS
   ============================================================ */

:root {
  --bg:         #0f1117;
  --surface:    #1a1d27;
  --surface2:   #222536;
  --border:     #2e3148;
  --accent:     #6c63ff;
  --accent-light: #8b84ff;
  --accent-glow: rgba(108,99,255,0.25);
  --text:       #e8eaf6;
  --text-muted: #7c82a8;
  --success:    #4caf82;
  --warning:    #f0a500;
  --sidebar-w:  260px;
  --topbar-h:   58px;
  --radius:     12px;
  --radius-sm:  8px;
  --transition: 0.25s ease;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Overlay mobile ─────────────────────────────────────── */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
  backdrop-filter: blur(2px);
}
.overlay.active { display: block; }

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transform: translateX(-100%);
  transition: transform var(--transition);
  overflow-y: auto;
}
.sidebar.open { transform: translateX(0); }

@media (min-width: 900px) {
  .sidebar { transform: translateX(0); }
  .overlay { display: none !important; }
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 26px;
  color: var(--accent);
  text-shadow: 0 0 12px var(--accent-glow);
}

.logo-text {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.2;
  color: var(--text);
}
.logo-text small {
  font-size: 10px;
  color: var(--accent-light);
  letter-spacing: 0.15em;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}
.close-btn:hover { color: var(--text); background: var(--surface2); }

@media (min-width: 900px) { .close-btn { display: none; } }

.sidebar-nav {
  padding: 12px 0;
  flex: 1;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 16px 20px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all var(--transition);
  cursor: pointer;
}
.nav-item:hover {
  color: var(--text);
  background: var(--surface2);
}
.nav-item.active {
  color: var(--accent-light);
  background: rgba(108,99,255,0.1);
  border-left-color: var(--accent);
}

.nav-icon {
  font-size: 17px;
  width: 22px;
  text-align: center;
}

.sidebar-footer {
  padding: 14px 20px;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  text-align: center;
  letter-spacing: 0.05em;
}

/* ── Main layout ────────────────────────────────────────── */
.main-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
}

@media (min-width: 900px) {
  .main-wrapper { margin-left: var(--sidebar-w); }
}

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  z-index: 50;
  backdrop-filter: blur(10px);
}

.menu-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  line-height: 1;
  transition: background var(--transition);
}
.menu-btn:hover { background: var(--surface2); }

@media (min-width: 900px) { .menu-btn { display: none; } }

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

/* ── Content ────────────────────────────────────────────── */
.content {
  flex: 1;
  padding: 20px 16px 40px;
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
}

/* ── Sections ───────────────────────────────────────────── */
.calc-section { display: none; }
.calc-section.active { display: block; }

/* ── Card ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent-light);
  margin-bottom: 18px;
}

/* ── Forms ──────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 480px) { .form-grid { grid-template-columns: 1fr; } }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.form-grid .form-group { margin-bottom: 0; }

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

input[type="number"],
input[type="text"] {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  padding: 10px 14px;
  outline: none;
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
  -moz-appearance: textfield;
}
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button { -webkit-appearance: none; }

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ── Buttons ────────────────────────────────────────────── */
.btn-primary {
  width: 100%;
  margin-top: 6px;
  padding: 13px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: background var(--transition), box-shadow var(--transition), transform 0.1s;
  box-shadow: 0 4px 18px var(--accent-glow);
}
.btn-primary:hover { background: var(--accent-light); box-shadow: 0 6px 24px var(--accent-glow); }
.btn-primary:active { transform: scale(0.98); }

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.btn-tva {
  padding: 7px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-tva.active, .btn-tva:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── Results ────────────────────────────────────────────── */
.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 480px) { .results-grid { grid-template-columns: 1fr; } }

.result-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.result-box.accent {
  background: rgba(108,99,255,0.12);
  border-color: rgba(108,99,255,0.4);
}
.result-box.highlight {
  background: rgba(76,175,130,0.1);
  border-color: rgba(76,175,130,0.35);
}

.result-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.result-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
}
.result-box.accent .result-value { color: var(--accent-light); }
.result-box.highlight .result-value { color: var(--success); }

/* ── Chart ──────────────────────────────────────────────── */
.chart-container {
  position: relative;
  width: 100%;
  height: 280px;
}

.chart-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 14px;
  flex-wrap: wrap;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.legend-dot.accent { background: var(--accent); }
.legend-dot.muted { background: var(--text-muted); }

/* ── Promo badge ────────────────────────────────────────── */
.promo-badge-wrap {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

.promo-badge {
  background: linear-gradient(135deg, var(--accent), #ff6584);
  border-radius: 50%;
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 900;
  color: #fff;
  box-shadow: 0 8px 30px rgba(108,99,255,0.4);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* ── Pourcentage blocks ─────────────────────────────────── */
.pct-block { margin-bottom: 6px; }
.pct-block-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-light);
  margin-bottom: 12px;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* ── Topbar notepad btn ─────────────────────────────────── */
.notepad-btn {
  margin-left: auto;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 18px;
  padding: 5px 10px;
  cursor: pointer;
  position: relative;
  transition: background var(--transition), border-color var(--transition);
  display: flex;
  align-items: center;
  gap: 5px;
}
.notepad-btn:hover { background: var(--accent); border-color: var(--accent); }

.notepad-count {
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
  line-height: 1.4;
}

/* ── Result-value clickable ─────────────────────────────── */
.result-value.clickable {
  cursor: pointer;
  border-radius: 4px;
  transition: background var(--transition), color var(--transition);
  padding: 2px 4px;
  margin: -2px -4px;
}
.result-value.clickable:hover {
  background: rgba(108,99,255,0.2);
  color: var(--accent-light);
}
.result-value.clickable:hover::after {
  content: ' +';
  font-size: 14px;
  opacity: 0.6;
}

/* ── Notepad panel ──────────────────────────────────────── */
.notepad-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 198;
}
.notepad-overlay.active { display: block; }

.notepad-panel {
  position: fixed;
  top: 0;
  right: -320px;
  width: 300px;
  max-width: 92vw;
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 199;
  display: flex;
  flex-direction: column;
  transition: right var(--transition);
  box-shadow: -8px 0 40px rgba(0,0,0,0.4);
  overflow: hidden;
}
.notepad-panel.open { right: 0; }

.notepad-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.notepad-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.notepad-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.notepad-clear {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 11px;
  padding: 4px 8px;
  cursor: pointer;
  transition: all var(--transition);
}
.notepad-clear:hover { border-color: #e74c3c; color: #e74c3c; }

.notepad-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}
.notepad-close:hover { color: var(--text); background: var(--surface2); }

.notepad-hint {
  font-size: 11px;
  color: var(--text-muted);
  padding: 10px 16px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.notepad-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.notepad-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 40px;
}

.notepad-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  animation: fadeIn 0.2s ease;
}

.notepad-item-content {
  flex: 1;
  min-width: 0;
}

.notepad-item-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 3px;
}

.notepad-item-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--accent-light);
  word-break: break-all;
}

.notepad-item-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
}
.notepad-item-delete:hover { color: #e74c3c; background: rgba(231,76,60,0.1); }

/* ── Toast ──────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface2);
  border: 1px solid var(--accent);
  color: var(--accent-light);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 300;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Animations ─────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.calc-section.active { animation: fadeIn 0.3s ease; }
.card { animation: fadeIn 0.3s ease; }
