/* =========================================
   STUDYWEEK — REDESIGN COMPLETO
   Dashboard + Agenda com Grade de Horários
   ========================================= */

/* VARIÁVEIS & RESET */
:root {
  color-scheme: dark;
  --bg: #111723;
  --bg2: #171d2b;
  --bg3: #1f2738;
  --border: #2b3446;
  --border2: #3b455c;
  --text: #f5f7fb;
  --muted: #90a0be;
  --accent: #7dd3fc;
  --accent-strong: #38bdf8;
  --accent-soft: rgba(125, 211, 252, 0.16);
  --accent2: #a78bfa;
  --danger: #fb7185;
  --radius: 16px;
  --radius-sm: 12px;
  --font-main: 'Syne', sans-serif;
  --font-mono: 'DM Mono', monospace;
  --shadow: 0 14px 40px rgba(2, 6, 23, 0.24);
  --shadow-soft: 0 10px 24px rgba(15, 23, 42, 0.16);
}

body[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f7fb;
  --bg2: #ffffff;
  --bg3: #eef3f8;
  --border: #dfe7f2;
  --border2: #cbd6e4;
  --text: #112033;
  --muted: #5f6f85;
  --accent: #0f766e;
  --accent-strong: #0ea5a5;
  --accent-soft: rgba(15, 118, 110, 0.12);
  --accent2: #7c3aed;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
  --shadow-soft: 0 10px 24px rgba(15, 23, 42, 0.08);
}

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

html {
  scroll-behavior: smooth;
}

body {
  background: radial-gradient(circle at top left, rgba(125, 211, 252, 0.16), transparent 28%),
              radial-gradient(circle at bottom right, rgba(167, 139, 250, 0.08), transparent 20%),
              var(--bg);
  color: var(--text);
  font-family: var(--font-main);
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  transition: background 0.25s ease, color 0.25s ease;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at top left, rgba(125, 211, 252, 0.04), transparent 28%),
              radial-gradient(circle at bottom right, rgba(167, 139, 250, 0.03), transparent 20%);
}

.main-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 0;
  flex: 1;
  overflow: hidden;
  min-height: calc(100vh - 96px);
}

/* HEADER (TOPO FIXO) */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(14, 19, 31, 0.92);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(18px);
  gap: 24px;
  box-shadow: 0 18px 40px rgba(2, 6, 23, 0.18);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(125, 211, 252, 0.12);
  color: var(--accent);
  font-size: 1.4rem;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.logo-title {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.8px;
  color: var(--text);
}

.header-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.week-nav {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 10px 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.btn-week-nav {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid transparent;
  border-radius: 50%;
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-week-nav:hover,
.btn-week-nav:focus-visible {
  border-color: rgba(125, 211, 252, 0.5);
  color: var(--accent);
  background: rgba(125, 211, 252, 0.18);
}

.week-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 150px;
}

.week-range {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 10px;
  min-width: 100px;
  border-radius: 999px;
  background: rgba(125, 211, 252, 0.12);
  color: var(--accent);
}

.week-label {
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  font-family: var(--font-mono);
}

.week-range {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
  font-family: var(--font-mono);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #07111f;
  border: none;
  border-radius: 999px;
  font-family: var(--font-main);
  font-size: 0.95rem;
  font-weight: 800;
  padding: 12px 22px;
  cursor: pointer;
  letter-spacing: 0.4px;
  transition: filter 0.18s, transform 0.18s, box-shadow 0.18s;
  box-shadow: 0 16px 36px rgba(56, 189, 248, 0.24);
}

.btn-primary:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

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

.btn-icon,
.btn-export {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  min-height: 40px;
  border-radius: 999px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-soft);
}

.btn-icon {
  width: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-export {
  padding: 0 18px;
  font-weight: 700;
}

.btn-icon:hover,
.btn-export:hover {
  border-color: rgba(125, 211, 252, 0.55);
  color: var(--accent);
  transform: translateY(-1px);
  background: rgba(125, 211, 252, 0.14);
}

.export-menu-wrapper {
  position: relative;
}

.export-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  min-width: 200px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(2, 6, 23, 0.18);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  z-index: 120;
}

