/* =============================================================
   BUTTONS
   ============================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--gap-sm);
  padding: 0.45rem 1rem;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  font-family: inherit;
  text-transform: lowercase;
  white-space: nowrap;
  cursor: pointer;
  transition: opacity var(--t-fast), background var(--t-fast), color var(--t-fast);
  border: 1px solid transparent;
  text-decoration: none;
  line-height: 1.4;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--accent);
  color: #0C0C0D;
  border-color: var(--accent);
}
.btn-primary:hover {
  opacity: 0.85;
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: rgba(252, 247, 241, 0.25);
}
.btn-secondary:hover {
  background: var(--surface-2);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--surface);
  color: var(--text);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: rgba(224, 68, 68, 0.30);
}
.btn-danger:hover {
  background: var(--danger-dim);
}

.btn-sm {
  padding: 0.25rem 0.6rem;
  font-size: var(--text-xs);
}

.btn-lg {
  padding: 0.65rem 1.4rem;
  font-size: var(--text-base);
}

.btn-full {
  width: 100%;
  justify-content: center;
}

/* Spinner inside button */
.btn .spinner {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: none;
}
.btn.loading .spinner {
  display: inline-block;
}
.btn.loading .btn-text {
  opacity: 0.6;
}

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

/* =============================================================
   INPUTS
   ============================================================= */
.inp {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: transparent;
  border: 1px solid rgba(252, 247, 241, 0.20);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: var(--text-sm);
  line-height: 1.5;
  transition: border-color var(--t-fast);
  outline: none;
  font-family: inherit;
  text-transform: lowercase;
}

.inp::placeholder {
  color: var(--text-dim);
}

.inp:focus {
  border-color: var(--text-muted);
}

.inp:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

textarea.inp {
  resize: vertical;
  min-height: 80px;
}

select.inp {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='rgba(252,247,241,0.4)' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 2rem;
}

.inp.error {
  border-color: var(--danger);
}

/* =============================================================
   FORM GROUP & ERRORS
   ============================================================= */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: var(--gap-md);
}

.form-label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.form-error {
  font-size: var(--text-sm);
  color: var(--danger);
  margin-top: 0.25rem;
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-dim);
  margin-top: 0.2rem;
}

.field-error {
  font-size: var(--text-xs);
  color: var(--danger);
  margin-top: 0.2rem;
}

/* =============================================================
   CARD
   ============================================================= */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--card-pad);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--gap-md);
  padding-bottom: var(--gap-md);
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: var(--text-base);
  font-weight: 500;
}

/* =============================================================
   BADGES / PILLS
   ============================================================= */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.45rem;
  font-size: var(--text-xs);
  font-weight: 500;
  border-radius: var(--radius-sm);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.badge-default  { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.badge-accent   { background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(197,106,45,.25); }
.badge-danger   { background: var(--danger-dim); color: var(--danger); border: 1px solid rgba(224,68,68,.25); }
.badge-success  { background: var(--success-dim); color: var(--success); border: 1px solid rgba(76,175,123,.25); }
.badge-warning  { background: var(--warning-dim); color: var(--warning); border: 1px solid rgba(212,160,23,.25); }

/* Stage badge colors */
.stage-pre_production  { background: var(--surface-2); color: var(--text-muted); }
.stage-production      { background: rgba(59,126,246,.12); color: #7EB3FF; }
.stage-post_production { background: rgba(139,92,246,.12); color: #C4A5FF; }
.stage-review          { background: var(--accent-dim); color: var(--accent); }
.stage-revisions       { background: var(--warning-dim); color: var(--warning); }
.stage-delivered       { background: var(--success-dim); color: var(--success); }
.stage-complete        { background: rgba(76,175,123,.20); color: var(--success); }

/* Video status badges */
.status-draft              { background: var(--surface-2); color: var(--text-muted); }
.status-review             { background: var(--accent-dim); color: var(--accent); }
.status-approved           { background: var(--success-dim); color: var(--success); }
.status-revision_requested { background: var(--warning-dim); color: var(--warning); }

/* Contract status */
.contract-none     { background: var(--surface-2); color: var(--text-dim); }
.contract-sent     { background: var(--accent-dim); color: var(--accent); }
.contract-signed   { background: rgba(59,126,246,.12); color: #7EB3FF; }
.contract-complete { background: var(--success-dim); color: var(--success); }

/* =============================================================
   EMPTY STATE
   ============================================================= */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem var(--gap-lg);
  text-align: center;
  gap: var(--gap-sm);
}

.empty-state-icon {
  width: 40px;
  height: 40px;
  color: var(--text-dim);
  margin-bottom: var(--gap-sm);
}

.empty-state-title {
  font-size: var(--text-base);
  color: var(--text-muted);
  font-weight: 500;
}

.empty-state-sub {
  font-size: var(--text-sm);
  color: var(--text-dim);
  max-width: 320px;
}

/* =============================================================
   TOAST
   ============================================================= */
.toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
  pointer-events: none;
}

.toast {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.9rem;
  font-size: var(--text-sm);
  color: var(--text);
  max-width: 320px;
  pointer-events: auto;
  animation: toast-in var(--t-base) forwards;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.toast.toast-out {
  animation: toast-out var(--t-base) forwards;
}

.toast-error  { border-color: rgba(224,68,68,.35); color: var(--danger); }
.toast-success{ border-color: rgba(76,175,123,.35); color: var(--success); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(8px); }
}

/* =============================================================
   MODAL
   ============================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 12, 13, 0.88);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gap-lg);
  animation: fade-in var(--t-base) ease;
}

.modal-card {
  background: #161618;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--gap-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--gap-lg);
}

.modal-title {
  font-size: var(--text-lg);
  font-weight: 500;
}

.modal-close {
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0.2rem;
}
.modal-close:hover {
  color: var(--text);
}

.modal-footer {
  display: flex;
  gap: var(--gap-sm);
  justify-content: flex-end;
  margin-top: var(--gap-lg);
  padding-top: var(--gap-md);
  border-top: 1px solid var(--border);
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Native page-embedded modal (toggled via element.hidden) */
.modal:not([hidden]) {
  position: fixed;
  inset: 0;
  background: rgba(12, 12, 13, 0.88);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gap-lg);
}

.modal-backdrop {
  position: absolute;
  inset: 0;
}

.modal-box {
  background: #161618;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--gap-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  z-index: 1;
}

/* =============================================================
   DRAWER
   ============================================================= */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 12, 13, 0.60);
  z-index: 900;
  animation: fade-in var(--t-base) ease;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(460px, 100%);
  background: #131315;
  border-left: 1px solid var(--border);
  z-index: 901;
  overflow-y: auto;
  padding: var(--gap-xl);
  animation: drawer-in var(--t-base) ease;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--gap-xl);
}

