/* =========================================
   STUDY OS DASHBOARD LAYOUT
   ========================================= */
:root {
  --os-font-display: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  --os-font-ui: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --os-font-mono: 'IBM Plex Mono', monospace;
}

.os-dashboard-body {
  display: block !important;
  background-color: #f7f9fc;
  font-family: var(--os-font-ui);
  color: #30313d;
  -webkit-font-smoothing: antialiased;
  margin: 0 !important;
  padding: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  overflow: hidden !important;
}

.os-dashboard-body h1,
.os-dashboard-body h2,
.os-dashboard-body h4,
.os-dashboard-body .brand-text,
.os-dashboard-body .stat-time,
.os-dashboard-body .study-timer-display {
  font-family: var(--os-font-display);
}

.os-dashboard-body .os-card h3,
.os-dashboard-body .stat-subj,
.os-dashboard-body .form-group label,
.os-dashboard-body .calendar-weekday,
.os-dashboard-body .exam-days,
.os-dashboard-body .exam-detail-badge {
  font-family: var(--os-font-mono);
}

.os-app-container {
  display: flex !important;
  flex-direction: row !important;
  height: 100vh !important;
  width: 100vw !important;
  position: relative !important;
  overflow: hidden !important;
}

/* --- MOBILE ELEMENTS: STRICTLY HIDDEN ON DESKTOP --- */
#os-mobile-bar,
.mobile-topbar {
  display: none !important;
}

#os-mobile-overlay,
.sidebar-overlay {
  display: none !important;
}

#os-close-drawer-btn {
  display: none !important;
}

/* --- LEFT SIDEBAR (Desktop Defaults) --- */
#dashboard-sidebar.os-sidebar,
.os-sidebar {
  width: 240px !important;
  min-width: 240px !important;
  height: 100vh !important;
  background-color: #ffffff !important;
  border-right: 1px solid #e3e8ee !important;
  display: flex !important;
  flex-direction: column !important;
  padding: 24px 16px !important;
  box-sizing: border-box !important;
  flex-shrink: 0 !important;
  z-index: 100 !important;
  position: relative !important;
  left: 0 !important;
  top: 0 !important;
  transform: none !important;
  box-shadow: none !important;
}

.sidebar-brand {
  padding: 0 12px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-brand .brand-text {
  font-size: 19px;
  font-weight: 700;
  color: #0071e3;
  letter-spacing: -0.03em;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.nav-item, .nav-tab {
  text-decoration: none;
  color: #6b7280;
  font-size: 14px;
  font-weight: 600;
  padding: 12px 14px; 
  border-radius: 8px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  min-height: 44px; 
}
.nav-item:hover, .nav-tab:hover {
  background-color: #f3f4f6;
  color: #111827;
}
.nav-item.active, .nav-tab.active {
  background-color: #e5f1fb;
  color: #0071e3;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid #e3e8ee;
  margin-top: auto;
}
.dash-email {
  font-family: var(--os-font-mono);
  font-size: 11.5px;
  font-weight: 500;
  color: #6b7280;
  word-break: break-all;
  display: inline-block;
  padding: 8px 12px; 
  background: #f3f4f6;
  border-radius: 12px;
  transition: background 0.2s;
  width: 100%; 
  box-sizing: border-box;
}
.dash-email:hover {
  background: #e5e7eb;
}

/* --- MAIN CONTENT & HEADER --- */
.os-main {
  flex: 1 !important;
  height: 100vh !important;
  display: flex !important;
  flex-direction: column !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  position: relative !important;
  -webkit-overflow-scrolling: touch !important; 
}

.os-header {
  background-color: #0071e3;
  padding: 40px 40px 100px 40px; 
  color: white;
}

.header-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-top-row h1 {
  font-size: 26px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.025em;
}

/* --- MONTHLY STATS (BASE) --- */
.header-metrics-row {
  display: grid !important;
  grid-template-columns: repeat(4, 1fr) !important;
  gap: 16px !important;
  margin-top: 32px;
  overflow-x: visible !important;
}

.monthly-stat-item {
  width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box;
  display: flex; 
  align-items: center; 
  gap: 14px; 
  background: #ffffff; 
  border: none; 
  padding: 16px 20px; 
  border-radius: 12px; 
  box-shadow: 0 4px 15px rgba(0,0,0,0.1); 
  transition: transform 0.2s; 
}
.monthly-stat-item:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.15); }
.stat-indicator { display: none; }
.stat-info { display: flex; flex-direction: column-reverse; gap: 4px; }
.stat-time { font-size: 24px; font-weight: 700; color: #111827; letter-spacing: -0.03em; } 
.stat-subj { font-size: 11px; font-weight: 600; color: #6b7280; text-transform: uppercase; letter-spacing: 0.06em; }


/* --- GRID CARDS & FORMS --- */
.os-content-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 24px;
  padding: 0 40px 60px 40px;
  margin-top: -50px; 
  max-width: 1400px;
}
.os-card {
  background-color: #ffffff;
  border-radius: 12px; 
  box-shadow: 0 2px 5px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.02);
  border: 1px solid #e3e8ee;
  padding: 24px;
  grid-column: span 12; 
}
.os-card h3 {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin: 0 0 20px 0;
}
.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.card-header-row h3 {
  margin: 0;
}