.export-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.export-option {
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--font-main);
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
}

.export-option:hover,
.export-option:focus {
  background: var(--bg3);
  color: var(--accent);
}

/* MAIN LAYOUT */
.main-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 0;
  flex: 1;
  overflow: hidden;
}

/* DASHBOARD */
.dashboard {
  background: linear-gradient(180deg, rgba(13, 17, 27, 0.98), rgba(23, 30, 46, 0.99));
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  padding: 24px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.dashboard::-webkit-scrollbar {
  width: 6px;
}

.dashboard::-webkit-scrollbar-track {
  background: transparent;
}

.dashboard::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 3px;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

/* DASHBOARD CARDS */
.dashboard-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: calc(var(--radius) + 4px);
  padding: 18px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: fadeIn 0.3s ease;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.1);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.card-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-family: var(--font-mono);
}

/* PROGRESS CARD */
.progress-card {
  gap: 16px;
}

.progress-visual {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
}

.progress-ring-wrap {
  position: relative;
  width: min(190px, 72vw);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.progress-ring-wrap svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: var(--border2);
  stroke-width: 2.2;
}

.ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.2;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.4s ease;
}

.progress-pct {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  font-weight: 800;
  color: var(--accent);
  font-family: var(--font-mono);
}

.progress-text {
  width: 100%;
  display: flex;
  justify-content: center;
}

.progress-label {
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.55;
  max-width: 220px;
}

/* STATS CARD */
.stats-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stat-item {
  padding: 18px 16px;
}

.stat-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px 16px;
  text-align: center;
  box-shadow: var(--shadow-soft);
}

.stat-label {
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-family: var(--font-mono);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--accent);
}

/* SUBJECTS LIST */
.subjects-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.subject-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.2s, transform 0.18s;
}

.subject-item:hover {
  border-color: var(--accent2);
  transform: translateY(-1px);
}

.subject-item:hover {
  border-color: var(--accent2);
}

.subject-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.subject-name {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subject-count {
  font-size: 0.75rem;
  color: var(--muted);
  font-family: var(--font-mono);
  background: var(--bg2);
  padding: 2px 8px;
  border-radius: 4px;
}

/* DAY SUMMARY */
.day-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.day-chip {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  text-align: center;
}

.day-chip-name {
  font-size: 0.65rem;
  color: var(--muted);
  font-family: var(--font-mono);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.day-chip-count {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
}

.day-chip-hours {
  font-size: 0.65rem;
  color: var(--accent);
  font-family: var(--font-mono);
}

/* NEXT SESSION */
.next-session-item {
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.12), rgba(255,255,255,0.04));
  border: 1px solid rgba(56, 189, 248, 0.18);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.next-session-subject {
  color: var(--text);
}

.next-session-subject {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.next-session-time {
  font-size: 0.75rem;
  color: var(--muted);
  font-family: var(--font-mono);
}

.next-session-day {
  font-size: 0.7rem;
  color: var(--accent);
  font-family: var(--font-mono);
  font-weight: 600;
}

.no-session {
  text-align: center;
  padding: 12px;
  color: var(--muted);
  font-size: 0.85rem;
}

/* AGENDA SECTION */
.agenda-section {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* TIME GRID HEADER */
.time-grid-header {
  display: grid;
  grid-template-columns: 70px 1fr;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg2);
}

.days-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-left: 1px solid var(--border);
}

.day-header-cell {
  padding: 16px 12px;
  text-align: center;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 4px;
  justify-content: center;
  background: rgba(255, 255, 255, 0.02);
  transition: background 0.2s;
}

.day-header-cell:hover {
  background: rgba(125, 211, 252, 0.08);
}

.day-header-cell.today {
  background: rgba(125, 211, 252, 0.16);
}

.day-header-cell.today .day-header-name {
  color: var(--accent);
}

.day-header-name {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--muted);
  font-family: var(--font-mono);
}

.day-header-date {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
}

