/* ===============================
   callsheet.css
   Call Sheet Section - Lína Style
   Two-panel layout matching stripboard
   =============================== */

/* ===============================
   PAGE LAYOUT
   =============================== */

.callsheet-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  border-width: 0px !important;
}

.callsheet-header {
  border-bottom: 0px !important;
}

.callsheet-canvas {
  flex: 1;
  overflow: auto;
  background: transparent !important;
  padding: 20px;
}

/* Header icon with gradient */
.callsheet-header-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-muted, #b8956e));
  border-radius: 8px;
}

.callsheet-header-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-primary);
}

/* ===============================
   LOADING STATE
   =============================== */

.callsheet-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 300px;
  color: var(--text-secondary);
  gap: 14px;
}

.callsheet-loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: cs-spin 1s linear infinite;
}

@keyframes cs-spin {
  to { transform: rotate(360deg); }
}

/* ===============================
   TWO-PANEL LAYOUT
   Matches stripboard (220px left panel)
   =============================== */

.callsheet-layout {
  display: flex;
  gap: 20px;
  height: 100%;
  min-height: 400px;
}

/* Left panel - Call Sheet List */
.callsheet-list-panel {
  width: 220px;
  min-width: 220px;
  max-width: 220px;
  flex-shrink: 0;
}

/* Right panel - Editor */
.callsheet-editor-panel {
  flex: 1;
  min-width: 0;
  overflow: auto;
}

.callsheet-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

/* ===============================
   LIST EMPTY STATE
   =============================== */

.callsheet-list-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 12px;
  text-align: center;
}

.callsheet-list-empty .empty-icon {
  font-size: 28px;
  margin-bottom: 8px;
  opacity: 0.5;
}

.callsheet-list-empty .empty-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.callsheet-list-empty .empty-hint {
  font-size: 10px;
  color: var(--text-secondary);
}

/* ===============================
   LIST ITEMS
   =============================== */

.callsheet-list-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  margin-bottom: 6px;
  background: var(--bg-elevated);
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.callsheet-list-item:hover {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.callsheet-list-item.active {
  background: var(--accent);
  border-color: var(--accent);
}

.callsheet-list-item.active .cs-item-day {
  color: #fff;
}

.callsheet-list-item.active .cs-item-date,
.callsheet-list-item.active .cs-item-scenes {
  color: rgba(255, 255, 255, 0.8);
}

.callsheet-list-item.active .cs-item-status {
  background: rgba(255, 255, 255, 0.2) !important;
  color: #fff !important;
}

.cs-item-main {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.cs-item-day {
  font-weight: 600;
  font-size: 12px;
  color: var(--text-primary);
}

.cs-item-date {
  font-size: 10px;
  color: var(--text-secondary);
}

.cs-item-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cs-item-scenes {
  font-size: 10px;
  color: var(--text-tertiary, #666);
}

.cs-item-call {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
}

.callsheet-list-item.active .cs-item-call {
  color: rgba(255, 255, 255, 0.8);
}

.cs-item-status {
  font-size: 9px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
}

/* ===============================
   EDITOR EMPTY STATE
   =============================== */

.callsheet-editor-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 400px;
  text-align: center;
  padding: 40px;
}

.callsheet-editor-empty .empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.callsheet-editor-empty .empty-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.callsheet-editor-empty .empty-text {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ===============================
   EDITOR CONTAINER
   =============================== */

.callsheet-editor {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
}

.cs-tab-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px;
}

/* Editor Header */
.cs-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.cs-editor-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.cs-status-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.cs-status-select {
  background: var(--bg-input, #1a1a1e);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 16px;
  min-width: 130px;
  cursor: pointer;
}

/* Locked state — disable all editing */
.cs-locked #csTabCallsheet .cs-edit-panel-btn {
  opacity: 0.3;
  pointer-events: none;
}

.cs-locked #csTabCallsheet .cs-table-input,
.cs-locked #csTabCallsheet .cs-input,
.cs-locked #csTabCallsheet .cs-textarea,
.cs-locked #csTabCallsheet .cs-select {
  pointer-events: none;
  opacity: 0.6;
}

.cs-locked #csTabCallsheet .remove-scene-btn,
.cs-locked #csTabCallsheet .remove-cast-btn,
.cs-locked #csTabCallsheet #addSceneBtn,
.cs-locked #csTabCallsheet #addCastBtn {
  display: none;
}

