﻿/* -------------------------------------------------
   Antigravity Theme - Deep Space / Advanced Tech
   ------------------------------------------------- */

/* Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Dynamic Palette */
  --bg-app: #09090b;
  /* Zinc 950 */
  --bg-panel: #18181b;
  /* Zinc 900 */
  --bg-element: #27272a;
  /* Zinc 800 */
  --bg-hover: #3f3f46;
  /* Zinc 700 */

  /* Updated Text Colors for 'Antigravity Blue-Grey' */
  --text-primary: #b0c4de;
  /* LightSteelBlue */
  --text-secondary: #778899;
  /* LightSlateGray */
  --text-tertiary: #546e7a;
  /* Blue Grey 600 */

  --accent-primary: #8b5cf6;
  /* Violet 500 */
  --accent-secondary: #6366f1;
  /* Indigo 500 */
  --accent-glow: rgba(139, 92, 246, 0.3);

  --border-subtle: #27272a;
  --border-highlight: #3f3f46;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --font-family: 'Inter', 'Noto Sans JP', sans-serif;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 1.5rem;
  overflow-y: scroll;
  /* Always show scrollbar to prevent layout shift */

  /* Antigravity Global Background (Black/Gray Shift) */
  background-image:
    radial-gradient(circle at 50% 0%, #09090b 0%, transparent 60%),
    radial-gradient(circle at 85% 30%, rgba(39, 39, 42, 0.2), transparent 40%),
    radial-gradient(circle at 15% 50%, rgba(24, 24, 27, 0.2), transparent 40%);
  background-attachment: fixed;
}

/* Layout */
.app-container {
  width: 100%;
  max-width: 1400px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-primary);
}

.logo i {
  color: var(--accent-primary);
  font-size: 1.25rem;
  filter: drop-shadow(0 0 8px var(--accent-glow));
}

.logo h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  background: linear-gradient(to right, #b0c4de, #778899);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.controls,
.view-switcher,
.actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Buttons (Base) */
button {
  font-family: inherit;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: var(--bg-element);
  color: var(--text-primary);
}

.text-btn {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 0.4rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
}

.text-btn:hover {
  background: var(--bg-element);
  border-color: var(--border-highlight);
}

/* View Switcher */
.view-switcher {
  background: var(--bg-element);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.view-switcher button {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.35rem 0.85rem;
  border-radius: calc(var(--radius-md) - 3px);
  font-size: 0.85rem;
  font-weight: 500;
}

.view-switcher button:hover {
  color: var(--text-primary);
}

.view-switcher button.active {
  background: var(--bg-hover);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

#current-date-display {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 140px;
  text-align: center;
}

/* Main Layout */
.main-content {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  /* Prevent stretching */
}

.calendar-view {
  flex: 1 1 65%;
  min-width: 0;
  /* Prevent overflow flex item */
}

/* Sidebar */
.sidebar {
  flex: 0 0 320px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 5.5rem;
}

.sidebar-section {
  background: var(--bg-panel);
  padding: 1rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.sidebar-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Task List in Sidebar */
.task-list {
  max-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.task-item {
  background: var(--bg-element);
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid transparent;
  cursor: grab;
  transition: all 0.2s;
}

.task-item:hover {
  border-color: var(--border-highlight);
  background: var(--bg-hover);
}

/* Calendar Grids */
.calendar-grid {
  display: grid;
  gap: 1px;
  background: var(--border-subtle);
  /* Borders via gap */
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.month-view .calendar-grid {
  grid-template-columns: repeat(7, minmax(0, 1fr));
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.calendar-cell {
  background: rgba(10, 10, 10, 0.6);
  /* Pure dark glass */
  min-height: 100px;
  padding: 0.5rem;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

/* Add grid lines visually if keeping same bg */
.calendar-cell {
  outline: 1px solid var(--border-subtle);
}

.calendar-cell:hover {
  background: var(--bg-element);
}

.date-number {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-tertiary);
  margin-bottom: 0.25rem;
  display: inline-block;
}

.calendar-cell.today .date-number {
  color: var(--accent-primary);
  font-weight: 700;
}

.calendar-cell.today {
  background: rgba(139, 92, 246, 0.05);
  /* Very subtle tint */
  box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.3);
  /* Subtle border */
}

.date-number.first-day {
  /* color: inherited (tertiary) */
  font-weight: 600;
  /* Slightly bolder */
  border-bottom: 2px solid var(--border-highlight);
}


.month-task-item {
  font-size: 0.65rem;
  color: var(--text-secondary);
  padding: 1px 0 1px 8px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
}

.month-task-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 3px;
  bottom: 3px;
  width: 3px;
  background-color: var(--task-color);
  border-radius: 1px;
  opacity: 0.8;
}

.month-task-item:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.month-task-item:hover::before {
  opacity: 1;
}

/* Chips & Tags */
.preset-chip {
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-secondary);
  font-weight: 400;
  /* Thinner look */
  border: 1px solid rgba(148, 163, 184, 0.15);
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
}

.preset-chip:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-highlight);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  /* Darker backdrop */
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  visibility: hidden;
  opacity: 0;
  transition: all 0.2s;
  z-index: 3000;
  /* Increased to be above mobile items */
}

.modal.show {
  visibility: visible;
  opacity: 1;
}

.modal-content {
  background: var(--bg-panel);
  border: 1px solid var(--border-highlight);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 500px;
  color: var(--text-primary);
  position: relative;
  max-height: 85vh;
  overflow-y: auto;
}

.close-modal {
  position: absolute;
  top: 1rem;
  right: 1rem;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.25rem;
  transition: color 0.2s;
}

.close-modal:hover {
  color: var(--text-primary);
}

.form-actions {
  display: flex !important;
  /* Force flex */
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-subtle);
}