/* TIME GRID CONTAINER */
.time-grid-container {
  display: grid;
  grid-template-columns: 70px 1fr;
  flex: 1;
  overflow: auto;
  position: relative;
  background: linear-gradient(180deg, rgba(255,255,255,0.015), transparent 2%), linear-gradient(90deg, rgba(255,255,255,0.015), transparent 2%);
  background-size: 100% 60px, calc(100% / 7) 100%;
}

.time-grid-container::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.time-grid-container::-webkit-scrollbar-track {
  background: transparent;
}

.time-grid-container::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 3px;
}

/* TIME LABELS */
.time-labels {
  background: var(--bg2);
  border-right: 1px solid var(--border);
  padding: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  left: 0;
  z-index: 10;
}

.time-label {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-family: var(--font-mono);
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* TIME GRID */
.time-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  position: relative;
}

.time-slot {
  height: 60px;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  position: relative;
}

.time-slot:last-child {
  border-right: none;
}

/* SESSION BLOCKS */
.session-block {
  position: absolute;
  left: 0;
  right: 0;
  margin: 2px;
  border-radius: var(--radius-sm);
  padding: 14px 14px 12px;
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
  animation: slideInBlock 0.25s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.16);
  background: rgba(255,255,255,0.04);
}

.session-block:hover {
  transform: translateY(-1px);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.2);
}

@keyframes slideInBlock {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.session-block:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.16);
  z-index: 5;
}

.session-block.done {
  opacity: 0.78;
}

.session-block-time {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  font-weight: 700;
  opacity: 0.9;
  letter-spacing: 0.3px;
}

.session-block-subject {
  font-size: 0.95rem;
  font-weight: 800;
  margin-top: 4px;
  line-height: 1.3;
}

.session-block-notes {
  margin-top: 8px;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--muted);
}

.session-block-check {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.18);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  transition: background 0.18s, transform 0.18s, border-color 0.18s;
}

.session-block-check:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: scale(1.05);
}

.session-block.done .session-block-check {
  background: rgba(34, 197, 94, 0.9);
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  backdrop-filter: blur(2px);
}

.drawer-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.drawer-panel {
  background: var(--bg2);
  border-left: 1px solid var(--border);
  width: 420px;
  max-width: 92vw;
  height: 100vh;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
  transform: translateX(420px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow-y: auto;
}

.drawer-overlay.open .drawer-panel {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  background: var(--bg2);
}

.btn-close-drawer {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg3);
  color: var(--muted);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: all 0.2s;
}

.btn-close-drawer:hover {
  background: var(--border2);
  color: var(--text);
}

.drawer-content {
  padding: 20px 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Mobile: drawer vem de baixo */
@media (max-width: 768px) {
  .drawer-panel {
    width: 100%;
    height: auto;
    max-height: 90vh;
    border-left: none;
    border-top: 1px solid var(--border);
    transform: translateY(90vh);
  }

  .drawer-overlay.open .drawer-panel {
    transform: translateY(0);
  }

  .drawer-header {
    border-bottom: 1px solid var(--border);
  }
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label,
.form-label,
legend {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  font-family: var(--font-mono);
}

.form-input,
.form-textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 12px;
  font-family: var(--font-main);
  font-size: 0.9rem;
  transition: border-color 0.2s;
}

.form-input:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-textarea {
  min-height: 80px;
  resize: vertical;
}

.form-row {
  display: flex;
  gap: 10px;
}

.form-group.half {
  flex: 1;
}

/* DAY PICKER */
.day-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.day-btn {
  flex: 1;
  min-width: calc(100% / 7 - 6px);
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--muted);
  border-radius: 6px;
  padding: 8px 4px;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s;
}

.day-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.day-btn.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #0d0d0f;
}

/* [MELHORIA 3] COLOR PICKER — Grid de 12 cores customizado */
.color-picker {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}

.color-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  position: relative;
}

.color-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.color-btn.selected {
  border-color: var(--text);
  transform: scale(1.15);
  box-shadow: 0 0 0 2px var(--bg2), 0 0 10px rgba(201, 245, 66, 0.4);
}

/* MODAL ACTIONS */
.modal-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
}

.btn-delete {
  background: rgba(255, 77, 109, 0.12);
  border: 1px solid rgba(255, 77, 109, 0.35);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.18s;
  margin-right: auto;
}

