:root {
  --color-primary: #4a90e2;
  --color-bg: #f8f8f8;
  --color-panel: #ffffff;
  --color-text: #1f2933;
  --color-muted: #6b7280;
  --color-danger: #f55c5c;
  --color-success: #7ac7a5;
  --radius-large: 18px;
  --radius-medium: 12px;
  --radius-small: 8px;
  --shadow-soft: 0 16px 40px rgba(31, 41, 51, 0.08);
  --shadow-light: 0 6px 12px rgba(31, 41, 51, 0.06);
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top right, rgba(74, 144, 226, 0.08), transparent 45%) var(--color-bg);
  color: var(--color-text);
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

/* App Layout with Sidebar */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.app-sidebar {
  width: 260px;
  background: var(--color-panel);
  border-right: 1px solid rgba(31, 41, 51, 0.1);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(31, 41, 51, 0.1);
}

.logo-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(31, 41, 51, 0.08);
}

.logo-image {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.logo-title {
  font-size: 24px;
  margin: 0;
  color: var(--color-primary);
  font-weight: 700;
  letter-spacing: -0.5px;
}

.sidebar-tagline {
  font-size: 12px;
  color: var(--color-muted);
  margin: 0;
  margin-top: 8px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: var(--color-text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-small);
  transition: all 0.18s ease;
  text-align: left;
  width: 100%;
}

.sidebar-nav-btn:hover {
  background: rgba(74, 144, 226, 0.08);
}

.sidebar-nav-btn.active {
  background: rgba(74, 144, 226, 0.15);
  color: var(--color-primary);
}

.nav-icon {
  font-size: 18px;
  width: 20px;
  text-align: center;
}

.nav-text {
  flex: 1;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(31, 41, 51, 0.1);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-language-select {
  width: 100%;
}

.sidebar-logout-btn {
  width: 100%;
  padding: 10px;
  border: 1px solid rgba(245, 92, 92, 0.3);
  background: transparent;
  color: var(--color-danger);
  border-radius: var(--radius-small);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.18s ease;
  font-weight: 500;
}

.sidebar-logout-btn:hover {
  background: rgba(245, 92, 92, 0.1);
  border-color: var(--color-danger);
}

/* Main Content Area */
.app-main {
  flex: 1;
  margin-left: 260px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-main .app-header {
  padding: 0;
  border: none;
  min-height: 0;
  background: transparent;
  display: none;
}

main {
  flex: 1;
  padding: 32px;
  overflow-y: auto;
}

/* Login Page Styles */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.login-panel {
  width: 100%;
  max-width: 420px;
  background: var(--color-panel);
  border-radius: var(--radius-large);
  box-shadow: var(--shadow-soft);
  padding: 40px;
}

.login-panel .logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-panel .logo h1 {
  margin-bottom: 8px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo h1 {
  font-size: clamp(24px, 5vw, 32px);
  margin: 0;
  color: var(--color-primary);
}

.logo p {
  margin: 4px 0 0;
  color: var(--color-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

select {
  appearance: none;
  padding: 10px 14px;
  border-radius: var(--radius-small);
  border: 1px solid rgba(74, 144, 226, 0.25);
  background: var(--color-panel);
  color: var(--color-text);
  font-size: 14px;
  cursor: pointer;
}

.ghost-btn,
.primary-btn,
.pill-btn {
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.primary-btn {
  background: var(--color-primary);
  color: #ffffff;
  box-shadow: var(--shadow-light);
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(74, 144, 226, 0.24);
}

.ghost-btn {
  background: rgba(74, 144, 226, 0.12);
  color: var(--color-primary);
}

.ghost-btn:hover {
  background: rgba(74, 144, 226, 0.2);
}

.pill-btn {
  background: transparent;
  color: var(--color-muted);
  padding: 10px 14px;
}

.pill-btn.active {
  color: var(--color-primary);
  background: rgba(74, 144, 226, 0.12);
}

/* Old tab-nav styles removed - using sidebar now */

.tab-panel {
  display: none;
  gap: 24px;
}

.tab-panel.active {
  display: grid;
}

.panel {
  background: var(--color-panel);
  padding: clamp(24px, 4vw, 32px);
  border-radius: var(--radius-large);
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 24px;
}

.panel-header h2,
.panel-header h3 {
  margin: 0;
  font-weight: 600;
}

.panel-header p {
  margin: 6px 0 0;
  color: var(--color-muted);
  line-height: 1.5;
}

.auth-toggle {
  display: flex;
  gap: 12px;
  background: rgba(74, 144, 226, 0.12);
  border-radius: 999px;
  padding: 4px;
  width: fit-content;
}

.auth-form {
  display: grid;
  gap: 16px;
}

.auth-form.hidden {
  display: none;
}

label {
  display: grid;
  gap: 6px;
  color: var(--color-muted);
  font-size: 14px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-small);
  border: 1px solid rgba(31, 41, 51, 0.1);
  background: rgba(255, 255, 255, 0.9);
  font-size: 15px;
  color: var(--color-text);
  transition: border 0.18s ease, box-shadow 0.18s ease;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.18);
}

.inline-form {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-items: end;
}

.grid-list {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.lesson-card {
  background: linear-gradient(140deg, rgba(74, 144, 226, 0.12), rgba(74, 144, 226, 0.04));
  border-radius: var(--radius-medium);
  padding: 18px;
  display: grid;
  gap: 8px;
  position: relative;
  overflow: hidden;
}

.lesson-card::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.3;
  background: var(--lesson-color, rgba(74, 144, 226, 0.2));
}

.lesson-card-content {
  position: relative;
  display: grid;
  gap: 6px;
}

.lesson-card h4 {
  margin: 0;
  font-size: 16px;
}

.lesson-card small {
  color: var(--color-muted);
}

.lesson-actions {
  display: flex;
  gap: 8px;
}

.calendar-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.empty-state {
  padding: 18px;
  border-radius: var(--radius-medium);
  background: rgba(31, 41, 51, 0.04);
  color: var(--color-muted);
  text-align: center;
}

.calendar-item {
  background: rgba(31, 41, 51, 0.03);
  border-radius: var(--radius-medium);
  padding: 16px;
  display: grid;
  gap: 8px;
}

.calendar-date {
  font-weight: 600;
  color: var(--color-text);
}

/* Study Room Layout */
.study-room-layout {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.study-room-timer-panel {
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
}

.study-room-settings-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.timer-display {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 40px 24px;
  border-radius: var(--radius-large);
  background: linear-gradient(180deg, rgba(74, 144, 226, 0.12), rgba(74, 144, 226, 0.04));
}

.timer-time {
  font-size: clamp(48px, 12vw, 88px);
  font-weight: 600;
  letter-spacing: 2px;
}

.timer-status {
  font-size: 16px;
  color: var(--color-muted);
}

.timer-controls {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.custom-time {
  display: grid;
  gap: 12px;
}

.timer-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.timer-buttons .ghost-btn {
  background: rgba(31, 41, 51, 0.06);
  color: var(--color-text);
}

.timer-buttons .ghost-btn:hover {
  background: rgba(31, 41, 51, 0.12);
}

.stats-filters {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.charts-grid {
  display: grid;
  gap: 24px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.chart-card {
  background: rgba(31, 41, 51, 0.03);
  border-radius: var(--radius-medium);
  padding: 18px;
  display: grid;
  gap: 12px;
}

#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 18px;
  border-radius: var(--radius-medium);
  background: rgba(31, 41, 51, 0.9);
  color: #ffffff;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

.field-hint {
  font-size: 12px;
  color: var(--color-muted);
  margin-top: 4px;
}

.calendar-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
}

.tasks-sidebar {
  display: flex;
  flex-direction: column;
}

.tasks-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 600px;
  overflow-y: auto;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: rgba(31, 41, 51, 0.03);
  border-radius: var(--radius-small);
  transition: background 0.18s ease;
}

.task-item:hover {
  background: rgba(31, 41, 51, 0.06);
}

.task-item.completed {
  opacity: 0.6;
}

.task-item.completed .task-title {
  text-decoration: line-through;
}

.task-checkbox {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--color-primary);
}

.task-title {
  flex: 1;
  font-size: 14px;
  color: var(--color-text);
}

.task-actions {
  display: flex;
  gap: 8px;
}

.calendar-main {
  display: flex;
  flex-direction: column;
}

.calendar-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.calendar-controls h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.calendar-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-bottom: 24px;
  grid-auto-rows: minmax(100px, auto);
}

.calendar-day-header {
  text-align: center;
  font-weight: 600;
  font-size: 12px;
  color: var(--color-muted);
  padding: 8px;
}

.calendar-day {
  position: relative;
  padding: 6px;
  border: 1px solid rgba(31, 41, 51, 0.1);
  border-radius: var(--radius-small);
  background: var(--color-panel);
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 100px;
  height: 100%;
}

.calendar-day:hover {
  background: rgba(74, 144, 226, 0.08);
  border-color: var(--color-primary);
}

.calendar-day.other-month {
  opacity: 0.4;
  background: rgba(31, 41, 51, 0.02);
}

.calendar-day.today {
  border-color: var(--color-primary);
  background: rgba(74, 144, 226, 0.12);
}

.calendar-day-number {
  font-weight: 600;
  font-size: 14px;
}

.calendar-day-events {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  margin-top: 2px;
  width: 100%;
}

.calendar-event-dot-base {
  width: 100%;
  height: 4px;
  border-radius: 2px;
  font-size: 10px;
  padding: 2px 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1024px) {
  .calendar-layout {
    grid-template-columns: 1fr;
  }

  .tasks-sidebar {
    order: 2;
  }

  .calendar-main {
    order: 1;
  }
}

@media (max-width: 768px) {
  body {
    padding: 24px 16px 60px;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  /* Sidebar responsive */
  .app-sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  
  .app-sidebar.open {
    transform: translateX(0);
  }
  
  .app-main {
    margin-left: 0;
  }

  .timer-buttons {
    width: 100%;
  }

  .timer-buttons button {
    flex: 1;
  }

  .calendar-month-grid {
    gap: 4px;
  }

  .calendar-day {
    min-height: 60px;
    padding: 4px;
  }

  .dashboard-layout {
    grid-template-columns: 1fr;
  }

  .dashboard-sidebar {
    margin-top: 24px;
  }
}

/* Dashboard Layout */
.dashboard-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
}

.dashboard-calendar {
  display: flex;
  flex-direction: column;
}

.dashboard-sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Reminders */
.reminders-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 400px;
  overflow-y: auto;
}

.reminder-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: rgba(31, 41, 51, 0.03);
  border-radius: var(--radius-small);
  border-left: 3px solid var(--color-primary);
  transition: background 0.18s ease;
}

.reminder-item:hover {
  background: rgba(31, 41, 51, 0.06);
}

.reminder-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.reminder-date {
  font-size: 12px;
  color: var(--color-muted);
  font-weight: 500;
}

.reminder-title {
  font-size: 14px;
  color: var(--color-text);
  font-weight: 500;
}

.reminder-location {
  font-size: 12px;
  color: var(--color-muted);
  margin-top: 2px;
}

.reminder-color {
  width: 4px;
  height: 100%;
  border-radius: 2px;
  flex-shrink: 0;
}

/* Exam Items */
.exams-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
}

.exam-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: rgba(31, 41, 51, 0.03);
  border-radius: var(--radius-small);
  border-left: 3px solid var(--color-primary);
  transition: background 0.18s ease;
  position: relative;
}

.exam-item:hover {
  background: rgba(31, 41, 51, 0.06);
}

.exam-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.exam-date {
  font-size: 12px;
  color: var(--color-muted);
  font-weight: 500;
}

.exam-title {
  font-size: 14px;
  color: var(--color-text);
  font-weight: 500;
}

.exam-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.exam-delete-btn {
  background: transparent;
  border: none;
  color: var(--color-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-small);
  transition: all 0.18s ease;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.exam-delete-btn:hover {
  background: rgba(255, 0, 0, 0.1);
  color: #ff4444;
}

.exam-color {
  width: 4px;
  height: 100%;
  border-radius: 2px;
  flex-shrink: 0;
}

/* Calendar Event Items - Google Calendar Style */
.calendar-event-item {
  display: flex;
  align-items: center;
  padding: 3px 6px;
  border-radius: 3px;
  border-left: 3px solid;
  font-size: 11px;
  line-height: 1.4;
  cursor: pointer;
  transition: opacity 0.18s ease, transform 0.18s ease;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-height: 18px;
  width: 100%;
  flex-shrink: 0;
}

.calendar-event-item:hover {
  opacity: 0.8;
  transform: translateX(2px);
}

.calendar-event-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-text);
  font-weight: 500;
}