.form-actions button {
  min-height: 48px;
  /* Larger touch target */
  min-width: 100px;
  font-size: 1rem;
  padding: 0 1.5rem;
  /* Fix text alignment */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

/* On mobile, ensure buttons are wide enough */
@media (max-width: 480px) {
  .form-actions button {
    flex: 1;
    /* Stretch buttons */
    padding: 0 0.5rem;
  }
}


/* Vertical View (Week/Day) & All Day Section */
.vertical-view {
  display: flex;
  flex-direction: column;
  height: 700px;
  background: rgba(5, 5, 5, 0.75);
  /* Darker Glassy Panel */
  backdrop-filter: blur(12px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}

.vertical-header {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
  padding-left: 0;
  padding-right: 10px;
  /* Compensate for scrollbar */
  background: rgba(255, 255, 255, 0.02);
  flex-shrink: 0;
}

.header-cell {
  flex: 1;
  text-align: center;
  padding: 0.75rem 0.25rem;
  border-left: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.header-cell.today {
  color: var(--accent-primary);
  background: rgba(139, 92, 246, 0.1);
  /* Very subtle tint */
}

/* All Day Section */
.all-day-row {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
  height: 100px;
  /* Fixed height for scroll box */
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.01);
  padding-right: 10px;
}

.all-day-label {
  width: 60px;
  border-right: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--text-tertiary);
  writing-mode: vertical-rl;
  text-orientation: mixed;
  padding: 4px;
  flex-shrink: 0;
  position: sticky;
  left: 0;
  top: 0;
  z-index: 5;
  background: var(--bg-panel);
  /* Sticky needs opaque bg */
}

.all-day-grid {
  flex: 1;
  display: flex;
  overflow-y: visible;
  /* Let parent scroll */
  background: transparent;
}

.day-view .all-day-grid {
  background: none;
}

.all-day-cell {
  flex: 1;
  min-width: 0;
  /* Important for flex child */
  border-left: 1px solid var(--border-subtle);
  padding: 2px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.day-view .all-day-cell {
  border-left: none;
}

.all-day-task-item {
  font-size: 0.6rem;
  color: var(--text-secondary);
  /* Added for consistency */
  padding: 1px 4px;
  background: var(--bg-element);
  border-radius: 2px;
  border-left: 3px solid var(--accent-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  margin-bottom: 1px;
  flex-shrink: 0;
}

.vertical-body {
  display: flex;
  flex: 1;
  overflow-y: scroll;
  position: relative;
  padding-top: 10px;
  /* fix 0:00 cutoff */
  padding-right: 0;
  scrollbar-gutter: stable;
}

.time-labels {
  width: 60px;
  flex-shrink: 0;
  background: transparent;
  border-right: 1px solid var(--border-subtle);
  min-height: 1440px;
  /* Ensure full height for border */
}

.time-label {
  height: 60px;
  text-align: right;
  padding-right: 10px;
  color: var(--text-tertiary);
  font-size: 0.75rem;
  position: relative;
  top: -10px;
  /* 0:00 aligns with top padding */
}

.days-grid {
  display: flex;
  flex: 1;
  position: relative;
  min-height: 1440px;
  /* Ensure full height */
  /* Background lines removed, using hour-cell border */
}

.day-column {
  flex: 1;
  border-left: 1px solid var(--border-subtle);
  position: relative;
  min-height: 1440px;
  /* Ensure border draws fully */
}

/* Current Time Line */
.current-time-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background-color: #ef4444;
  z-index: 50;
  pointer-events: none;
}

.current-time-line::before {
  content: '';
  position: absolute;
  left: -4px;
  top: -3.5px;
  width: 7px;
  height: 7px;
  background-color: #ef4444;
  border-radius: 50%;
}

.hour-cell {
  height: 60px;
  border-top: 1px dotted rgba(255, 255, 255, 0.15);
  /* Dotted line */
  box-sizing: border-box;
}

/* Ensure day-column is last before drag-over to match structure */

.day-column.drag-over {
  background: rgba(139, 92, 246, 0.1);
}

/* Events/Tasks in Calendar */
.calendar-task {
  position: absolute;
  left: 2px;
  right: 2px;
  background: var(--bg-element);
  /* Fallback */
  border-left: 3px solid var(--accent-primary);
  border-radius: 4px;
  padding: 2px 4px;
  font-size: 0.6rem;
  color: var(--text-secondary);
  overflow: hidden;
  cursor: pointer;
  z-index: 10;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.1s, box-shadow 0.1s;
}

.calendar-task:hover {
  z-index: 20;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
  filter: brightness(1.1);
}

.month-view .calendar-task {
  position: static;
  /* Stack naturally in month view */
  margin-bottom: 2px;
  background: transparent;
  border: none;
  border-left: 3px solid;
  /* Color driven by JS style */
  padding: 1px 4px;
}

.month-view .calendar-task:hover {
  background: var(--bg-hover);
}

/* Primary Buttons */
.primary-btn {
  background: var(--accent-primary);
  color: #fff;
  border: none;
  font-weight: 500;
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.2);
  /* Soft glow */
}

.primary-btn:hover {
  background: var(--accent-secondary);
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}

.danger-btn {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.danger-btn:hover {
  background: rgba(239, 68, 68, 0.25);
}

/* Tag Settings */
.tag-settings-list {
  background: var(--bg-element);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  max-height: 200px;
}

/* Sticky Columns for Horizontal Scroll (Mobile Week View) */
.vertical-header>div:first-child,
.all-day-label,
.time-labels {
  position: sticky;
  left: 0;
  z-index: 20;
  background: var(--bg-main);
  border-right: 1px solid var(--border-subtle);
}