/* ========================================================
   SHEET LAYOUTS â€” Grid, Multi-Section, Dual-Panel
   ======================================================== */

/* ---- Shared Sheet Wrapper ---- */
.sheet-view {
  display: none;
  padding: var(--space-md);
  min-height: 100%;
}

.sheet-view.active {
  display: block;
}

/* ---- Header Fields (Date, Week No, etc.) ---- */
.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-sm);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
  width: 100%;
}

.sheet-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.sheet-header-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 1;
}

.header-fields-container {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
}

/* Date Nav overrides in sheet header */
.sheet-header-right .date-nav .nav-btn,
.sheet-header-right .date-nav .date-display {
  color: var(--text-primary) !important;
  border-color: var(--border-grid) !important;
}

.sheet-header-right .date-nav .date-display {
  background: var(--bg-surface) !important;
}

.sheet-header-right .date-nav .date-display:hover,
.sheet-header-right .date-nav .nav-btn:hover {
  background: var(--bg-surface-hover) !important;
}

.header-field {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.header-field-label {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.header-field-input {
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--border-grid);
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-surface);
  min-width: 80px;
  max-width: 200px;
  transition: border-color var(--transition-fast);
}

.header-field-input:focus {
  outline: none;
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px var(--accent-gold-light);
}

.header-field-static {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--text-primary);
}

/* ================================================
   TYPE: GRID (Sheet 1 â€” Weekly Schedule)
   ================================================ */
.grid-wrapper {
  overflow: auto;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-grid);
}

.grid-table {
  display: grid;
  min-width: 100%;
  border-collapse: collapse;
}

/* Grid Header (column names) */
.grid-cell {
  display: flex;
  align-items: center;
  padding: var(--space-xs) var(--space-sm);
  border-right: 1px solid var(--border-grid);
  border-bottom: 1px solid var(--border-grid);
  min-height: 42px;
  font-size: var(--font-size-sm);
  position: relative;
  overflow: hidden;
}

.grid-cell:last-child {
  border-right: none;
}

/* Corner cell (top-left) */
.grid-cell.corner-header {
  background: var(--bg-header);
  color: var(--text-header);
  font-weight: 700;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  justify-content: center;
  position: sticky;
  left: 0;
  z-index: 12;
}

/* Column headers */
.grid-cell.col-header {
  background: var(--bg-header);
  color: var(--text-header);
  font-weight: 700;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  justify-content: center;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 10;
}

/* Row labels (time column) */
.grid-cell.row-label {
  background: linear-gradient(135deg, #FFFCF5, #FFF9ED);
  font-weight: 600;
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  justify-content: center;
  text-align: center;
  position: sticky;
  left: 0;
  z-index: 5;
  border-right: 2px solid var(--border-grid);
  white-space: nowrap;
}

/* Data cells (tappable) */
.grid-cell.data-cell {
  cursor: pointer;
  background: var(--bg-surface);
  transition: background var(--transition-fast);
  font-weight: 500;
  word-break: break-word;
  line-height: 1.3;
}

.grid-cell.data-cell:hover {
  background: var(--accent-gold-light);
}

.grid-cell.data-cell:active {
  transform: scale(0.98);
}

.grid-cell.data-cell.has-content {
  color: var(--text-primary);
}

.grid-cell.data-cell.empty {
  color: var(--text-tertiary);
}

/* Completed / strikethrough cells */
.grid-cell.data-cell.completed {
  text-decoration: line-through;
  text-decoration-color: var(--success);
  text-decoration-thickness: 2px;
  opacity: 0.5;
}

/* Read-only mode (past dates) */
.sheet-view.read-only .grid-cell.data-cell {
  cursor: default;
  pointer-events: none;
}

.sheet-view.read-only .grid-cell.data-cell:hover {
  background: var(--bg-surface);
}

.sheet-view.read-only .header-field-input {
  pointer-events: none;
  opacity: 0.7;
}

/* Cell text preview */
.cell-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

.cell-placeholder {
  color: var(--text-tertiary);
  font-size: var(--font-size-xs);
  font-style: italic;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.grid-cell.data-cell:hover .cell-placeholder {
  opacity: 1;
}

/* ================================================
   TYPE: MULTI-SECTION (Sheet 2 â€” Team Tasks)
   ================================================ */
.multi-section-wrapper {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

.section-block {
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-grid);
}

.section-title-bar {
  display: flex;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  background: linear-gradient(135deg, var(--bg-header), var(--bg-header-light));
  color: var(--text-header);
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.section-title-bar.no-title {
  display: none;
}

/* Column headers in sections */
.section-col-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm) var(--space-xs);
  background: var(--bg-header);
  color: var(--text-header);
  font-weight: 700;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
}

.section-col-header:last-child {
  border-right: none;
}

/* Section grid */
.section-grid {
  display: grid;
}

.section-data-cell {
  display: flex;
  align-items: center;
  padding: var(--space-xs) var(--space-sm);
  border-right: 1px solid var(--border-grid);
  border-bottom: 1px solid var(--border-grid);
  min-height: 42px;
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  background: var(--bg-surface);
  transition: background var(--transition-fast);
  overflow: hidden;
  word-break: break-word;
  line-height: 1.3;
}

.section-data-cell:nth-child(n):last-child,
.section-grid > :nth-child(n+1):nth-last-child(-n+5) ~ .section-col-header {
  border-right: none;
}

.section-data-cell:hover {
  background: var(--accent-gold-light);
}

.section-data-cell:active {
  transform: scale(0.98);
}

.section-data-cell.completed {
  text-decoration: line-through;
  text-decoration-color: var(--success);
  text-decoration-thickness: 2px;
  opacity: 0.5;
}

.sheet-view.read-only .section-data-cell {
  cursor: default;
  pointer-events: none;
}

/* ================================================
   TYPE: DUAL-PANEL (Sheet 3 â€” Daily Scheduler)
   ================================================ */
.dual-panel-wrapper {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.panel {
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-grid);
}

.panel-title {
  padding: var(--space-sm) var(--space-md);
  background: linear-gradient(135deg, var(--bg-header), var(--bg-header-light));
  color: var(--text-header);
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.panel-title.no-title {
  display: none;
}

/* Right panel: stacked lists */
.stacked-lists {
  display: flex;
  flex-direction: column;
}

.list-section {
  border-bottom: 2px solid var(--border-grid);
}

.list-section:last-child {
  border-bottom: none;
}

.list-title {
  display: flex;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  background: linear-gradient(135deg, #FFFCF5, #FFF3DC);
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #8B6914;
  border-bottom: 1px solid var(--border-grid);
}

.list-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-md);
  border-bottom: 1px solid var(--border-light);
  min-height: 38px;
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  background: var(--bg-surface);
  transition: background var(--transition-fast);
}

.list-item:last-child {
  border-bottom: none;
}

.list-item:hover {
  background: var(--accent-gold-light);
}

.list-item:active {
  transform: scale(0.98);
}

.list-item-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: var(--accent-gold-light);
  color: var(--accent-gold);
  font-size: var(--font-size-xs);
  font-weight: 700;
  border-radius: 50%;
  flex-shrink: 0;
}

