/* Grid view styles - isolated from main styles */

* {
  box-sizing: border-box;
}

:root {
  --bg-primary: #0c0c0d;
  --bg-secondary: #050506;
  --bg-tertiary: #1a1a1d;
  --bg-panel: rgba(0, 0, 0, 0.52);
  --bg-modal: #050507;
  --bg-input: rgba(5, 5, 7, 0.96);
  --text-primary: #f5f5f5;
  --text-secondary: rgba(245, 245, 245, 0.7);
  --accent: #a68f50;
  --accent-glow: rgba(166, 143, 80, 0.9);
  --accent-glow-strong: rgba(166, 143, 80, 1);
  --border-primary: rgba(166, 143, 80, 0.15);
  --border-secondary: rgba(166, 143, 80, 0.2);
  --border-accent: rgba(166, 143, 80, 0.9);
}

html[data-theme="white"],
html[data-theme=""] {
  --bg-primary: #0c0c0d;
  --bg-secondary: #050506;
  --bg-tertiary: #1a1a1d;
  --bg-panel: rgba(0, 0, 0, 0.52);
  --text-primary: #f5f5f5;
  --text-secondary: rgba(245, 245, 245, 0.7);
  --accent: #a68f50;
  --accent-glow: rgba(166, 143, 80, 0.9);
  --accent-glow-strong: rgba(166, 143, 80, 1);
  --border-primary: rgba(166, 143, 80, 0.15);
  --border-secondary: rgba(166, 143, 80, 0.2);
}

html[data-theme="white"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f8f8f8;
  --bg-tertiary: #f0f0f0;
  --bg-panel: rgba(255, 255, 255, 0.8);
  --bg-modal: #ffffff;
  --bg-input: #ffffff;
  --text-primary: #1a1a1a;
  --text-secondary: rgba(26, 26, 26, 0.7);
  --accent: #a68f50;
  --accent-glow: rgba(166, 143, 80, 0.6);
  --accent-glow-strong: rgba(166, 143, 80, 0.9);
  --border-primary: rgba(0, 0, 0, 0.1);
  --border-secondary: rgba(0, 0, 0, 0.15);
  --border-accent: rgba(166, 143, 80, 0.6);
}

html[data-theme="white"] .time-grid-cell-block {
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

html[data-theme="white"] .time-grid-cell-block:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15), 0 0 20px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.6) !important;
  border-color: rgba(0, 0, 0, 0.15);
}

html[data-theme="white"] .time-grid-cell-block-title {
  color: rgba(0, 0, 0, 0.9);
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.5);
}

html[data-theme="white"] .time-grid-cell-block-notes {
  color: rgba(0, 0, 0, 0.7);
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.3);
}

html[data-theme="gray"] {
  --bg-primary: #2a2a2a;
  --bg-secondary: #1f1f1f;
  --bg-tertiary: #333333;
  --bg-panel: rgba(42, 42, 42, 0.8);
  --bg-modal: #2a2a2a;
  --bg-input: rgba(42, 42, 42, 0.96);
  --text-primary: #e0e0e0;
  --text-secondary: rgba(224, 224, 224, 0.7);
  --accent: #888888;
  --accent-glow: rgba(136, 136, 136, 0.6);
  --accent-glow-strong: rgba(136, 136, 136, 0.9);
  --border-primary: rgba(255, 255, 255, 0.1);
  --border-secondary: rgba(255, 255, 255, 0.15);
  --border-accent: rgba(136, 136, 136, 0.6);
}

html[data-theme="gray"] .time-grid-cell-block {
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

html[data-theme="gray"] .time-grid-cell-block:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), 0 0 20px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
  border-color: rgba(255, 255, 255, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: "HalvarBreit", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg-panel);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

#grid-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  box-sizing: border-box;
}

.grid-header-wrapper {
  overflow-x: auto;
  overflow-y: hidden;
  flex-shrink: 0;
}

.grid-header-wrapper::-webkit-scrollbar {
  height: 8px;
}

.grid-header-wrapper::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
}

.grid-header-wrapper::-webkit-scrollbar-thumb {
  background: var(--accent-glow);
  border-radius: 4px;
}

.grid-header-wrapper::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

.grid-header {
  display: grid;
  grid-template-columns: 80px repeat(var(--grid-days-count, 34), var(--grid-column-width, 180px));
  padding: 6px 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-secondary);
  min-width: max-content;
}

.grid-header-cell {
  padding-left: 4px;
  border-right: 1px solid var(--border-primary);
  border-bottom: 1px solid var(--border-primary);
}

.grid-header-cell:first-child {
  padding-left: 0;
  position: sticky;
  left: 0;
  background: var(--bg-panel);
  backdrop-filter: blur(8px);
  z-index: 10;
  border-right: 1px solid var(--border-secondary);
}

.time-grid-wrapper {
  flex: 1;
  overflow-x: auto;
  overflow-y: auto;
  position: relative;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.time-grid-wrapper::-webkit-scrollbar {
  height: 8px;
  width: 0px;
}

.time-grid-wrapper::-webkit-scrollbar:vertical {
  width: 0px;
  display: none;
}

.time-grid-wrapper::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
}

.time-grid-wrapper::-webkit-scrollbar-thumb {
  background: var(--accent-glow);
  border-radius: 4px;
}

.time-grid-wrapper::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

.time-grid {
  padding: 4px 10px 10px;
  display: grid;
  grid-template-columns: 80px repeat(var(--grid-days-count, 34), var(--grid-column-width, 180px));
  grid-auto-rows: 48px;
  min-width: max-content;
  position: relative;
}

