/* Glassmorphism Design System - V2 */

@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css");

:root {
  /* 1. Color Palette (Indigo & Amber) */
  --primary: #6366f1;
  /* Indigo 500 */
  --primary-hover: #4f46e5;
  --primary-light: #e0e7ff;
  --accent: #f59e0b;
  /* Amber 500 */
  --accent-hover: #d97706;
  --accent-light: #fef3c7;
  --star-empty: #e2e8f0;

  /* 2. Backgrounds & Text */
  --bg-main: #f8fafc;
  /* Slate 50 */
  --text-main: #1e293b;
  /* Slate 800 */
  --text-sub: #64748b;
  /* Slate 500 */
  --border: rgba(203, 213, 225, 0.6);
  --error: #ef4444;
  --success: #22c55e;

  /* 3. Glassmorphism Tokens */
  --glass-bg: rgba(255, 255, 255, 0.75);
  --glass-border: 1px solid rgba(255, 255, 255, 0.6);
  --glass-shadow: 0 8px 32px rgba(31, 38, 135, 0.07);
  --glass-shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.05);

  /* 4. Layout & Spacing */
  --radius: 20px;
  --radius-sm: 14px;
  --header-height: 64px;

  /* 5. Component Specific (Calendar) */
  --cal-bg: rgba(255, 255, 255, 0.4);
  --cal-header-bg: rgba(255, 255, 255, 0.5);
  --cal-cell-bg: rgba(255, 255, 255, 0.6);
  --cal-cell-border: rgba(255, 255, 255, 0.8);
  --cal-today-bg: #ffffff;
  --cal-item-bg: #ffffff;

  /* 6. Form & Overlay Tokens */
  --input-bg: rgba(255, 255, 255, 0.6);
  --input-border: rgba(203, 213, 225, 0.8);
  --drawer-bg: rgba(255, 255, 255, 0.95);
  --btn-outline-bg: #ffffff;
  --input-focus-bg: #ffffff;
  --panel-bg: rgba(0, 0, 0, 0.03);
  --track-bg: rgba(0, 0, 0, 0.05);
  --segment-bg: rgba(0, 0, 0, 0.05);
}

/* Dark Mode Overrides */
body.dark-mode {
  --bg-main: #0f172a;
  --text-main: #f1f5f9;
  --text-sub: #94a3b8;
  --border: rgba(51, 65, 85, 0.6);

  --glass-bg: rgba(30, 41, 59, 0.7);
  --glass-border: 1px solid rgba(255, 255, 255, 0.1);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  --glass-shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.3);

  --primary-light: rgba(99, 102, 241, 0.2);

  /* Dark Mode Calendar */
  --cal-bg: rgba(30, 41, 59, 0.4);
  --cal-header-bg: rgba(255, 255, 255, 0.05);
  --cal-cell-bg: rgba(30, 41, 59, 0.6);
  --cal-cell-border: rgba(255, 255, 255, 0.1);
  --cal-today-bg: #1e293b;
  --cal-item-bg: #334155;

  /* Dark Mode Table */
  --table-hover: rgba(51, 65, 85, 0.4);
  --table-border: #334155;
  --table-stripe: rgba(30, 41, 59, 0.5);
  --table-text: #e2e8f0;
  --table-header: #94a3b8;

  /* Dark Mode Form & Overlay */
  --input-bg: rgba(30, 41, 59, 0.6);
  --input-border: rgba(255, 255, 255, 0.1);
  --drawer-bg: rgba(15, 23, 42, 0.95);
  --btn-outline-bg: rgba(30, 41, 59, 0.8);
  --input-focus-bg: rgba(30, 41, 59, 1);
  --panel-bg: rgba(255, 255, 255, 0.05);

  --table-header-bg: rgba(255, 255, 255, 0.05);
  --accent-light: rgba(245, 158, 11, 0.2);
  --scrollbar-thumb: rgba(255, 255, 255, 0.2);
  --scrollbar-thumb: rgba(255, 255, 255, 0.2);
  --scrollbar-thumb-hover: rgba(255, 255, 255, 0.3);

  --track-bg: rgba(255, 255, 255, 0.1);
  --segment-bg: rgba(255, 255, 255, 0.1);
  --star-empty: rgba(255, 255, 255, 0.2);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 20px;
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background:
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(245, 158, 11, 0.1) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(99, 102, 241, 0.05) 0px, transparent 50%),
    var(--bg-main);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.3s, color 0.3s;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

/* Base UI Components */
button {
  font-family: inherit;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 12px;
  border: none;
  font-weight: 500;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.2);
}

.btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn.outline {
  background: var(--btn-outline-bg);
  border: 1px solid var(--border);
  color: var(--text-main);
  box-shadow: var(--glass-shadow-sm);
}

.btn.outline:hover {
  background: #f1f5f9;
  border-color: var(--text-sub);
}

.btn.danger {
  background: var(--error);
}

.btn.danger:hover {
  background: #dc2626;
}

/* Progress Dashboard Widget */
.dashboard-container {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  flex: 1;
  background: var(--glass-bg);
  border: var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--glass-shadow-sm);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.stat-info .label {
  font-size: 11px;
  color: var(--text-sub);
  display: block;
}

.stat-info .value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
}

.progress-bar-container {
  flex: 2;
  background: var(--glass-bg);
  border: var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 16px;
  box-shadow: var(--glass-shadow-sm);
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 600;
}