.form-row-double { display: flex; gap: 16px; margin-bottom: 16px; }
.form-row-horizontal { display: flex; gap: 16px; margin-bottom: 16px; align-items: flex-end; } 
@media (max-width: 900px) { .form-row-horizontal { flex-direction: column; align-items: stretch; } }

.form-group { flex: 1; margin-bottom: 12px; }
.form-group label { display: block; font-size: 11.5px; font-weight: 600; color: #4b5563; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.05em; }
.dash-input { width: 100%; padding: 12px 14px; border-radius: 8px; border: 1px solid #e3e8ee; font-size: 15px; color: #111827; background-color: #ffffff; transition: all 0.2s; font-family: var(--os-font-ui); box-sizing: border-box; height: 44px; }
.dash-input:focus { border-color: #0071e3; box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1); outline: none; }
textarea.dash-input { resize: vertical; min-height: 80px; height: auto; }

.slider-container { display: flex; align-items: center; gap: 16px; }
.slider-val { font-family: var(--os-font-mono); font-weight: 600; font-size: 13.5px; color: #0071e3; }
.color-options { display: flex; gap: 12px; }
.color-circle { width: 32px; height: 32px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; }
.color-circle.selected { border-color: #111827; transform: scale(1.1); }
.bg-blue { background: #0071e3; } .bg-orange { background: #ff9500; } .bg-red { background: #ff3b30; } .bg-purple { background: #af52de; } .bg-green { background: #34c759; } .bg-teal { background: #5ac8fa; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 44px; }
.priority-label-text { font-size: 14px; font-weight: 600; color: #6b7280; }
.switch { position: relative; display: inline-block; width: 50px; height: 28px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #d1d5db; transition: .3s; border-radius: 28px; }
.slider:before { position: absolute; content: ""; height: 24px; width: 24px; left: 2px; bottom: 2px; background-color: white; transition: .3s; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
input:checked + .slider { background-color: #34c759; }
input:checked + .slider:before { transform: translateX(22px); }


/* --- BUTTONS --- */
.btn-primary, .btn-secondary {
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--os-font-ui);
  min-height: 44px; 
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-primary {
  background-color: #0071e3;
  color: white;
  border: none;
  padding: 10px 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.btn-primary:hover { background-color: #005ce6; }
.log-btn { width: 100%; padding: 14px; margin-top: 16px; }
.btn-secondary { background-color: #ffffff; color: #374151; border: 1px solid #d1d5db; padding: 10px 18px; }
.btn-secondary:hover { background-color: #f9fafb; }


/* --- BANNER --- */
.action-banner {
  background-color: #0071e3;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  flex-wrap: wrap; 
  gap: 12px;
}
.action-banner h3 { font-family: var(--os-font-display); color: white; margin: 0; font-size: 16px; letter-spacing: -0.02em; text-transform: none; }
.banner-content { display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 500; }
.banner-cta { background: white; color: #0071e3; text-decoration: none; padding: 10px 18px; border-radius: 8px; font-weight: 600; }


/* --- MODALS --- */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 10000; padding: 16px; box-sizing: border-box; }
.modal-content { background: white; width: 100%; max-width: 440px; border-radius: 12px; padding: 24px; box-shadow: 0 10px 25px rgba(0,0,0,0.1); max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.modal-header h2 { margin: 0; font-size: 20px; letter-spacing: -0.02em; }
.icon-btn { background: none; border: none; font-size: 20px; cursor: pointer; color: #9ca3af; padding: 8px; }
.status-text { font-family: var(--os-font-mono); font-size: 12.5px; margin-top: 8px; min-height: 20px; }
.status-text.success { color: #34c759; }
.status-text.error { color: #df1b41; }
.log-item { border: 1px solid #e3e8ee; border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.log-header { display: flex; justify-content: space-between; margin-bottom: 12px; align-items: flex-start; }
.log-title-group { display: flex; align-items: center; gap: 10px; font-family: var(--os-font-display); font-size: 15px; font-weight: 700; letter-spacing: -0.02em; }
.log-color-dot { width: 12px; height: 12px; border-radius: 50%; }
.log-stats { font-family: var(--os-font-mono); font-size: 12px; color: #6b7280; margin-bottom: 12px; display: flex; gap: 16px; flex-wrap: wrap; }
.log-reflection { font-size: 14px; font-style: italic; color: #374151; background: #f9fafb; padding: 12px; border-radius: 6px; border-left: 3px solid #e3e8ee; margin: 0; }
.log-next-action { font-size: 14px; color: #0071e3; background: #e5f1fb; padding: 12px; border-radius: 6px; margin-top: 12px; font-weight: 500; }

/* =========================================
   NEW FIXES APPLIED (CALENDAR, EXAMS, RADAR)
   ========================================= */

/* --- CALENDAR (CLIPPING FIX) --- */
.consistency-grid-full {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 16px;
  padding-left: 4px;
  padding-right: 16px;
  -webkit-overflow-scrolling: touch; 
  scrollbar-width: none; 
}
.consistency-grid-full::-webkit-scrollbar { display: none; } 

.calendar-month {
  width: auto;
  min-width: 250px; 
  flex: 0 0 auto;
  background: #ffffff;
  border: 1px solid #e3e8ee;
  border-radius: 12px;
  padding: 16px;
}
.calendar-month h4 {
  text-align: left;
  margin: 0 0 16px 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #111827;
}
.calendar-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px; 
  text-align: center;
}
.calendar-weekday { font-size: 11px; font-weight: 600; color: #9ca3af; margin-bottom: 4px; }
.calendar-day {
  font-family: var(--os-font-mono);
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 600; border-radius: 6px;
  background-color: #f3f4f6; color: #9ca3af; cursor: crosshair;
}
.calendar-day.empty { background: transparent; }
.calendar-day.future-day { opacity: 0.3; background: transparent; border: 1px dashed #d1d5db; }
.calendar-day.has-data { color: white; }
.calendar-day.activity-level-1 { background-color: #9be9a8; color: #111827; }
.calendar-day.activity-level-2 { background-color: #40c463; }
.calendar-day.activity-level-3 { background-color: #30a14e; }
.calendar-day.activity-level-4 { background-color: #216e39; }
.consistency-legend { font-family: var(--os-font-mono); display: flex; justify-content: flex-end; gap: 8px; font-size: 11.5px; color: #6b7280; margin-top: 16px; align-items: center; }
.consistency-legend .calendar-day { width: 14px; height: 14px; font-size: 0; }

/* --- EXAMS LIST (ICONS MOVED TO TOP RIGHT) --- */
.exams-list-container { display: flex; flex-direction: column; gap: 12px; }
.exam-chip {
  position: relative; 
  display: flex; 
  flex-direction: column; 
  align-items: flex-start;
  padding: 20px 16px; 
  border: 1px solid #e3e8ee; 
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
  gap: 12px;
}
.exam-info strong { 
  font-family: var(--os-font-display);
  font-size: 16px; 
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #111827; 
  display: block; 
  margin-bottom: 4px; 
  padding-right: 48px;
}
.exam-date { 
  font-family: var(--os-font-mono);
  font-size: 12.5px; 
  color: #6b7280; 
  display: flex; 
  align-items: center; 
  gap: 8px; 
  flex-wrap: wrap;
}
.exam-right-group { 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  width: 100%; 
  margin-top: 4px; 
}
.exam-days { font-size: 12px; font-weight: 700; color: #0071e3; background: #e5f1fb; padding: 6px 12px; border-radius: 6px; }
.exam-days.urgent { color: #b91c1c; background: #fef2f2; }
.exam-detail-badge { font-size: 11.5px; background: white; border: 1px solid #e3e8ee; padding: 4px 8px; border-radius: 6px; color: #6b7280; display: inline-flex; align-items: center; gap: 4px; }

/* Absolute position for edit/delete icons on exam cards */
.exam-actions-container {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 12px;
}
.exam-actions-container button {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s;
}
.exam-actions-container button:hover { color: #374151; }

/* =========================================
   LIVE STUDY TIMER / POMODORO & EXAMS EMPTY STATE
   ========================================= */
.minutes-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.minutes-input-row .dash-input {
  flex: 1;
  min-width: 0;
}
.timer-trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  height: 44px;
  white-space: nowrap;
  flex-shrink: 0;
  color: #0071e3;
  border-color: #cfe4fa;
  background-color: #f0f7ff;
}
.timer-trigger-btn:hover {
  background-color: #e0effe;
}
.timer-trigger-btn.timer-active {
  background-color: #0071e3;
  color: #ffffff;
  border-color: #0071e3;
}
.input-auto-filled {
  border-color: #34c759 !important;
  box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.2) !important;
}

.study-timer-panel {
  background: #f7f9fc;
  border: 1px solid #e3e8ee;
  border-radius: 16px;
  padding: 24px 28px 28px;
  margin: 4px 0 24px;
  text-align: center;
}
.timer-panel-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
}
.timer-mode-tabs {
  display: inline-flex;
  background: #ffffff;
  border: 1px solid #e3e8ee;
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
  flex-wrap: wrap;
}
.timer-mode-btn {
  font-family: var(--os-font-mono);
  border: none;
  background: transparent;
  color: #6b7280;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.timer-mode-btn:hover {
  color: #111827;
}
.timer-mode-btn.active {
  background: #0071e3;
  color: #ffffff;
}
.timer-display-wrapper {
  padding: 12px 0 24px;
}
.study-timer-display {
  font-size: 72px;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.05;
  color: #111827;
  font-variant-numeric: tabular-nums;
  margin-bottom: 8px;
  transition: color 0.2s ease;
}
.study-timer-display.is-running {
  color: #0071e3;
}
.study-timer-status {
  font-size: 14px;
  color: #6b7280;
  font-weight: 500;
}
.timer-controls-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}
.timer-action-btn {
  min-width: 150px;
  height: 46px;
  font-size: 15px;
}
.timer-fill-btn {
  min-width: 180px;
  height: 46px;
  font-size: 15px;
  background-color: #111827;
}
.timer-fill-btn:hover:not(:disabled) {
  background-color: #1f2937;
}
.timer-fill-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.timer-reset-btn {
  height: 46px;
  padding: 0 20px;
}

.exams-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 36px 20px;
  border: 1px dashed #d1d5db;
  border-radius: 12px;
  background: #f9fafb;
  color: #9ca3af;
  gap: 6px;
}
.exams-empty-title {
  font-family: var(--os-font-display);
  margin: 6px 0 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #374151;
}
.exams-empty-desc {
  margin: 0;
  font-size: 13px;
  color: #6b7280;
}

/* =========================================
   MOBILE RESPONSIVENESS OVERHAUL (< 768px)
   ========================================= */

@media (max-width: 1024px) {
  .header-metrics-row {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media screen and (max-width: 768px) {
  
  .os-header {
    padding: 24px 16px 40px 16px !important; 
  }
  
  .header-top-row { display: block !important; }
  .header-top-row h1 { font-size: 24px !important; margin-bottom: 4px !important; }

  /* 2x2 Grid for Mobile Metrics */
  .header-metrics-row {
    display: grid !important; 
    grid-template-columns: 1fr 1fr !important;
    gap: 12px !important;
    margin-top: 16px !important;
    overflow-x: hidden !important; 
  }
  
  .monthly-stat-item {
    flex: none !important;
    width: 100% !important;
    padding: 16px 12px !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
  }
  
  .stat-time { font-size: 20px !important; }

  /* Content Cards Stack */
  .os-content-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
    padding: 0 16px 40px 16px !important; 
    margin-top: -20px !important; 
  }
  
  .card-header-row {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
  }

  .header-actions {
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important; 
    gap: 8px !important;
  }

  .header-actions button {
    width: 100% !important; 
    padding: 12px !important;
    justify-content: center !important;
  }

  .form-row-double {
    flex-direction: column !important;
    gap: 12px !important;
  }
  
  /* Make save button full width and taller for better mobile UX */
  #log-study-btn {
    width: 100% !important;
    height: 30px !important;
    margin-top: 16px !important;
    margin-right: 20px !important;
    right: 30px;
    font-size: 12px !important;
  }

  .study-timer-panel {
    padding: 18px 16px 22px !important;
  }
  .study-timer-display {
    font-size: 52px !important;
  }
  .timer-controls-row {
    flex-direction: column !important;
  }
  .timer-action-btn,
  .timer-fill-btn,
  .timer-reset-btn {
    width: 100% !important;
  }

  /* Stop Radar Chart from clipping edges */
  .chart-container {
    padding: 0 12px !important;
  }
  
  .action-banner {
    flex-direction: column !important;
    align-items: flex-start !important;
    text-align: left !important;
    gap: 16px !important;
  }
  
  .banner-content { 
    flex-direction: column !important; 
    align-items: flex-start !important; 
    gap: 8px !important;
  }
  
  .banner-cta {
    width: 100% !important;
    text-align: center !important;
    box-sizing: border-box !important;
  }
}