.time-grid-time {
  font-size: 14px;
  color: var(--text-secondary);
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding-right: 8px;
  position: sticky;
  left: 0;
  background: var(--bg-panel);
  backdrop-filter: blur(8px);
  z-index: 10;
  padding-left: 10px;
  margin-left: -10px;
  border-right: 1px solid var(--border-secondary);
  font-weight: 500;
}

.time-grid-cell {
  border-top: 1px solid var(--border-primary);
  border-right: 1px solid var(--border-primary);
  cursor: pointer;
  position: relative;
}

.time-grid-cell-last-col {
  border-right: 1px solid var(--border-primary);
}

.time-grid-cell-last-row {
  border-bottom: 1px solid var(--border-primary);
}

.time-grid-cell-selected {
  border: 2px solid var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
  z-index: 20;
  position: relative;
}

.time-grid-cell-block-selected {
  border: 2px solid var(--accent) !important;
  box-shadow: 0 0 12px var(--accent-glow) !important;
  z-index: 20;
  position: relative;
}

.cell-handle {
  position: absolute;
  background: var(--accent);
  border: 2px solid var(--bg-secondary);
  border-radius: 50%;
  width: 12px;
  height: 12px;
  cursor: ns-resize;
  z-index: 25;
  box-shadow: 0 0 8px var(--accent-glow);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  pointer-events: auto;
}

.cell-handle:hover {
  transform: scale(1.3);
  box-shadow: 0 0 12px var(--accent-glow-strong);
}

.cell-handle-top {
  cursor: ns-resize;
}

.cell-handle-bottom {
  cursor: ns-resize;
}

.cell-handle-left {
  cursor: ew-resize;
}

.cell-handle-right {
  cursor: ew-resize;
}

.time-grid-cell-block {
  position: relative;
  margin: 2px 3px;
  border-radius: 8px;
  cursor: pointer;
  z-index: 15;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  padding: 6px 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.time-grid-cell-block:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25), 0 0 20px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.15) !important;
  border-color: rgba(255, 255, 255, 0.2);
}

.time-grid-task-block {
  cursor: move !important;
  border: 1px solid rgba(166, 143, 80, 0.3);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25), 0 0 8px rgba(166, 143, 80, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  animation: taskBlockAppear 0.3s ease-out;
  will-change: transform, opacity;
}

.time-grid-task-block:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3), 0 0 16px rgba(166, 143, 80, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.15) !important;
  border-color: rgba(166, 143, 80, 0.5);
}

.time-grid-task-block:active {
  cursor: grabbing !important;
}

@keyframes taskBlockAppear {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.time-grid-cell-block-title {
  font-weight: 600;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.95);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 3px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  letter-spacing: 0.02em;
}

.time-grid-cell-block-notes {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.75);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.4;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}

.time-grid-cell:first-child {
  position: sticky;
  left: 0;
  background: var(--bg-panel);
  backdrop-filter: blur(8px);
  z-index: 5;
  border-right: 1px solid var(--border-secondary);
}

.time-grid-cell:nth-child(odd) {
  background: var(--bg-tertiary);
}

.time-grid-task {
  position: relative;
  margin: 2px 3px;
  padding: 3px 6px;
  border-radius: 6px;
  font-size: 11px;
  line-height: 1.3;
  color: var(--bg-secondary);
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
  overflow: hidden;
  cursor: pointer;
}

.time-grid-task-title {
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.time-grid-task-meta {
  font-size: 10px;
  opacity: 0.9;
  margin-top: 2px;
}

.selection-menu {
  background: var(--bg-modal);
  border: 1px solid var(--border-primary);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  padding: 4px;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.selection-menu-item {
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease;
  font-family: "HalvarBreit", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.selection-menu-item:hover {
  background: var(--bg-tertiary);
}

.selection-menu-item-cancel {
  color: var(--text-secondary);
  margin-top: 4px;
  border-top: 1px solid var(--border-primary);
  padding-top: 8px;
}

.cell-action-buttons {
  position: absolute;
  top: -32px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  z-index: 30;
  background: var(--bg-modal);
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  padding: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.cell-action-btn {
  padding: 4px 8px;
  background: var(--bg-tertiary);
  border: none;
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s ease;
  font-family: "HalvarBreit", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.cell-action-btn:hover {
  background: var(--accent);
  color: var(--bg-secondary);
}

.cell-action-btn-delete:hover {
  background: #ff4444;
  color: white;
}

@media (max-width: 768px) {
  body {
    font-size: 12px;
  }
  
  .grid-header {
    font-size: 11px;
  }
  
  .grid-day {
    font-size: 11px;
    padding: 6px 4px;
  }
  
  .time-grid {
    font-size: 11px;
  }
  
  .time-label {
    font-size: 10px;
    padding: 4px;
  }
  
  .grid-cell {
    min-height: 30px;
  }
  
  .grid-task,
  .grid-cell-block {
    font-size: 10px;
    padding: 4px 6px;
    min-height: 28px;
  }
  
  .grid-task-time {
    font-size: 9px;
  }
}

@media (max-width: 480px) {
  .grid-header {
    font-size: 10px;
  }
  
  .grid-day {
    font-size: 10px;
    padding: 4px 2px;
  }
  
  .time-label {
    font-size: 9px;
    padding: 2px;
  }
  
  .grid-cell {
    min-height: 25px;
  }
  
  .grid-task,
  .grid-cell-block {
    font-size: 9px;
    padding: 2px 4px;
    min-height: 24px;
  }
}

