/* ==========================================================================
   NoClassTable (无课表周历计算器)
   Google Calendar Web Official Aesthetic (Material Design 3 / Google Workspace)
   Modeled closely after Google Calendar Web (calendar.google.com)
   Pure CSS & Local Assets - 100% Offline & Fast in Mainland China
   ========================================================================== */

:root {
  /* Google Calendar Palette */
  --g-blue: #1a73e8;
  --g-blue-hover: #1557b0;
  --g-blue-surface: #e8f0fe;
  --g-green: #188038;
  --g-green-hover: #137333;
  --g-green-surface: #e6f4ea;
  --g-red: #d93025;
  --g-coral: #e67c73;

  /* Google Calendar Neutral Grays */
  --g-text-primary: #3c4043;
  --g-text-secondary: #70757a;
  --g-text-subtle: #80868b;
  --g-line: #dadce0;
  --g-surface: #ffffff;
  --g-sidebar-bg: #ffffff;
  --g-hover: #f1f3f4;
  --g-selected: #e8f0fe;

  /* Material Design 3 Motion Tokens */
  --md-sys-motion-easing-standard: cubic-bezier(0.2, 0, 0, 1);
  --md-sys-motion-easing-emphasized: cubic-bezier(0.2, 0, 0, 1);
  --md-sys-motion-easing-decelerate: cubic-bezier(0, 0, 0.2, 1);
  --md-sys-motion-easing-accelerate: cubic-bezier(0.3, 0, 1, 1);
  --md-sys-motion-duration-short: 150ms;
  --md-sys-motion-duration-medium: 250ms;
  --md-sys-motion-duration-long: 350ms;

  /* Fonts */
  --g-font: Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

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

body {
  font-family: var(--g-font);
  background-color: var(--g-surface);
  color: var(--g-text-primary);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Base Icons */
.g-icon {
  display: inline-block;
  width: 20px;
  height: 20px;
  min-width: 20px;
  fill: currentColor;
  vertical-align: middle;
}

/* ==========================================================================
   1. Google Calendar Top App Bar
   ========================================================================== */
.g-app-bar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid var(--g-line);
  background: var(--g-surface);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 12px;
}

.g-bar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  white-space: nowrap;
}

.g-logo-group {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  margin-right: 8px;
  flex-shrink: 0;
  white-space: nowrap;
}

.g-calendar-icon-box {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #1a73e8;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  position: relative;
  box-shadow: none;
}

.g-calendar-icon-box .box-month {
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: -2px;
}

.g-calendar-icon-box .box-day {
  font-size: 17px;
  line-height: 1;
  font-weight: 700;
}

.g-app-title {
  font-size: 22px;
  font-weight: 400;
  color: #5f6368;
  letter-spacing: -0.01em;
}

/* Date Nav Controls */
.g-date-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 12px;
}

.g-btn-today {
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--g-line);
  border-radius: 8px;
  background: transparent;
  color: var(--g-text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: none;
  transition: background-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
              transform var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.g-btn-today:hover {
  background: var(--g-hover);
}

.g-btn-today:active {
  transform: scale(0.97);
  box-shadow: none;
}

.g-nav-arrows {
  display: flex;
  align-items: center;
  gap: 2px;
}

.g-arrow-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--g-text-secondary);
  cursor: pointer;
  transition: background-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
              transform var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.g-arrow-btn:hover {
  background: var(--g-hover);
}

.g-arrow-btn:active {
  transform: scale(0.92);
}

.g-current-title-label {
  font-size: 20px;
  font-weight: 400;
  color: var(--g-text-primary);
  margin-left: 8px;
  white-space: nowrap;
}

.g-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* View Switcher Dropdown (like "周" in Google Calendar) */
.g-view-switcher {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--g-line);
  border-radius: 8px;
  background: transparent;
  color: var(--g-text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  box-shadow: none;
  transition: background-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
              border-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.g-view-switcher:hover {
  background: var(--g-hover);
}

/* Google Action Buttons */
.g-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--g-line);
  border-radius: 8px;
  background: transparent;
  color: var(--g-text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: none;
  transition: background-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
              border-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
              transform var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.g-tool-btn:hover {
  background: var(--g-hover);
  box-shadow: none;
}

.g-tool-btn:active {
  transform: scale(0.97);
}

.g-tool-btn-primary {
  background: var(--g-blue);
  color: #ffffff;
  border-color: var(--g-blue);
  box-shadow: none;
}

.g-tool-btn-primary:hover {
  background: var(--g-blue-hover);
  border-color: var(--g-blue-hover);
  box-shadow: none;
}

.g-tool-btn-primary:active {
  transform: scale(0.97);
}

.g-icon-tool-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--g-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
              transform var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.g-icon-tool-btn:hover {
  background: var(--g-hover);
}

.g-icon-tool-btn:active {
  transform: scale(0.92);
}

/* ==========================================================================
   2. Main Container (Sidebar + Calendar Canvas)
   ========================================================================== */
.g-workspace-layout {
  display: flex;
  flex: 1;
  min-height: calc(100vh - 64px);
  position: relative;
}

/* Left Sidebar */
.g-sidebar {
  width: 256px;
  min-width: 256px;
  padding: 16px 12px;
  border-right: 1px solid var(--g-line);
  background: var(--g-sidebar-bg);
  display: flex;
  flex-direction: column;
  gap: 16px;
  user-select: none;
}

/* Google "+ 创建" Pill Button */
.g-create-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  height: 48px;
  padding: 0 20px 0 12px;
  border-radius: 24px;
  border: 1px solid var(--g-line);
  background: var(--g-surface);
  box-shadow: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--g-text-primary);
  cursor: pointer;
  transition: background-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
              border-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
              transform var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
  margin-bottom: 4px;
}