.calendar-exam-item {
  border-left-color: #4A90E2;
}

.calendar-reminder-item {
  border-left-color: #4A90E2;
}

.calendar-task-item {
  border-left-color: #7ac7a5;
}

/* Event Popup */
.event-popup {
  background: var(--color-panel);
  border-radius: var(--radius-medium);
  box-shadow: var(--shadow-soft);
  padding: 16px;
  min-width: 250px;
  max-width: 350px;
  border: 1px solid rgba(74, 144, 226, 0.15);
}

.event-popup-content h4 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
}

.event-popup-content p {
  margin: 4px 0;
  font-size: 14px;
  color: var(--color-muted);
}

.event-location {
  font-size: 12px;
  color: var(--color-primary);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(74, 144, 226, 0.1);
}

/* Responsive Dashboard */
@media (max-width: 1024px) {
  .dashboard-layout {
    grid-template-columns: 1fr;
  }

  .dashboard-sidebar {
    margin-top: 24px;
  }
}

/* Study Session Info */
.study-session-details {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
}

.study-session-lesson,
.study-session-time,
.study-session-technique {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(31, 41, 51, 0.1);
}

.study-session-lesson:last-child,
.study-session-time:last-child,
.study-session-technique:last-child {
  border-bottom: none;
}

.study-session-lesson span:first-child,
.study-session-time span:first-child,
.study-session-technique span:first-child {
  font-weight: 500;
  color: var(--color-muted);
}

.study-session-lesson span:last-child,
.study-session-time span:last-child,
.study-session-technique span:last-child {
  font-weight: 600;
  color: var(--color-text);
}

/* Profile Forms */
.auth-form h3 {
  margin: 24px 0 16px;
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text);
}

.auth-form h3:first-child {
  margin-top: 0;
}