.list-item-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item.completed {
  text-decoration: line-through;
  text-decoration-color: var(--success);
  text-decoration-thickness: 2px;
  opacity: 0.5;
}

.sheet-view.read-only .list-item {
  cursor: default;
  pointer-events: none;
}

/* ---- Portrait: Stack panels vertically ---- */
@media (orientation: portrait) {
  .dual-panel-wrapper {
    flex-direction: column;
  }
}

/* ---- Landscape: Side by side ---- */
@media (orientation: landscape) {
  .dual-panel-wrapper {
    flex-direction: row;
    align-items: flex-start;
  }

  .dual-panel-wrapper .panel:first-child {
    flex: 3;
  }

  .dual-panel-wrapper .panel:last-child {
    flex: 2;
  }
}

/* ---- Desktop: Side by side always ---- */
@media (min-width: 1024px) {
  .dual-panel-wrapper {
    flex-direction: row;
    align-items: flex-start;
  }

  .dual-panel-wrapper .panel:first-child {
    flex: 3;
  }

  .dual-panel-wrapper .panel:last-child {
    flex: 2;
  }
}

/* ================================================
   TYPE: CARD LAYOUT (Team Delegation)
   ================================================ */
.card-layout-wrapper {
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-grid);
  overflow: hidden;
}

.cards-container {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.team-card {
  width: 100%;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-grid);
  border-bottom: 1px solid var(--border-grid);
  border-radius: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
}

.team-card:nth-child(5n) {
  border-right: none;
}

.team-card:nth-last-child(-n+5) {
  border-bottom: none;
}

/* Removed dragging styles */

.card-header {
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-header);
  color: var(--text-header);
  font-weight: 700;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-grid);
  text-align: center;
}

.card-body {
  display: flex;
  flex-direction: column;
}



.dynamic-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: var(--space-xs);
  background: var(--bg-surface);
  color: var(--text-tertiary);
  border: none;
  border-top: 1px dashed var(--border-grid);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.dynamic-add-btn:hover {
  color: var(--accent-gold-solid);
  background: var(--bg-surface-hover);
}


/* ---- Unfinished Tasks & Paste Mode ---- */
.unfinished-tasks-section {
  border-bottom: 2px solid var(--border-grid);
  margin-bottom: var(--space-xl);
  background: var(--bg-surface);
}

.unfinished-item {
  display: flex;
  align-items: center;
  transition: opacity var(--transition-normal);
}

.unfinished-assign-btn {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  padding: 4px;
  cursor: pointer;
  transition: color var(--transition-fast);
  flex-shrink: 0;
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.unfinished-assign-btn:hover {
  color: var(--accent-gold-solid);
}

.pending-assignment {
  opacity: 0.5;
  pointer-events: none;
}

body.paste-mode {
  cursor: crosshair;
}

body.paste-mode .sheet-view {
  box-shadow: 0 0 0 4px var(--accent-gold-light) inset;
}

body.paste-mode .list-item:not(.unfinished-item),
body.paste-mode .grid-cell.data-cell,
body.paste-mode .section-data-cell {
  cursor: cell !important;
}

body.paste-mode .list-item:not(.unfinished-item):hover,
body.paste-mode .grid-cell.data-cell:hover,
body.paste-mode .section-data-cell:hover {
  background: var(--accent-gold-light);
  outline: 2px solid var(--accent-gold-solid);
  z-index: 10;
}
