/* Import variables first */
@import url("./base/variables.css");
/* Layout */
@import url("./base/layout.css");
/* Mobile Responsive */
@import url("./base/mobile.css");
/* Mobile Utilities */
@import url("./base/utilities-mobile.css");
/* Component modules */
@import url("./components/buttons.css");
@import url("./components/cards.css");
@import url("./components/forms.css");
@import url("./components/sidebar.css");
@import url("./components/search.css");
@import url("./components/mobile-menu.css");
@import url("./components/desktop-sidebar.css");
@import url("./components/header-tabs.css");
@import url("./components/loading.css");
@import url("./components/toast.css");
/* Feature modules */
@import url("./pages/settings.css");
@import url("./pages/dashboard.css");
@import url("./pages/assignments.css");
@import url("./pages/exams.css");
@import url("./pages/attendance.css");
@import url("./pages/notes.css");

/* Reset CSS cơ bản */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box; /* FIX ISSUE 1: Ensure all elements use border-box */
}

/* FIX ISSUE 1: Prevent horizontal overflow on mobile */
html,
body {
  width: 100%;
  overflow-x: hidden; /* Prevent horizontal scroll */
}

body {
  font-family: var(--font-family);
  background-color: var(--color-background);
  color: var(--color-text-dark);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  font-weight: var(--font-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- MAIN CONTENT --- */
/* Centered content container - like header tabs */
main {
  padding: var(--space-4);
  animation: fadeIn var(--transition-normal) ease-out;
}

/* Main content is just a wrapper, no special centering here */
.main-content {
  width: 100%;
}

/* --- COURSES HEADER (OPTIMIZED) --- */
.courses-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px; /* OPTIMIZED: Reduced from 16px */
  margin-bottom: 16px; /* OPTIMIZED: Reduced from 20px */
}

.courses-header h3 {
  margin: 0;
  font-size: 1.125rem; /* OPTIMIZED: Compact header */
}

/* OPTIMIZED: Compact actions layout */
.courses-actions {
  display: flex;
  align-items: center;
  gap: 8px; /* OPTIMIZED: Reduced from 12px */
  flex-wrap: wrap;
}

.courses-actions .search-bar-container {
  margin: 0;
}

.courses-actions .search-input {
  min-width: 200px; /* OPTIMIZED: Reduced from 250px */
  max-width: 250px; /* OPTIMIZED: Prevent excessive width */
}

/* Dashboard Week Navigation */
.dashboard-week-nav {
  margin-bottom: 20px;
}

/* --- VIEW TRANSITION STYLES (RIPPLE EFFECT) --- */
@keyframes ripple-effect {
  from {
    clip-path: circle(0% at var(--x) var(--y));
  }
  to {
    clip-path: circle(150% at var(--x) var(--y));
  }
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.5s;
  animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  animation-fill-mode: forwards;
}

/* Animate the NEW view */
::view-transition-new(root) {
  animation-name: ripple-effect;
}

/* Scrollbar đẹp hơn cho Webkit */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--color-background);
  border-radius: var(--border-radius-default);
}
::-webkit-scrollbar-thumb {
  background: var(--color-text-gray);
  border-radius: var(--border-radius-default);
  will-change: background;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-dark);
}

/* --- PAGE TRANSITION ANIMATIONS --- */
@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Timetable centered animation */
.timetable-container {
  animation: slideInUp 0.4s ease-out;
}

/* Tab content - just shows/hides, no special styling */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Reduce motion cho users có nhu cầu */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .course-card::before {
    display: none;
  }

  .pulse,
  .todayGlow,
  .badgePulse,
  .ripple-effect,
  .slideDown {
    animation: none !important;
  }
}

/* HEADER (Minimalist) */
.app-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-3) var(--space-4);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

/* Desktop header layout with centered tabs */
.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0;
  gap: 16px;
}

