/**
 * Shared Full-Height Drawer & Operating Hours Widget Stylesheet
 * Module: assets/css/crm-drawer.css
 * 
 * Supports DOOM CRM, Sapper CRM, and shared mcHoursWidget.
 * Strong selectors ensure override of legacy .mc-crm-drawer rules.
 */

/* ==========================================================================
   1. Shared Drawer Backdrop
   ========================================================================== */
.mc-crm-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 12, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1040;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}

.mc-crm-drawer-backdrop.active,
.mc-crm-drawer-backdrop.mc-crm-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* ==========================================================================
   2. Full-Height Drawer (Desktop: 520px, Mobile: 100vw)
   ========================================================================== */
body > #mcCrmInspector,
body > #mcSapperInspector,
#mcCrmInspector.mc-crm-drawer,
#mcSapperInspector.mc-crm-drawer,
.mc-crm-full-drawer {
  position: fixed !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: auto !important;
  width: 520px !important;
  max-width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  max-height: none !important;
  box-sizing: border-box !important;
  margin: 0 !important;
  padding: 0 !important;
  border-radius: 0 !important;
  border: none !important;
  border-left: 1px solid var(--outline-variant, rgba(255, 255, 255, 0.1)) !important;
  z-index: 1050 !important;
  background: var(--surface-container, #1c2028) !important;
  color: var(--on-surface, #dfe2ee) !important;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5) !important;
  display: flex !important;
  flex-direction: column !important;
  transform: translateX(100%) !important;
  visibility: hidden !important;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s ease !important;
  pointer-events: none !important;
  overflow: hidden !important;
}

/* Light Theme */
[data-theme="light"] body > #mcCrmInspector,
[data-theme="light"] body > #mcSapperInspector,
[data-theme="light"] #mcCrmInspector.mc-crm-drawer,
[data-theme="light"] #mcSapperInspector.mc-crm-drawer,
[data-theme="light"] .mc-crm-full-drawer,
.light body > #mcCrmInspector,
.light body > #mcSapperInspector,
.light #mcCrmInspector.mc-crm-drawer,
.light #mcSapperInspector.mc-crm-drawer,
.light .mc-crm-full-drawer {
  background: var(--surface-container, #ffffff) !important;
  color: var(--on-surface, #1a1c1e) !important;
  border-left: 1px solid var(--outline-variant, rgba(0, 0, 0, 0.12)) !important;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.15) !important;
}

/* Open State */
body > #mcCrmInspector.mc-crm-open,
body > #mcSapperInspector.mc-crm-open,
#mcCrmInspector.mc-crm-drawer.mc-crm-open,
#mcSapperInspector.mc-crm-drawer.mc-crm-open,
.mc-crm-full-drawer.mc-crm-open {
  transform: translateX(0) !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

/* Mobile full width */
@media (max-width: 640px) {
  body > #mcCrmInspector,
  body > #mcSapperInspector,
  #mcCrmInspector.mc-crm-drawer,
  #mcSapperInspector.mc-crm-drawer,
  .mc-crm-full-drawer {
    width: 100vw !important;
    max-width: 100vw !important;
  }
}

/* Suppress background interactions & mobile nav when open */
body.drawer-open {
  overflow: hidden !important;
}

body.drawer-open #mobileNav,
body.drawer-open nav.mobile-bottom-nav,
body.drawer-open .mobile-bottom-bar,
body.drawer-open [data-mobile-bottom-nav] {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* Preserve board width & scroll when drawer opens */
#page-doom-sports .mc-crm-grid {
  display: block !important;
  width: 100% !important;
}

#page-doom-sports .mc-crm-board {
  width: 100% !important;
  overflow-x: auto !important;
}

/* ==========================================================================
   3. Pinned Header & Identity Inside Drawer
   ========================================================================== */
.mc-drawer-header {
  position: sticky;
  top: 0;
  z-index: 20;
  flex-shrink: 0;
  background: var(--surface-container, #1c2028);
  padding: 16px 20px 10px 20px;
  border-bottom: 1px solid var(--outline-variant, rgba(255, 255, 255, 0.08));
}

[data-theme="light"] .mc-drawer-header,
.light .mc-drawer-header {
  background: var(--surface-container, #ffffff);
  border-bottom-color: var(--outline-variant, rgba(0, 0, 0, 0.08));
}

.mc-drawer-identity-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.mc-drawer-title-wrap {
  min-width: 0;
  flex: 1;
}

.mc-drawer-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--on-surface, #dfe2ee);
  line-height: 1.3;
  margin: 4px 0 0 0;
  word-break: break-word;
}

[data-theme="light"] .mc-drawer-title,
.light .mc-drawer-title {
  color: var(--on-surface, #1a1c1e);
}

.mc-drawer-meta-sub {
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--outline, #849495);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.mc-drawer-close-btn {
  background: transparent;
  border: none;
  color: var(--outline, #849495);
  cursor: pointer;
  padding: 8px;
  min-width: 38px;
  min-height: 38px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background 0.15s ease;
}

.mc-drawer-close-btn:hover {
  color: var(--on-surface, #dfe2ee);
  background: rgba(255, 255, 255, 0.08);
}

[data-theme="light"] .mc-drawer-close-btn:hover,
.light .mc-drawer-close-btn:hover {
  color: var(--on-surface, #1a1c1e);
  background: rgba(0, 0, 0, 0.06);
}

/* Drawer Tabs */
.mc-drawer-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  margin-top: 10px;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.mc-drawer-tabs::-webkit-scrollbar {
  display: none;
}

.mc-drawer-tab-btn {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: var(--surface-container-high, #262a33);
  color: var(--on-surface-variant, #b9cacb);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  min-height: 34px;
}

[data-theme="light"] .mc-drawer-tab-btn,
.light .mc-drawer-tab-btn {
  background: var(--surface-container-high, #f0f2f5);
  color: var(--on-surface-variant, #5c6269);
}

.mc-drawer-tab-btn:hover {
  background: var(--surface-variant, #333842);
  color: var(--on-surface, #dfe2ee);
}

[data-theme="light"] .mc-drawer-tab-btn:hover,
.light .mc-drawer-tab-btn:hover {
  background: #e4e7eb;
  color: var(--on-surface, #1a1c1e);
}

.mc-drawer-tab-btn.active,
.mc-drawer-tab-btn[aria-pressed="true"] {
  background: var(--primary, #00f0ff);
  color: var(--on-primary, #00363d);
  border-color: var(--primary, #00f0ff);
  font-weight: 700;
}

/* ==========================================================================
   4. Scrollable Body
   ========================================================================== */
.mc-drawer-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 20px 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
}

.mc-drawer-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mc-drawer-card {
  background: var(--surface-container-high, #262a33);
  border: 1px solid var(--outline-variant, rgba(255, 255, 255, 0.08));
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

[data-theme="light"] .mc-drawer-card,
.light .mc-drawer-card {
  background: var(--surface-container-low, #f4f5f8);
  border-color: var(--outline-variant, rgba(0, 0, 0, 0.08));
}

/* ==========================================================================
   5. Reusable Operating Hours Widget (.mc-hours-widget)
   ========================================================================== */
.mc-hours-widget {
  background: var(--surface-container-low, #181c24);
  border: 1px solid var(--outline-variant, rgba(255, 255, 255, 0.08));
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

[data-theme="light"] .mc-hours-widget,
.light .mc-hours-widget {
  background: var(--surface-container-low, #f8f9fa);
  border-color: var(--outline-variant, rgba(0, 0, 0, 0.08));
}

.mc-hours-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.mc-hours-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--outline, #849495);
  display: flex;
  align-items: center;
  gap: 6px;
}

.mc-hours-day-select {
  font-size: 12px;
  font-family: inherit;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--surface-container, #1c2028);
  color: var(--on-surface, #dfe2ee);
  border: 1px solid var(--outline-variant, rgba(255, 255, 255, 0.15));
  outline: none;
  cursor: pointer;
  min-height: 32px;
}

[data-theme="light"] .mc-hours-day-select,
.light .mc-hours-day-select {
  background: #ffffff;
  color: #1a1c1e;
  border-color: rgba(0, 0, 0, 0.15);
}

.mc-hours-status-message {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.4;
  background: var(--surface-container, #1c2028);
  color: var(--on-surface-variant, #b9cacb);
  border-left: 3px solid var(--outline, #849495);
}

.mc-hours-status-message.state-conflict {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border-left-color: #ef4444;
}

.mc-hours-status-message.state-stale {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
  border-left-color: #f59e0b;
}

.mc-hours-status-message.state-verified {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
  border-left-color: #10b981;
}

/* Timeline Track */
.mc-hours-timeline-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mc-hours-axis-track {
  position: relative;
  height: 24px;
  background: var(--surface-container-highest, #2c313c);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--outline-variant, rgba(255, 255, 255, 0.08));
}

[data-theme="light"] .mc-hours-axis-track,
.light .mc-hours-axis-track {
  background: #e8eaed;
  border-color: rgba(0, 0, 0, 0.08);
}

.mc-hours-band-open {
  position: absolute;
  top: 0;
  bottom: 0;
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.6) 0%, rgba(16, 185, 129, 0.8) 100%);
  border-left: 1px solid #10b981;
  border-right: 1px solid #10b981;
}

.mc-hours-band-closure {
  position: absolute;
  top: 0;
  bottom: 0;
  background: repeating-linear-gradient(45deg, rgba(239, 68, 68, 0.2), rgba(239, 68, 68, 0.2) 6px, rgba(239, 68, 68, 0.35) 6px, rgba(239, 68, 68, 0.35) 12px);
  border-left: 1px dashed rgba(239, 68, 68, 0.6);
  border-right: 1px dashed rgba(239, 68, 68, 0.6);
}

.mc-hours-axis-labels {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--outline, #849495);
  padding: 0 2px;
}

.mc-hours-disclaimer {
  font-size: 11px;
  color: var(--outline, #849495);
  line-height: 1.35;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--surface-container, #1c2028);
}

[data-theme="light"] .mc-hours-disclaimer,
.light .mc-hours-disclaimer {
  background: #f0f2f5;
  color: #5c6269;
}

/* Provenance */
.mc-hours-provenance {
  border-top: 1px solid var(--outline-variant, rgba(255, 255, 255, 0.08));
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  color: var(--on-surface-variant, #b9cacb);
}

[data-theme="light"] .mc-hours-provenance,
.light .mc-hours-provenance {
  border-top-color: rgba(0, 0, 0, 0.08);
  color: #5c6269;
}

.mc-hours-provenance a {
  color: var(--primary, #00f0ff);
  text-decoration: underline;
  word-break: break-all;
}

.mc-hours-quote {
  font-style: italic;
  font-size: 11px;
  padding: 6px 10px;
  border-left: 2px solid var(--primary, #00f0ff);
  background: var(--surface-container, #1c2028);
  color: var(--on-surface-variant, #b9cacb);
  border-radius: 0 6px 6px 0;
  margin-top: 4px;
}

[data-theme="light"] .mc-hours-quote,
.light .mc-hours-quote {
  background: #f0f2f5;
  color: #3f444a;
}

/* Compact summary chip inside Overview tab */
.mc-hours-compact-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--surface-container-high, #262a33);
  border: 1px solid var(--outline-variant, rgba(255, 255, 255, 0.08));
  font-size: 12px;
}

[data-theme="light"] .mc-hours-compact-card,
.light .mc-hours-compact-card {
  background: var(--surface-container-high, #f0f2f5);
  border-color: rgba(0, 0, 0, 0.08);
}

body.drawer-open #mcMobileWorkspaces {display:none !important;}