.cs-locked #csTabCallsheet .btn-icon:not(#previewCallsheetBtn) {
  opacity: 0.3;
  pointer-events: none;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 6px;
  background: var(--bg-input, #1a1a1e);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.btn-icon:hover {
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

.btn-icon.btn-danger {
  color: var(--text-secondary);
}

.btn-icon.btn-danger:hover {
  color: #e74c3c;
  border-color: #e74c3c;
}

.btn-icon svg {
  width: 16px;
  height: 16px;
}

.cs-editor-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.cs-editor-actions {
  display: flex;
  gap: 8px;
}

/* ===============================
   SECTIONS (matching breakdown.css)
   =============================== */

.cs-section {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: visible;
}

.cs-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  min-height: 48px;
  border-radius: 8px 8px 0 0;
}

.cs-section-icon {
  font-size: 16px;
  opacity: 0.8;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.cs-section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-primary);
}

.cs-section-body {
  display: block;
  padding: 20px;
  background: var(--bg-panel);
}

.cs-section-body-grid {
  display: block;
  padding: 16px;
  background: var(--bg-panel);
}

/* ===============================
   FORM GRID
   =============================== */

.cs-form-grid {
  display: grid;
  grid-template-columns: 1fr 100px 100px 100px;
  gap: 16px;
  align-items: end;
}

.cs-form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cs-form-field label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  font-weight: 600;
}

.cs-form-field.cs-field-full {
  grid-column: 1 / -1;
}

/* Form Inputs */
.cs-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  background: var(--bg-input, #1a1a1e);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  transition: border-color 0.15s ease, background 0.15s ease;
  box-sizing: border-box;
}

.cs-input:hover {
  background: rgba(0, 0, 0, 0.3);
}

.cs-input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(0, 0, 0, 0.3);
}

.cs-textarea {
  resize: vertical;
  min-height: 60px;
}

.cs-select {
  cursor: pointer;
}

/* ===============================
   STATUS ROW
   =============================== */

.cs-status-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.cs-status-row select {
  width: auto;
  min-width: 120px;
}

/* ===============================
   TABLES
   =============================== */