.drawer-title {
  font-size: var(--text-lg);
  font-weight: 500;
}

.drawer-close {
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0.2rem;
}
.drawer-close:hover {
  color: var(--text);
}

@keyframes drawer-in {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

/* =============================================================
   DATA TABLE
   ============================================================= */
.data-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.data-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  color: var(--text-dim);
  font-weight: 500;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:hover td {
  background: var(--surface);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table .actions {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  justify-content: flex-end;
}

/* =============================================================
   PAGE HEADER
   ============================================================= */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--gap-xl);
  gap: var(--gap-md);
}

.page-title {
  font-size: var(--text-xl);
  font-weight: 500;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  flex-shrink: 0;
}

/* =============================================================
   STAT CARDS
   ============================================================= */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gap-md);
  margin-bottom: var(--gap-xl);
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--card-pad);
}

.stat-num {
  font-size: var(--text-2xl);
  font-weight: 500;
  line-height: 1.1;
  color: var(--text);
  margin-bottom: 0.3rem;
}

.stat-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* =============================================================
   STEPPER
   ============================================================= */
.stepper {
  display: flex;
  gap: var(--gap-xs);
  flex-wrap: wrap;
}

.stepper-item {
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: var(--text-xs);
  color: var(--text-dim);
  font-weight: 500;
  white-space: nowrap;
}

.stepper-item.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.stepper-item.done {
  color: var(--text-muted);
  border-color: var(--border);
}

/* =============================================================
   SEARCH BAR
   ============================================================= */
.search-bar {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  margin-bottom: var(--gap-lg);
}

.search-input {
  max-width: 280px;
}

/* =============================================================
   TABS
   ============================================================= */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--gap-xl);
}

.tab-link {
  padding: 0.6rem 1rem;
  font-size: var(--text-sm);
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--t-fast), border-color var(--t-fast);
  text-decoration: none;
  white-space: nowrap;
}

.tab-link:hover {
  color: var(--text);
}

.tab-link.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* =============================================================
   AVATAR DOT
   ============================================================= */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
}

/* =============================================================
   NOTE / COMMENT
   ============================================================= */
.note-list {
  display: flex;
  flex-direction: column;
  gap: var(--gap-md);
}

.note-item {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.note-body {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
}

.note-meta {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  margin-bottom: 0.4rem;
}

.note-author {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-muted);
}

.note-time {
  font-size: var(--text-xs);
  color: var(--text-dim);
}