.progress-track {
  height: 10px;
  background: var(--track-bg);
  border-radius: 5px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  width: 0%;
  transition: width 1s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Structures */
.container {
  max-width: 1400px;
  margin: 0 auto;
}

.card {
  background: var(--glass-bg);
  border: var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(8px);
  padding: 24px;
  margin-bottom: 24px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.card-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
}

/* Form Elements */
input,
select,
textarea {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  padding: 10px 14px;
  border-radius: 12px;
  transition: all 0.2s ease;
  font-size: 14px;
  width: 100%;
  color: var(--text-main);
}

input:focus,
select:focus,
textarea:focus {
  background: var(--input-focus-bg);
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
  outline: none;
}

/* Utilities */
.hidden {
  display: none !important;
}

.flex {
  display: flex;
}

.gap-2 {
  gap: 8px;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

/* Tab Navigation */
.tab-nav {
  display: flex;
  gap: 8px;
  padding-bottom: 1px;
}

.tab {
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-sub);
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
  position: relative;
}

.tab:hover {
  background: var(--panel-bg);
  color: var(--text-main);
}

.tab.active {
  color: var(--primary);
}

.tab.active::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 6px;
  right: 6px;
  height: 2px;
  background: var(--primary);
  border-radius: 2px;
}

/* Toast */
#toast-container {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  pointer-events: auto;
  background: rgba(15, 23, 42, 0.9);
  color: white;
  padding: 10px 16px;
  border-radius: 20px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Drawer & Datail Modal */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(8px);
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: 0.3s;
}

.drawer-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  right: -700px;
  width: 100%;
  max-width: 650px;
  height: 100vh;
  background: var(--drawer-bg);
  backdrop-filter: blur(16px);
  z-index: 2001;
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.15);
  transition: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  pointer-events: none;
}

/* V3: Focus Mode (Expanded) */
.drawer.editor-expanded {
  max-width: 900px;
  /* Wider */
  background: var(--panel-bg);
  /* Slightly distinct background if needed */
}

.drawer.editor-expanded #fields-task>div:not(:has(#edit-body)),
.drawer.editor-expanded #fields-ann>div:not(:has(#edit-body)) {
  /* Hide other fields in focus mode, or maybe just dim them? 
       Prompt said "focus mode", expanding on click. 
       Let's making the body area huge. 
    */
  display: none;
}

.drawer.editor-expanded #edit-body {
  height: 60vh !important;
  /* Make textarea huge */
  font-size: 16px;
  line-height: 1.6;
}



.drawer.open {
  right: 0;
  pointer-events: auto;
}

/* Centered Mode (like a popup but inside) */
.drawer.centered {
  right: 50% !important;
  margin-right: -400px;
  max-width: 800px;
  border-radius: 20px;
  height: 85vh;
  top: 7.5vh;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  transform: scale(0.95) translateY(20px);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.drawer.centered.open {
  right: 50% !important;
  margin-right: -400px;
  transform: scale(1) translateY(0);
  opacity: 1;
}

.drawer-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  font-size: 15px;
  line-height: 1.6;
}

.drawer-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.5);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Grid for Main Layout (Option D) - Page Scroll Version */
.main-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
  align-items: start;
  /* Don't stretch, let them follow content */
}

/* Sidebar: Sticky so it follows while scrolling right side */
.left-panel {
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
}

.left-panel .card {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 0;
}

/* Right Panel: Content grows naturally with page */
.right-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.right-panel .calendar-section,
.right-panel .tasks-section {
  flex-shrink: 0;
}

/* Tasks table horizontal scroll support */
.tasks-section {
  overflow-x: auto;
}

/* Premium Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb, rgba(0, 0, 0, 0.1));
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover, rgba(0, 0, 0, 0.2));
}

/* Task Table Custom Styles */
.task-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.task-table th {
  text-align: left;
  padding: 12px 8px;
  color: var(--text-sub);
  font-weight: 500;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  background: var(--table-header-bg, transparent);
  border-radius: 8px;
}

.task-table td {
  padding: 12px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  vertical-align: middle;
}

.task-table tr:hover td {
  background: var(--primary-light);
}

.task-table tbody tr {
  cursor: pointer;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: -0.01em;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.badge.private {
  background: #f3f4f6;
  color: #4b5563;
}

.badge.shared {
  background: #eff6ff;
  color: #3b82f6;
}

.badge.status-my-done {
  background: #ecfccb;
  color: #65a30d;
  border: 1px solid #bef264;
}

.badge.status-in-progress {
  background: #e0f2fe;
  color: #0284c7;
  border: 1px solid #bae6fd;
}

/* Blue for In Progress */
.badge.status-waiting {
  background: #fffbeb;
  color: #d97706;
  border: 1px solid #fde68a;
}

.badge.status-start {
  background: #f3f4f6;
  color: #6b7280;
  border: 1px solid #e5e7eb;
}

/* Gray for Not Started */

.status-tooltip {
  position: relative;
  cursor: help;
}

.status-tooltip:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 8px;
  border-radius: 6px;
  font-size: 11px;
  white-space: pre-line;
  z-index: 1000;
  min-width: 120px;
  pointer-events: none;
  line-height: 1.5;
}

.overdue-warning {
  color: var(--error);
  font-weight: 700;
  background: #fef2f2;
  border: 1px solid #fee2e2;
  padding: 2px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.overdue-warning:hover {
  background: #fee2e2;
}

/* Star Rating Animation */
.star-rating {
  font-size: 16px;
  color: #fbbf24;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: inline-block;
  user-select: none;
}

.star-rating:hover {
  transform: scale(1.4);
}

.star-rating.empty {
  color: var(--star-empty);
}

.star-rating.pulse {
  animation: starPulse 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes starPulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.6);
  }

  100% {
    transform: scale(1);
  }
}

/* Table Header Sorting */
.task-table th[onclick] {
  transition: background 0.2s;
}

.task-table th[onclick]:hover {
  background: var(--table-hover);
  color: var(--primary);
}

@media (max-width: 900px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
}