.g-create-btn:hover {
  box-shadow: none;
  background: var(--g-hover);
  border-color: #c4c7c5;
}

.g-create-btn:active {
  transform: scale(0.98);
  background: #e8eaed;
}

.g-create-plus-icon {
  width: 32px;
  height: 32px;
  background: #f1f3f4;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--g-blue);
}

/* Drag and Drop Fullscreen Overlay */
.drag-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: opacity var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.drag-overlay-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 36px 56px;
  background: #ffffff;
  border: 2px dashed var(--g-blue);
  border-radius: 16px;
  box-shadow: none;
  animation: overlayCardIn var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
}

@keyframes overlayCardIn {
  from {
    transform: scale(0.92);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.drag-overlay-icon {
  width: 48px;
  height: 48px;
  color: var(--g-blue);
}

.drag-overlay-text {
  font-size: 16px;
  font-weight: 500;
  color: var(--g-blue);
}

/* "我的日历 / 参与人员" Section (Exact Google Calendar Style) */
.g-sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--g-text-secondary);
}

.member-checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.member-checkbox-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.member-checkbox-item:hover {
  background: var(--g-hover);
}

.member-left {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

/* Custom Google Styled Colored Checkbox */
.g-check-box {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 2px solid #5f6368;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.member-checkbox-item.checked .g-check-box {
  background: #1a73e8;
  border-color: #1a73e8;
  color: #ffffff;
}

.member-checkbox-item.checked:nth-child(2n) .g-check-box {
  background: #0b8043;
  border-color: #0b8043;
}

.member-checkbox-item.checked:nth-child(3n) .g-check-box {
  background: #8e24aa;
  border-color: #8e24aa;
}

.member-checkbox-item.checked:nth-child(4n) .g-check-box {
  background: #d93025;
  border-color: #d93025;
}

.member-name-label {
  font-size: 13px;
  color: var(--g-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-checkbox-item.disabled .member-name-label {
  color: var(--g-text-subtle);
  text-decoration: line-through;
}

.member-del-icon {
  border: none;
  background: transparent;
  color: var(--g-text-subtle);
  opacity: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  border-radius: 50%;
  transition: opacity var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
              color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
              transform var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.member-checkbox-item:hover .member-del-icon {
  opacity: 1;
}

.member-del-icon:hover {
  color: var(--g-red);
  transform: scale(1.15);
}

/* ==========================================================================
   3. Main Calendar Week Grid (calendar.google.com Exact Styling)
   ========================================================================== */
.g-calendar-canvas {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--g-surface);
  overflow-x: auto;
}

/* Calendar Week Table */
.g-calendar-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  table-layout: fixed;
}

/* Top Header Row */
.g-calendar-table thead th {
  padding: 8px 4px 10px 4px;
  text-align: center;
  border-bottom: 1px solid var(--g-line);
  border-right: 1px solid var(--g-line);
  background: var(--g-surface);
  position: sticky;
  top: 0;
  z-index: 10;
  height: 78px;
  box-sizing: border-box;
}

.g-calendar-table thead th:last-child {
  border-right: none;
}

.g-time-corner-cell {
  width: 100px;
  min-width: 100px;
  font-size: 14px;
  font-weight: 500;
  color: var(--g-text-secondary);
  text-align: center;
  vertical-align: middle;
  padding: 8px !important;
  height: 78px;
  box-sizing: border-box;
}

.g-time-corner-cell.is-all-semester {
  vertical-align: middle;
  padding: 8px !important;
}

.day-header-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 60px;
  box-sizing: border-box;
}

.day-header-group.is-all-semester {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.day-header-weekday {
  font-size: 11px;
  font-weight: 500;
  color: var(--g-text-secondary);
  text-transform: uppercase;
}

.day-header-group.is-all-semester .day-header-weekday {
  font-size: 22px;
  font-weight: 400;
  color: var(--g-text-primary);
  text-transform: none;
  line-height: 1;
}

.day-header-number {
  font-size: 24px;
  font-weight: 400;
  color: var(--g-text-primary);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background-color 0.15s;
}

.day-header-group.is-today .day-header-weekday {
  color: var(--g-blue);
  font-weight: 700;
}

.day-header-group.is-today .day-header-number {
  background: var(--g-blue);
  color: #ffffff;
  font-weight: 500;
}

/* Left Time Column (Gutter) */
.g-time-gutter-cell {
  width: 100px;
  min-width: 100px;
  padding: 10px 8px;
  text-align: right;
  border-right: 1px solid var(--g-line);
  border-bottom: 1px solid var(--g-line);
  vertical-align: middle;
  background: var(--g-surface);
}

.time-period-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--g-text-primary);
}