/* Desktop: 3-column layout - Actions | Tabs | App Name */
@media (min-width: 769px) {
  .header-top {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 20px;
  }
}

.sidebar-toggle {
  display: none;
}

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

/* Header Logo / App Name - Show on both desktop (right side) and mobile (center) */
.header-logo {
  display: flex;
  align-items: center;
}

/* Desktop: App name on the right */
@media (min-width: 769px) {
  .header-logo {
    justify-content: flex-end;
  }

  .header-logo h1 {
    font-size: 0.95rem;
    color: var(--color-text-secondary);
    font-weight: 600;
  }
}

/* Mobile: Show header title centered */
@media (max-width: 768px) {
  .header-logo {
    display: flex;
    flex: 1;
    justify-content: center;
  }
}

/* OPTIMIZED: Compact header title */
.header-logo h1 {
  font-size: var(--text-xl);
  color: var(--color-text-dark);
  font-weight: var(--font-bold);
  margin: 0;
  line-height: var(--leading-tight);
  text-align: left;
  white-space: nowrap;
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  background: var(--color-background);
  color: var(--color-text-dark);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xl);
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-xs);
}

.btn-icon:hover {
  background: var(--color-hover);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

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

.btn-icon:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.icon-theme {
  display: inline-block;
}

/* OLD Week Navigation - Hidden, replaced by week-slider */
.week-navigation {
  display: none; /* Hidden - replaced by week-slider */
}

.nav-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-background);
  color: var(--color-text-dark);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-xs);
}

.nav-btn:hover {
  background: var(--color-hover);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

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

.nav-btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

/* Week select dropdown - Hidden, replaced by week-slider */
.week-select {
  display: none; /* Hidden - replaced by week-slider */
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-background);
  color: var(--color-text-dark);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  min-width: 200px;
  transition: border-color 0.2s ease;
}

.week-select:hover {
  border-color: var(--color-primary);
}

.week-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: var(--shadow-focus);
}

/* Tab Content */
.tab-content {
  display: none;
  animation: fadeIn 0.3s ease;
  width: 100%;
  max-width: 100%;
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* BANNER NGÀY NGHỈ (Dòng chữ đỏ bên dưới timeline) */
.holiday-note {
  text-align: center;
  font-size: 0.9rem;
  color: #ffffff;
  background: #ef4444;
  margin: 12px auto 0 auto;
  max-width: 1400px;
  padding: 10px 20px;
  border-radius: var(--border-radius-default);
  font-weight: 600;
  box-shadow: var(--shadow-md);
  display: none;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* KHU VỰC GHI CHÚ & MÔN TỰ DO (Bên dưới Grid) */
.notes-container {
  margin-top: 30px;
  padding: 25px;
  background: var(--color-surface);
  border-radius: var(--border-radius-card);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-border);
  position: relative;
  overflow: hidden;
}

.notes-container::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--color-primary);
}

.notes-container h3 {
  color: var(--color-text-dark);
  margin-bottom: 20px;
  padding-bottom: 12px;
  font-size: 1.3rem;
  font-weight: 700;
  border-bottom: 2px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.note-card {
  background: #fef3c7;
  color: var(--color-text-dark);
  padding: 18px;
  border-radius: var(--border-radius-default);
  border-left: 5px solid #f59e0b;
  cursor: pointer;
  transition: var(--transition-normal);
  position: relative;
  box-shadow: var(--shadow-md);
}

.note-card::after {
  content: "✎";
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 1rem;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.note-card:hover::after {
  opacity: 0.6;
}

.note-card:hover {
  transform: translateY(-4px) rotate(-0.5deg);
  box-shadow: var(--shadow-md);
}

.note-card h4 {
  margin-bottom: 10px;
  color: var(--color-text-dark);
  font-size: 1.05rem;
  font-weight: 700;
}

.note-card p {
  font-size: 0.9rem;
  color: #92400e;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
/* OPTIMIZED: Compact course list section */
.course-list-section {
  margin-top: 20px; /* OPTIMIZED: Reduced from 30px */
  background: var(--color-surface);
  padding: 16px; /* OPTIMIZED: Reduced from 25px */
  border-radius: var(--border-radius-card);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-border);
  position: relative;
  overflow: hidden;
}

.course-list-section::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--color-success);
}

