/* ==========================================================================
   FLOATING COMMAND PALETTE SYSTEM (Notion & Linear Inspired Glassmorphism)
   ========================================================================== */

/* Backdrop overlay with blur effect */
#commandPaletteBackdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background-color: rgba(15, 23, 42, 0.3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#commandPaletteBackdrop.open {
  opacity: 1;
  pointer-events: auto;
}

html.dark #commandPaletteBackdrop {
  background-color: rgba(2, 6, 23, 0.6);
}

/* Central Card */
#commandPaletteCard {
  position: fixed;
  top: 15vh;
  left: 50%;
  transform: translate(-50%, -20px) scale(0.95);
  width: 92%;
  max-width: 520px;
  max-height: 70vh;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(25px) saturate(180%);
  -webkit-backdrop-filter: blur(25px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 20px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.12),
              inset 0 1px 0 rgba(255, 255, 255, 0.4);
  z-index: 101;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), 
              opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#commandPaletteCard.open {
  transform: translate(-50%, 0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

html.dark #commandPaletteCard {
  background: rgba(15, 23, 42, 0.75);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.4),
              inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* Header Input Bar */
.palette-header {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

html.dark .palette-header {
  border-bottom-color: rgba(255, 255, 255, 0.05);
}

.palette-search-icon {
  color: #94a3b8;
  margin-right: 12px;
  flex-shrink: 0;
}

#paletteSearchInput {
  flex-grow: 1;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

#paletteSearchInput::placeholder {
  color: #94a3b8;
}

/* Badges */
.palette-shortcut-badge {
  font-size: 10px;
  font-family: inherit;
  font-weight: 700;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 6px;
  color: #64748b;
  box-shadow: 0 1px 1px rgba(0,0,0,0.02);
  user-select: none;
}

html.dark .palette-shortcut-badge {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.05);
  color: #94a3b8;
}

/* Results Content Area */
.palette-content {
  flex-grow: 1;
  overflow-y: auto;
  padding: 8px 12px 16px 12px;
  max-height: 45vh;
  scrollbar-width: none;
}

.palette-content::-webkit-scrollbar {
  display: none;
}

/* Category Sections */
.palette-category {
  margin-top: 10px;
}

.palette-category-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #94a3b8;
  padding: 8px 12px 4px 12px;
}

/* Command Item */
.command-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  margin-bottom: 2px;
}

.command-item-left {
  display: flex;
  align-items: center;
  min-width: 0;
}

.command-item-icon {
  width: 32px;
  height: 32px;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  margin-right: 12px;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

html.dark .command-item-icon {
  background: rgba(255, 255, 255, 0.04);
  color: #94a3b8;
}

.command-item-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.command-item-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.command-item-desc {
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-transform: none;
  text-overflow: ellipsis;
}

html.dark .command-item-desc {
  color: #94a3b8;
  opacity: 0.8;
}

/* Selected state (Keyboard Navigation / Hover) */
.command-item.selected,
.command-item:hover {
  background: rgba(37, 99, 235, 0.08);
}

.command-item.selected .command-item-icon,
.command-item:hover .command-item-icon {
  background: var(--primary-color) !important;
  color: white !important;
}

html.dark .command-item.selected,
html.dark .command-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.command-item:active {
  transform: scale(0.995);
}

/* Floating Footer Help */
.palette-footer {
  padding: 10px 20px;
  background: rgba(0, 0, 0, 0.02);
  border-top: 1px solid rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 10px;
  color: #64748b;
}

html.dark .palette-footer {
  background: rgba(0, 0, 0, 0.15);
  border-top-color: rgba(255, 255, 255, 0.04);
  color: #94a3b8;
}

.palette-footer span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.palette-footer kbd {
  padding: 2px 5px;
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 4px;
  font-weight: bold;
}

html.dark .palette-footer kbd {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255,255,255,0.05);
}

/* ==========================================================================
   WIDGETS LAYOUT (Calculator & Calendar)
   ========================================================================== */

.palette-widget-view {
  display: none;
  flex-direction: column;
  padding: 16px 20px;
  animation: widgetSlide 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.palette-widget-view.open {
  display: flex;
}

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

.widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.widget-back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-color) !important;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s;
}

.widget-back-btn:hover {
  background: rgba(37, 99, 235, 0.08);
}

html.dark .widget-back-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

.widget-title {
  font-size: 14px;
  font-weight: 750;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Calculator Widget */
.calc-display-container {
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0,0,0,0.05);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 14px;
  text-align: right;
  overflow: hidden;
}

html.dark .calc-display-container {
  background: rgba(0, 0, 0, 0.2);
  border-color: rgba(255,255,255,0.05);
}

#calcExpr {
  font-size: 11px;
  color: #64748b;
  min-height: 14px;
  font-family: var(--font-mono);
}

html.dark #calcExpr {
  color: #94a3b8;
}

#calcResult {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  min-height: 32px;
  font-family: var(--font-mono);
  margin-top: 4px;
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.calc-btn {
  height: 46px;
  border: 1px solid rgba(0, 0, 0, 0.05);
  background: rgba(255, 255, 255, 0.6);
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

html.dark .calc-btn {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255,255,255,0.05);
}

.calc-btn:hover {
  background: rgba(0, 0, 0, 0.04);
  transform: translateY(-1px);
}

html.dark .calc-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.calc-btn.op-btn {
  color: var(--primary-color);
  background: rgba(37, 99, 235, 0.05);
  border-color: rgba(37, 99, 235, 0.1);
}

html.dark .calc-btn.op-btn {
  color: #60a5fa;
  background: rgba(96, 165, 250, 0.05);
  border-color: rgba(96, 165, 250, 0.08);
}

.calc-btn.op-btn:hover {
  background: rgba(37, 99, 235, 0.15);
}

html.dark .calc-btn.op-btn:hover {
  background: rgba(96, 165, 250, 0.15);
}

.calc-btn.equal-btn {
  background: var(--primary-color) !important;
  color: white !important;
  border: none;
  grid-column: span 2;
}

.calc-btn.equal-btn:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 12px var(--primary-glow);
}

/* Calendar Widget */
.calendar-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.calendar-ctrl-btn {
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid rgba(0, 0, 0, 0.05);
  color: var(--text-primary);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

html.dark .calendar-ctrl-btn {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.05);
}

.calendar-ctrl-btn:hover {
  background: rgba(0, 0, 0, 0.06);
}

html.dark .calendar-ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
}

.calendar-day-header {
  font-size: 10px;
  font-weight: 700;
  color: #64748b;
  padding: 6px 0;
  text-transform: uppercase;
}

.calendar-day-cell {
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  border-radius: 8px;
  transition: all 0.2s;
  cursor: default;
}

.calendar-day-cell.other-month {
  color: #94a3b8;
  opacity: 0.4;
}

.calendar-day-cell.today {
  background: var(--primary-color) !important;
  color: white !important;
  font-weight: 800;
  box-shadow: 0 4px 10px var(--primary-glow);
}