.time-range-label {
  font-size: 11px;
  color: var(--g-text-secondary);
  font-family: monospace;
  margin-top: 2px;
}

/* Calendar Data Cell */
.g-cal-cell {
  height: 116px;
  min-height: 100px;
  padding: 4px;
  vertical-align: top;
  border-right: 1px solid var(--g-line);
  border-bottom: 1px solid var(--g-line);
  background: var(--g-surface);
  cursor: pointer;
  transition: background-color 0.12s;
}

.g-cal-cell:last-child {
  border-right: none;
}

.g-cal-cell:hover {
  background-color: #f8f9fa;
}

/* ==========================================================================
   4. Google Calendar Event Chips (Solid Color Blocks with Rounded Corners)
   ========================================================================== */
.g-event-chip {
  height: calc(100% - 4px);
  margin: 2px;
  border-radius: 8px;
  padding: 6px 8px;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  box-sizing: border-box;
  box-shadow: none;
  transition: transform var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
              filter var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.g-event-chip:hover {
  filter: brightness(0.94);
  transform: translateY(-1px);
}

.g-event-chip:active {
  transform: scale(0.98);
  filter: brightness(0.88);
}

/* Green Event Block: 全员无课 (Google Calendar Basil/Sage Green) */
.chip-all-free {
  background-color: #0b8043;
}

/* Blue Event Block: 部分无课 (Google Calendar Cobalt/Blue) */
.chip-partial-free {
  background-color: #039be5;
}

.event-chip-title {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  display: flex;
  align-items: center;
  gap: 4px;
}

.event-chip-meta {
  font-size: 11px;
  opacity: 0.92;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-chip-names {
  font-size: 11px;
  font-weight: 500;
  margin-top: 2px;
  line-height: 1.3;
  word-break: break-all;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Empty Cell */
.g-empty-slot {
  height: 100%;
}

/* ==========================================================================
   5. Google Calendar Detail Dialog / Popover
   ========================================================================== */
.g-dialog-scrim {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.36);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 16px;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard),
              visibility var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
}

.g-dialog-scrim.active {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.g-dialog-card {
  background: #ffffff;
  border-radius: 24px;
  border: 1px solid var(--g-line);
  box-shadow: none;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  transform: scale(0.92) translateY(12px);
  opacity: 0;
  transition: transform var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard),
              opacity var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
}

.g-dialog-scrim.active .g-dialog-card {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.g-dialog-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 24px 8px 24px;
}

.g-dialog-title {
  font-size: 18px;
  font-weight: 500;
  color: var(--g-text-primary);
}

.g-dialog-subtitle {
  font-size: 12px;
  color: var(--g-text-secondary);
  margin-top: 2px;
}

.g-dialog-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--g-text-secondary);
  cursor: pointer;
  transition: background-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.g-dialog-close:hover {
  background: var(--g-hover);
}

.g-dialog-body {
  padding: 12px 24px 24px 24px;
}

.g-dialog-section {
  margin-bottom: 16px;
}

.g-dialog-section-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--g-text-secondary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.g-free-names-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.g-free-pill {
  background: var(--g-green-surface);
  color: var(--g-green);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 8px;
}

.g-busy-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.g-busy-item {
  background: #e67c73;
  color: #ffffff;
  border-radius: 8px;
  padding: 8px 12px;
  box-shadow: none;
}

.g-busy-item .busy-student {
  font-size: 11px;
  color: #ffffff;
  opacity: 0.92;
  margin-bottom: 2px;
}

.g-busy-item .busy-course {
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
}

.g-busy-item .busy-meta {
  font-size: 11px;
  color: #ffffff;
  opacity: 0.92;
  margin-top: 2px;
}

.g-dialog-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--g-line);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Settings Form */
.g-settings-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.g-settings-row input, .g-input {
  height: 34px;
  border: 1px solid var(--g-line);
  border-radius: 8px;
  padding: 0 10px;
  font-size: 12px;
  outline: none;
  transition: border-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.g-settings-row input:focus, .g-input:focus {
  border-color: var(--g-blue);
}

/* Toast */
.g-toast-host {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 600;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.g-toast {
  background: #202124;
  color: #ffffff;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #333333;
  box-shadow: none;
  animation: toastSlideIn var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard) forwards;
}

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

.g-toast.is-hiding {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
              transform var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

/* Responsive */
@media (max-width: 900px) {
  .g-sidebar {
    display: none;
  }
}