.cs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.cs-table th {
  background: var(--bg-elevated);
  padding: 10px 8px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

.cs-table td {
  padding: 4px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.cs-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.cs-table-input {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 8px;
  color: var(--text-primary);
  font-size: 12px;
}

.cs-table-input:hover {
  background: var(--bg-input, #1a1a1e);
}

.cs-table-input:focus {
  outline: none;
  background: var(--bg-input, #1a1a1e);
  border-color: var(--accent);
}

.cs-table-empty {
  text-align: center;
  padding: 24px 12px;
  color: var(--text-tertiary, #666);
  font-size: 12px;
  font-style: italic;
}

/* ===============================
   PRODUCTION HEADER (combined schedule + prod info)
   =============================== */

.cs-production-header-section {
  padding: 0 !important;
}

.cs-production-header-top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  border-radius: 8px 8px 0 0;
}

.cs-day-badge {
  min-width: 56px;
  height: 56px;
  padding: 0 10px;
  border: 2px solid var(--accent);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
  gap: 1px;
  line-height: 1;
}

.cs-day-badge-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.8;
}

.cs-day-badge-number {
  font-size: 22px;
  font-weight: 700;
  font-family: "Unbounded", sans-serif;
}

.cs-production-header-info {
  flex: 1;
  min-width: 0;
}

.cs-production-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
  line-height: 1.3;
}

.cs-production-date {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.cs-production-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.cs-meta-tag {
  padding: 3px 10px;
  background: var(--bg-input, #1a1a1e);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

.cs-meta-tag.cs-meta-dim {
  opacity: 0.5;
  font-style: italic;
}

.cs-production-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.cs-crew-call-display {
  text-align: center;
  flex-shrink: 0;
  padding: 0 16px;
  border-left: 1px solid var(--border);
}

.cs-crew-call-time {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: "Unbounded", sans-serif;
  line-height: 1.2;
}

.cs-crew-call-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  font-weight: 600;
  margin-top: 2px;
}

.cs-production-header-details {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

/* ===============================
   LOCATION & WEATHER TWO-COLUMN LAYOUT
   =============================== */

.cs-location-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.cs-location-details {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cs-weather-row {
  display: flex;
  gap: 20px;
}

.cs-weather-row .cs-readonly-field {
  flex: 1;
}

.cs-location-map {
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 180px;
}

.cs-map-iframe {
  width: 100%;
  flex: 1;
  border: none;
  min-height: 160px;
  background: var(--bg-input, #1a1a1e);
}

.cs-map-link {
  display: block;
  text-align: center;
  padding: 6px;
  font-size: 11px;
  color: var(--text-secondary);
  text-decoration: none;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  transition: color 0.15s ease;
}

.cs-map-link:hover {
  color: var(--accent);
}

.cs-map-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 100%;
  min-height: 180px;
  color: var(--text-secondary);
  font-size: 13px;
  background: var(--bg-input, #1a1a1e);
}

/* ===============================
   READ-ONLY DISPLAY PANELS
   =============================== */

.cs-readonly-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.cs-readonly-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.cs-readonly-field.cs-readonly-full {
  grid-column: 1 / -1;
}

.cs-readonly-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  font-weight: 600;
}

.cs-readonly-value {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.4;
}

/* Override dot indicator */
.cs-override-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
  flex-shrink: 0;
  margin-left: 6px;
}

/* Edit panel button */
.cs-edit-panel-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  opacity: 0.6;
  transition: opacity 0.15s ease;
}

.cs-edit-panel-btn:hover {
  opacity: 1;
}

.cs-edit-panel-btn svg {
  width: 14px;
  height: 14px;
}

/* ===============================
   EDIT MODAL FIELDS
   =============================== */

.cs-edit-modal {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cs-modal-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cs-modal-field label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  font-weight: 600;
}

.cs-modal-row {
  display: flex;
  gap: 12px;
}

.cs-modal-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* Reset button */
.cs-reset-btn {
  display: inline-flex;
  align-items: center;
  color: var(--text-secondary);
  font-size: 12px;
}

.cs-reset-btn:hover {
  color: var(--accent);
}

.cs-reset-btn.hidden {
  display: none;
}

/* ===============================
   RESPONSIVE
   =============================== */

@media (max-width: 768px) {
  .callsheet-layout {
    flex-direction: column;
    gap: 16px;
  }

  .callsheet-list-panel {
    width: 100%;
    min-width: 100%;
    max-width: 100%;
    max-height: 150px;
  }

  .callsheet-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px;
  }

  .callsheet-list-item {
    flex: 0 0 auto;
    min-width: 120px;
    margin-bottom: 0;
  }

  .cs-form-grid {
    grid-template-columns: 1fr 1fr;
  }

  .cs-form-field.cs-field-full {
    grid-column: 1 / -1;
  }

  .cs-readonly-grid {
    grid-template-columns: 1fr;
  }

  .cs-production-header-details {
    grid-template-columns: 1fr;
  }

  .cs-location-layout {
    grid-template-columns: 1fr;
  }

  .cs-location-map {
    min-height: 200px;
  }

  .cs-modal-row {
    flex-direction: column;
    gap: 14px;
  }
}

@media (max-width: 500px) {
  .cs-form-grid {
    grid-template-columns: 1fr;
  }

  .cs-form-field.cs-field-full {
    grid-column: span 1;
  }
}

/* ===============================
   PRINT
   =============================== */

@media print {
  .callsheet-list-panel {
    display: none;
  }

  .callsheet-editor-panel {
    border: none;
  }
}

/* ===============================
   TABS (in editor header)
   =============================== */

.cs-header-tabs {
  display: flex;
  gap: 2px;
  align-items: stretch;
}

.cs-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary, #a0a0b0);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.cs-tab:hover {
  color: var(--text-primary, #e0e0e8);
}

.cs-tab.active {
  color: var(--accent, #d18b3c);
  border-bottom-color: var(--accent, #d18b3c);
}

.cs-tab svg {
  opacity: 0.6;
}

.cs-tab.active svg {
  opacity: 1;
}

/* ===============================
   SEND & TRACK PANEL
   =============================== */

.cs-send-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.cs-send-form {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cs-send-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cs-send-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary, #a0a0b0);
  font-weight: 600;
}

.cs-send-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 4px;
}

.cs-send-info {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-tertiary, #666);
  flex: 1;
}

/* ===============================
   TRACKING (within Send & Track)
   =============================== */

.cs-tracking-body {
  padding: 16px 20px;
}

.cs-tracking-summary {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.cs-tracking-stat {
  flex: 1;
  background: var(--bg-elevated, #22212b);
  border-radius: 8px;
  padding: 12px 16px;
  text-align: center;
}

.cs-tracking-stat-value {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary, #e0e0e8);
}

.cs-tracking-stat-value.cs-stat-viewed {
  color: #4caf50;
}

.cs-tracking-stat-value.cs-stat-pending {
  color: #ff9800;
}

.cs-tracking-stat-label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary, #a0a0b0);
  margin-top: 4px;
}

.cs-tracking-group-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-secondary, #a0a0b0);
  font-weight: 600;
  padding: 12px 0 8px;
  border-bottom: 1px solid var(--border-subtle, #2a2935);
  margin-bottom: 4px;
}

.cs-tracking-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border-subtle, #2a2935);
}

.cs-tracking-item:last-child {
  border-bottom: none;
}

.cs-tracking-item-icon {
  flex-shrink: 0;
  width: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cs-tracking-item-info {
  flex: 1;
  min-width: 0;
}

.cs-tracking-item-name {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary, #e0e0e8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cs-tracking-item-dept {
  display: inline-block;
  font-size: 10px;
  color: var(--text-secondary, #a0a0b0);
  margin-top: 1px;
}

.cs-tracking-item-meta {
  flex-shrink: 0;
  text-align: right;
}

.cs-tracking-item-time {
  display: block;
  font-size: 11px;
  color: var(--text-secondary, #a0a0b0);
}

.cs-tracking-item-views {
  display: block;
  font-size: 10px;
  color: var(--text-tertiary, #666);
}

.cs-tracking-item-unseen {
  color: var(--text-tertiary, #666);
}

.cs-tracking-loading,
.cs-tracking-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary, #a0a0b0);
  font-size: 13px;
}

.cs-tracking-viewed .cs-tracking-item-name {
  color: var(--text-primary, #e0e0e8);
}

.cs-tracking-stale .cs-tracking-item-name {
  color: var(--text-primary, #e0e0e8);
}

.cs-tracking-item-stale-time {
  color: #ff9800;
}

.cs-tracking-pending .cs-tracking-item-name {
  color: var(--text-secondary, #a0a0b0);
}

.cs-resend-btn {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--text-secondary, #a0a0b0);
  opacity: 0.5;
  transition: opacity 0.15s, color 0.15s;
}

.cs-tracking-item:hover .cs-resend-btn {
  opacity: 1;
}

.cs-resend-btn:hover {
  color: var(--accent, #d18b3c);
  opacity: 1;
}

.cs-resend-btn:disabled {
  opacity: 0.3;
  pointer-events: none;
}