.btn-delete:hover {
  background: rgba(255, 77, 109, 0.2);
}

.btn-cancel {
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--muted);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.18s;
}

.btn-cancel:hover {
  border-color: var(--text);
  color: var(--text);
}

.btn-save {
  background: var(--accent);
  border: none;
  color: #0d0d0f;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-family: var(--font-main);
  font-weight: 800;
  font-size: 0.85rem;
  cursor: pointer;
  transition: filter 0.18s;
}

.btn-save:hover {
  filter: brightness(1.1);
}

/* TOAST */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg2);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 12px 24px;
  border-radius: 100px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  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);
}

/* =========================================
   RESPONSIVE: TABLET (max 1200px)
   ========================================= */
@media (max-width: 1200px) {
  .main-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }

  .dashboard {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 50vh;
    order: 2;
  }

  .agenda-section {
    order: 1;
    max-height: 50vh;
  }
}

/* =========================================
   RESPONSIVE: MOBILE (max 768px)
   ========================================= */
@media (max-width: 768px) {
  .header {
    padding: 14px 16px;
    flex-wrap: wrap;
    gap: 12px;
  }

  .logo-title {
    font-size: 1.2rem;
  }

  .header-center {
    width: 100%;
    order: 3;
  }

  .header-right {
    gap: 8px;
  }

  .btn-primary {
    padding: 8px 16px;
    font-size: 0.85rem;
  }

  .main-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .agenda-section {
    order: 1;
    max-height: 60vh;
    border-bottom: 1px solid var(--border);
  }

  .dashboard {
    order: 2;
    max-height: none;
    border-right: none;
    border-bottom: none;
    padding: 16px;
  }

  .time-grid-container {
    grid-template-columns: 50px 1fr;
  }

  .time-labels {
    width: 50px;
  }

  .time-label {
    height: 50px;
    font-size: 0.6rem;
  }

  .time-slot {
    height: 50px;
  }

  .day-header-cell {
    padding: 12px 6px;
  }

  .day-header-name {
    font-size: 0.65rem;
    letter-spacing: 1px;
  }

  .day-header-date {
    font-size: 0.85rem;
  }

  .session-block {
    padding: 4px 6px;
  }

  .session-block-time {
    font-size: 0.6rem;
  }

  .session-block-subject {
    font-size: 0.7rem;
  }

  .section-title {
    font-size: 1rem;
  }

  .dashboard-card {
    padding: 12px;
    gap: 8px;
  }

  .card-title {
    font-size: 0.75rem;
  }

  .day-summary {
    grid-template-columns: repeat(4, 1fr);
  }

  .day-chip {
    padding: 8px 6px;
  }

  .day-chip-name {
    font-size: 0.6rem;
  }

  .day-chip-count {
    font-size: 0.9rem;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .modal {
    width: 95vw;
    padding: 20px;
    gap: 12px;
  }

  .modal-title {
    font-size: 1rem;
  }

  .day-picker {
    gap: 4px;
  }

  .day-btn {
    min-width: calc(100% / 7 - 4px);
    padding: 6px 2px;
    font-size: 0.6rem;
  }

  .color-btn {
    width: 28px;
    height: 28px;
  }
}

/* =========================================
   RESPONSIVE: SMALL MOBILE (max 480px)
   ========================================= */
@media (max-width: 480px) {
  .header {
    padding: 12px;
    gap: 8px;
  }

  .logo-title {
    display: none;
  }

  .logo-icon {
    font-size: 1.4rem;
  }

  .week-nav {
    gap: 8px;
    padding: 6px 8px;
  }

  .btn-week-nav {
    font-size: 0.9rem;
  }

  .week-info {
    min-width: auto;
  }

  .week-range {
    font-size: 0.8rem;
  }

  .header-right {
    gap: 6px;
  }

  .btn-primary {
    padding: 6px 12px;
    font-size: 0.75rem;
  }

  .btn-icon,
  .btn-export {
    min-height: 36px;
    font-size: 0.9rem;
  }

  .btn-export {
    padding: 0 12px;
  }

  .time-grid-container {
    grid-template-columns: 45px 1fr;
  }

  .time-labels {
    width: 45px;
  }

  .time-label {
    height: 40px;
    font-size: 0.5rem;
  }

  .time-slot {
    height: 40px;
  }

  .day-header-cell {
    padding: 10px 4px;
    background: rgba(255, 255, 255, 0.02);
  }

  .day-header-name {
    font-size: 0.55rem;
    letter-spacing: 0.5px;
  }

  .day-header-date {
    font-size: 0.75rem;
  }

  .session-block {
    padding: 3px 4px;
    margin: 1px;
  }

  .session-block-time {
    font-size: 0.5rem;
  }

  .session-block-subject {
    font-size: 0.6rem;
  }

  .session-block-button {
    width: 16px;
    height: 16px;
    top: 4px;
    right: 4px;
  }

  .dashboard {
    padding: 12px;
  }

  .section-title {
    font-size: 0.95rem;
    margin-bottom: 2px;
  }

  .dashboard-card {
    padding: 10px;
    gap: 6px;
  }

  .card-title {
    font-size: 0.65rem;
  }

  .day-summary {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .day-chip {
    padding: 6px 4px;
  }

  .day-chip-name {
    font-size: 0.55rem;
  }

  .day-chip-count {
    font-size: 0.8rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .stat-item {
    padding: 10px;
  }

  .stat-value {
    font-size: 1.4rem;
  }

  .subjects-list {
    gap: 6px;
  }

  .subject-item {
    padding: 8px 10px;
    gap: 8px;
  }

  .subject-dot {
    width: 10px;
    height: 10px;
  }

  .subject-name {
    font-size: 0.8rem;
  }

  .subject-count {
    font-size: 0.65rem;
  }

  .modal {
    width: 90vw;
    padding: 16px;
    gap: 10px;
  }

  .modal-title {
    font-size: 0.95rem;
  }

  .form-input,
  .form-textarea {
    font-size: 0.85rem;
    padding: 8px 10px;
  }

  .form-textarea {
    min-height: 70px;
  }

  .day-picker {
    gap: 3px;
  }

  .day-btn {
    min-width: calc(100% / 7 - 3px);
    padding: 5px 2px;
    font-size: 0.55rem;
  }

  .color-btn {
    width: 26px;
    height: 26px;
  }

  .btn-save,
  .btn-cancel {
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  .btn-delete {
    padding: 8px 12px;
    font-size: 0.75rem;
  }

  .modal-actions {
    gap: 8px;
    margin-top: 6px;
  }
}

/* =========================================
   [MELHORIA 1] EMPTY STATE
   ========================================= */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  min-height: 200px;
}

.empty-state-icon {
  font-size: 3rem;
  opacity: 0.6;
  margin-bottom: 8px;
}

.empty-state-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.empty-state-subtitle {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 12px;
}

.empty-state-cta {
  background: var(--accent);
  color: #0d0d0f;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: filter 0.2s;
  margin-top: 8px;
}

.empty-state-cta:hover {
  filter: brightness(1.1);
}

/* =========================================
   [MELHORIA 2] HIERARQUIA VISUAL
   ========================================= */
.section-title {
  font-size: 0.92rem !important;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.8px;
  color: var(--accent);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid rgba(125, 211, 252, 0.18);
}

.card-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* =========================================
   [MELHORIA 12] EXPORT MENU
   ========================================= */
.export-menu-wrapper {
  position: relative;
}

.export-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  min-width: 180px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: all 0.2s;
  z-index: 150;
}

.export-menu.open {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

.export-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 0.9rem;
  text-align: left;
  transition: background 0.15s;
}

.export-option:hover {
  background: var(--bg3);
}

.export-option:active {
  background: var(--border);
}

/* =========================================
   [MELHORIA 5] TOASTS MELHORADOS
   ========================================= */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(120px);
  background: var(--bg2);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 12px 24px;
  border-radius: 100px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 300;
  white-space: nowrap;
  max-width: 90%;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* Stacking de toasts */
.toast:nth-of-type(2).show {
  bottom: 80px;
}

.toast:nth-of-type(3).show {
  bottom: 132px;
}