.course-list-section h3 {
  color: var(--color-text-dark);
  font-size: 1.3rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* OPTIMIZED: Compact search input */
#search-input {
  padding: 10px 14px; /* OPTIMIZED: Reduced from 12px 16px */
  border: 2px solid var(--color-border);
  border-radius: var(--border-radius-default);
  width: 100%; /* OPTIMIZED: Responsive width */
  max-width: 280px; /* OPTIMIZED: Reduced from fixed 320px */
  font-size: 0.875rem; /* OPTIMIZED: Reduced from 0.95rem */
  transition: var(--transition-normal);
  background: var(--color-surface);
  color: var(--color-text-dark);
}

#search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px var(--color-primary-soft);
}

#search-input::placeholder {
  color: var(--color-text-gray);
}

/* Bảng */
.table-wrapper {
  overflow-x: auto;
  margin-top: 20px;
}

.course-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 750px;
}

.course-table th,
.course-table td {
  padding: 16px 15px;
  border-bottom: 1px solid var(--color-border);
  text-align: center;
  font-size: 0.9rem;
}

.course-table th {
  background: var(--color-primary);
  color: #ffffff;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.8px;
  position: sticky;
  top: 0;
}

.course-table thead th:first-child {
  border-top-left-radius: var(--border-radius-default);
}
.course-table thead th:last-child {
  border-top-right-radius: var(--border-radius-default);
}
.course-table tbody tr:last-child td:first-child {
  border-bottom-left-radius: var(--border-radius-default);
}
.course-table tbody tr:last-child td:last-child {
  border-bottom-right-radius: var(--border-radius-default);
}

.course-table tbody tr {
  transition: var(--transition-fast);
}

.course-table tr:nth-child(even) {
  background-color: rgba(59, 130, 246, 0.03);
}

.course-table tr:hover {
  background: var(--color-hover);
  cursor: pointer;
}

/* Style cho cột Môn học */
.course-table td.col-name {
  text-align: left;
  font-weight: 600;
  color: var(--color-text-dark);
  max-width: 200px;
}