.note-content {
  font-size: var(--text-sm);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.note-internal {
  border-color: rgba(212,160,23,.25);
  background: var(--warning-dim);
}

.note-pinned {
  border-color: rgba(197,106,45,.25);
}

/* =============================================================
   SKELETON / LOADING
   ============================================================= */
@keyframes skeleton-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.skeleton {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  animation: skeleton-pulse 1.4s ease infinite;
}

/* =============================================================
   VIDEO CARD
   ============================================================= */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--gap-lg);
}

.video-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color var(--t-fast);
  text-decoration: none;
  display: block;
  color: inherit;
}

.video-card:hover {
  border-color: var(--border-2);
}

.video-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
}

.video-thumb svg {
  width: 32px;
  height: 32px;
}

.video-info {
  padding: 0.75rem 1rem;
}

.video-title {
  font-size: var(--text-sm);
  font-weight: 500;
  margin-bottom: 0.3rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.video-meta {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  flex-wrap: wrap;
}

/* =============================================================
   ACTIVITY FEED
   ============================================================= */
.activity-list {
  display: flex;
  flex-direction: column;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
}

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

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-2);
  flex-shrink: 0;
  margin-top: 0.4rem;
}

.activity-text {
  flex: 1;
  color: var(--text-muted);
  line-height: 1.5;
}

.activity-time {
  font-size: var(--text-xs);
  color: var(--text-dim);
  flex-shrink: 0;
  white-space: nowrap;
}

/* =============================================================
   FOOTER
   ============================================================= */
.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem var(--page-x);
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.footer-name {
  font-size: var(--text-sm);
  color: var(--text-dim);
}

.footer-social {
  display: flex;
  align-items: center;
  gap: var(--gap-md);
}

.footer-social a {
  color: var(--text-dim);
  transition: color var(--t-fast);
  display: flex;
  align-items: center;
}

.footer-social a:hover {
  color: var(--text-muted);
}

.footer-social svg {
  width: 16px;
  height: 16px;
}

/* =============================================================
   FILTER PILLS (stage tabs)
   ============================================================= */
.filter-pills {
  display: flex;
  gap: var(--gap-sm);
  flex-wrap: wrap;
  margin-bottom: var(--gap-lg);
}

.filter-pill {
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: all var(--t-fast);
  white-space: nowrap;
}

.filter-pill:hover {
  border-color: var(--border-2);
  color: var(--text);
}

.filter-pill.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

/* =============================================================
   CALENDAR
   ============================================================= */
.calendar-wrap {
  width: 100%;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--gap-md);
}

.calendar-title {
  font-size: var(--text-sm);
  font-weight: 500;
}

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

.calendar-dow {
  text-align: center;
  font-size: var(--text-xs);
  color: var(--text-dim);
  padding: 0.3rem 0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.calendar-cell {
  min-height: 56px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 0.35rem;
  font-size: var(--text-xs);
  color: var(--text-muted);
  position: relative;
}

.calendar-cell.today {
  border: 1px solid var(--border-2);
}

.calendar-cell.other-month {
  opacity: 0.35;
}

.calendar-day-num {
  display: block;
  margin-bottom: 0.25rem;
}

.calendar-dots {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
}

.calendar-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

.dot-deadline  { background: var(--text); }
.dot-shoot     { background: var(--accent); }
.dot-delivered { background: rgba(252,247,241,0.35); }

/* =============================================================
   VIDEO PLAYER
   ============================================================= */
.video-player-wrap {
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
}

.video-player-wrap video,
.video-player-wrap iframe {
  width: 100%;
  height: 100%;
  display: block;
  border: none;
}

/* =============================================================
   TOGGLE SWITCH (for video flags)
   ============================================================= */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.toggle-row:last-child {
  border-bottom: none;
}

.toggle-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.toggle-switch {
  position: relative;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform var(--t-fast), background var(--t-fast);
}

.toggle-switch input:checked + .toggle-track {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.toggle-switch input:checked + .toggle-track::after {
  background: var(--accent);
  transform: translateX(16px);
}

/* =============================================================
   DEADLINE COUNTDOWN
   ============================================================= */
.deadline-card {
  text-align: center;
  padding: var(--gap-lg);
}

.deadline-num {
  font-size: 3rem;
  font-weight: 500;
  line-height: 1;
  margin-bottom: 0.3rem;
}

.deadline-num.overdue {
  color: var(--danger);
}

.deadline-unit {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* =============================================================
   TWO-COLUMN GRID (dashboard)
   ============================================================= */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap-lg);
  margin-bottom: var(--gap-xl);
}

@media (max-width: 768px) {
  .two-col {
    grid-template-columns: 1fr;
  }
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .page-header {
    flex-wrap: wrap;
  }
  .page-header .page-actions {
    flex-shrink: unset;
  }
}

@media (max-width: 480px) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