/* Nút hành động nhỏ trong bảng */
.action-btn {
  border: none;
  padding: 8px 14px;
  border-radius: var(--border-radius-button);
  cursor: pointer;
  font-size: 0.85rem;
  transition: var(--transition-fast);
  margin: 0 3px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.action-btn:hover {
  transform: translateY(-2px) scale(1.05);
}

.btn-edit-row {
  background: #fbbf24;
  color: #78350f;
  box-shadow: var(--shadow-sm);
}

.btn-edit-row:hover {
  background: #f59e0b;
  box-shadow: var(--shadow-md);
}

.btn-delete-row {
  background: #ef4444;
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.btn-delete-row:hover {
  background: #dc2626;
  box-shadow: var(--shadow-md);
}

/* Responsive adjustments for main layout (can be moved to layout.css) */

/* OPTIMIZED: Tablet - Ensure courses header fits */
@media (max-width: 1024px) {
  main {
    padding: 14px; /* OPTIMIZED: Reduced from 15px */
  }
  .header-top h1 {
    font-size: 1.375rem; /* OPTIMIZED: Reduced from 1.5rem */
  }

  /* OPTIMIZED: Courses actions for tablet */
  .courses-header {
    gap: 10px;
  }

  .courses-actions {
    gap: 8px;
  }

  .courses-actions .search-input {
    min-width: 180px;
    max-width: 220px;
  }

  #search-input {
    width: 100%;
    max-width: 220px; /* OPTIMIZED: Reduced from 250px */
  }
}

/* Mobile */
@media (max-width: 768px) {
  main {
    padding: 10px;
    padding-bottom: 100px;
  }

  /* Header */
  .app-header {
    padding: 15px;
  }

  .header-top {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .header-top h1 {
    font-size: 1.3rem;
    justify-content: center;
  }

  .action-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    width: 100%;
  }

  .action-buttons .btn-secondary,
  .action-buttons .btn-primary {
    padding: 10px 8px;
    font-size: 0.75rem;
    justify-content: center;
    margin: 0;
  }

  /* Timeline */
  .week-navigation {
    padding: 8px 10px;
    gap: 8px;
  }

  /* Holiday Banner */
  .holiday-note {
    margin: 10px;
    padding: 8px 15px;
    font-size: 0.8rem;
  }

  /* OPTIMIZED: Sections - Compact */
  .notes-container,
  .course-list-section {
    padding: 12px; /* OPTIMIZED: Reduced from 15px */
    margin-top: 16px; /* OPTIMIZED: Reduced from 20px */
  }

  .notes-container h3,
  .course-list-section h3 {
    font-size: 1rem; /* OPTIMIZED: Reduced from 1.1rem */
  }

  .notes-grid {
    grid-template-columns: 1fr;
    gap: 10px; /* OPTIMIZED: Reduced from 12px */
  }

  .note-card {
    padding: 12px; /* OPTIMIZED: Reduced from 14px */
  }

  /* OPTIMIZED: Courses header responsive */
  .courses-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px; /* Compact spacing */
  }

  .courses-actions {
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }

  .courses-actions .search-bar-container {
    width: 100%;
  }

  .courses-actions .search-input {
    width: 100%;
    max-width: 100%;
    min-width: auto;
  }

  .courses-actions .btn-primary {
    width: 100%; /* Full width button for easy tap */
  }

  /* Course List Section Header */
  .course-list-section > div:first-child {
    flex-direction: column;
    gap: 10px; /* OPTIMIZED: Reduced from 12px */
  }

  #search-input {
    width: 100%;
  }

  /* Table */
  .table-wrapper {
    margin-top: 15px;
  }

  .course-table {
    min-width: 600px;
  }

  .course-table th,
  .course-table td {
    padding: 10px 8px;
    font-size: 0.8rem;
  }

  .action-btn {
    padding: 6px 10px;
    font-size: 0.75rem;
  }
}

/* Small Mobile */
@media (max-width: 480px) {
  .header-top h1 {
    font-size: 1.15rem;
  }

  .action-buttons {
    grid-template-columns: repeat(2, 1fr);
  }

  .action-buttons .btn-primary {
    grid-column: 1 / -1;
  }

  .notes-container h3,
  .course-list-section h3 {
    font-size: 1rem;
  }

  .note-card h4 {
    font-size: 0.95rem;
  }

  .note-card p {
    font-size: 0.8rem;
  }

  /* Disable complex animations trên mobile */
  .course-card {
    background: #fff;
    color: var(--color-text-dark);
    border: 1px solid var(--color-primary);
    border-radius: 4px;
    transition:
      border-color 0.2s ease-out,
      opacity 0.2s ease-out,
      transform 0.2s ease-out;
  }

  .course-card:hover {
    border-color: var(--color-primary-dark);
    background: #fff;
    box-shadow: var(--shadow-md);
  }

  .note-card {
    transition:
      transform 0.15s ease,
      box-shadow 0.15s ease;
  }

  .note-card:hover {
    transform: translateY(-2px);
  }

  /* Disable hover glow effects */
  .btn-primary:hover {
    box-shadow: var(--shadow-md);
  }

  /* Giảm blur effect */
  .sidebar-overlay {
    backdrop-filter: none;
  }
}

/* Smooth scroll behavior */
html {
  scroll-behavior: smooth;
}

/* Optimize for mobile touch */
* {
  -webkit-tap-highlight-color: transparent;
}
