/* ==========================================================================
   Monetra Snatcher - Calmer, Modern Scheduling System CSS
   Clean, Professional, Google Calendar-like Layout & Restrained Palette
   ========================================================================== */

:root {
  /* Restrained Palette - Light Theme */
  --bg-primary: #f8fafc;
  --bg-surface: #ffffff;
  --bg-hover: #f1f5f9;
  --bg-subtle: #f8fafc;
  --bg-overlay: rgba(15, 23, 42, 0.5);

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  --border-color: #e2e8f0;
  --border-subtle: #f1f5f9;
  --border-focus: #2563eb;

  /* Restrained Color Meanings */
  --color-blue: #2563eb;          /* Primary interaction / current selection */
  --color-blue-bg: #eff6ff;
  --color-purple: #7c3aed;        /* Syntax / Lingsom provider identity */
  --color-purple-bg: #f3e8ff;
  --color-teal: #0284c7;          /* Monetra provider identity */
  --color-teal-bg: #e0f2fe;
  --color-red: #dc2626;           /* Real collision / error */
  --color-red-bg: #fef2f2;
  --color-amber: #d97706;         /* Warning or temporary hold */
  --color-amber-bg: #fffbeb;
  --color-green: #16a34a;         /* Healthy / confirmed */
  --color-green-bg: #f0fdf4;
  --color-gray: #64748b;          /* Cancelled / history / inactive */
  --color-gray-bg: #f1f5f9;

  /* Sizing & Typography */
  --sidebar-width: 230px;
  --header-height: 56px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --transition: all 0.15s ease;
}

/* Dark Theme Palette */
[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-surface: #1e293b;
  --bg-hover: #334155;
  --bg-subtle: #1e293b;
  --bg-overlay: rgba(0, 0, 0, 0.7);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-inverse: #0f172a;

  --border-color: #334155;
  --border-subtle: #1e293b;
  --border-focus: #60a5fa;

  --color-blue: #3b82f6;
  --color-blue-bg: rgba(59, 130, 246, 0.15);
  --color-purple: #a78bfa;
  --color-purple-bg: rgba(124, 58, 237, 0.2);
  --color-teal: #38bdf8;
  --color-teal-bg: rgba(2, 132, 199, 0.2);
  --color-red: #f87171;
  --color-red-bg: rgba(220, 38, 38, 0.2);
  --color-amber: #fbbf24;
  --color-amber-bg: rgba(217, 119, 6, 0.2);
  --color-green: #4ade80;
  --color-green-bg: rgba(22, 163, 74, 0.2);
  --color-gray: #94a3b8;
  --color-gray-bg: rgba(100, 116, 139, 0.2);
}

/* Base Setup */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--color-blue);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* App Layout */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar Navigation */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 100;
  transition: var(--transition);
}

.sidebar-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  border-bottom: 1px solid var(--border-color);
  gap: 0.75rem;
}

.sidebar-logo {
  width: 28px;
  height: 28px;
  background: var(--color-blue);
  color: white;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.sidebar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.sidebar-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.sidebar-nav {
  padding: 1rem 0.75rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  color: var(--text-muted);
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 13px;
  transition: var(--transition);
}

.nav-item:hover {
  background-color: var(--bg-hover);
  color: var(--text-main);
  text-decoration: none;
}

.nav-item.active {
  background-color: var(--color-blue-bg);
  color: var(--color-blue);
  font-weight: 600;
}

.nav-badge {
  margin-left: auto;
  background: var(--color-red);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 10px;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border-color);
  font-size: 11px;
  color: var(--text-muted);
}

/* Main Content Wrapper */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Standalone Minimal Layout for Provider Portal */
.provider-layout .main-wrapper {
  margin-left: 0 !important;
}

/* Top Header Bar */
.top-bar {
  height: var(--header-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 90;
}

.mobile-nav-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-main);
  cursor: pointer;
}

.page-title-area h1 {
  font-size: 18px;
  font-weight: 700;
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Theme Toggle Button */
.theme-toggle-btn {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 13px;
  transition: var(--transition);
}
.theme-toggle-btn:hover {
  background: var(--bg-hover);
}

/* Content Area */
.content-area {
  padding: 1.5rem;
  flex: 1;
}

/* Cards & Layout Utilities */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
}

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

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

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

/* Clean Badges System */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
}

.badge-blue { background: var(--color-blue-bg); color: var(--color-blue); }
.badge-green { background: var(--color-green-bg); color: var(--color-green); }
.badge-amber { background: var(--color-amber-bg); color: var(--color-amber); }
.badge-red { background: var(--color-red-bg); color: var(--color-red); }
.badge-gray { background: var(--color-gray-bg); color: var(--color-gray); }

/* Provider Specific Badges */
.badge-monetra { background: var(--color-teal-bg); color: var(--color-teal); }
.badge-syntax { background: var(--color-purple-bg); color: var(--color-purple); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-md);
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  font-size: 13px;
}

.btn-primary {
  background-color: var(--color-blue);
  color: white;
}
.btn-primary:hover {
  background-color: #1d4ed8;
}

.btn-secondary {
  background-color: var(--bg-surface);
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-secondary:hover {
  background-color: var(--bg-hover);
}

.btn-danger {
  background-color: var(--color-red);
  color: white;
}
.btn-danger:hover {
  background-color: #b91c1c;
}

.btn-sm {
  padding: 0.25rem 0.65rem;
  font-size: 12px;
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text-main);
}

.form-control {
  width: 100%;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  color: var(--text-main);
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Switch Toggle Component */
.switch-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--border-color);
  transition: .2s;
  border-radius: 22px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .2s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--color-blue);
}

input:checked + .slider:before {
  transform: translateX(18px);
}

/* Compact Summary Widget Cards */
.stat-card {
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.stat-val {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.1;
}

.stat-lbl {
  font-size: 12px;
  color: var(--text-muted);
}

/* CALENDAR STYLES (Google Calendar-like behavior & grid) */
.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.cal-nav-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cal-title-display {
  font-size: 18px;
  font-weight: 700;
  min-width: 160px;
}

.view-btn-group {
  display: flex;
  background: var(--bg-hover);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.view-btn {
  padding: 0.3rem 0.8rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.view-btn.active {
  background: var(--bg-surface);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

/* MONTH VIEW GRID (Full 7-Column Layout) */
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  overflow: hidden;
}

.month-header-cell {
  padding: 0.6rem 0.25rem;
  text-align: center;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
}
.month-header-cell:last-child {
  border-right: none;
}

.month-day-cell {
  min-height: 105px;
  padding: 0.4rem;
  border-bottom: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  background: var(--bg-surface);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  position: relative;
}

.month-day-cell:nth-child(7n) {
  border-right: none;
}

.month-day-cell:hover {
  background: var(--bg-hover);
}

.month-day-cell.muted {
  background: var(--bg-subtle);
  opacity: 0.5;
}

.month-day-num {
  font-size: 12px;
  font-weight: 600;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-main);
}

.month-day-cell.today .month-day-num {
  background: var(--color-blue);
  color: white;
}

.month-day-cell.selected {
  outline: 2px solid var(--color-blue);
  outline-offset: -2px;
  background: var(--color-blue-bg);
}

/* Event Pill inside Month Day Cell */
.event-pill {
  font-size: 11px;
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.event-pill-monetra {
  background: var(--color-teal-bg);
  color: var(--text-main);
  border-left: 3px solid var(--color-teal);
}

.event-pill-syntax {
  background: var(--color-purple-bg);
  color: var(--text-main);
  border-left: 3px solid var(--color-purple);
}

.event-pill-collision {
  background: var(--color-red-bg);
  color: var(--color-red);
  border: 1px solid var(--color-red);
  font-weight: 700;
}

.event-pill-gray {
  background: var(--color-gray-bg);
  color: var(--color-gray);
  border-left: 3px solid var(--color-gray);
  text-decoration: line-through;
}

.event-pill-hold {
  background: var(--color-amber-bg);
  color: var(--text-main);
  border: 1px dashed var(--color-amber);
}

/* WEEK & DAY VIEW GRID */
.week-day-grid {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  overflow-x: auto;
}

.day-view-grid {
  grid-template-columns: 60px 1fr !important;
}

.grid-time-col {
  background: var(--bg-subtle);
  border-right: 1px solid var(--border-color);
}

.time-slot-label {
  height: 52px;
  padding: 0.25rem;
  text-align: right;
  font-size: 11px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.grid-day-col {
  position: relative;
  min-height: 520px;
  border-right: 1px solid var(--border-color);
}
.grid-day-col:last-child {
  border-right: none;
}

.time-slot-bg {
  height: 52px;
  border-bottom: 1px solid var(--border-color);
}

/* Event Block inside Week/Day View */
.time-event-block {
  position: absolute;
  left: 3px; right: 3px;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 11px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  z-index: 10;
  transition: var(--transition);
  overflow: hidden;
}

.time-event-block:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* PROVIDER PORTAL STYLES */
.provider-banner {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.slot-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.slot-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
}

.slot-available { border-left: 4px solid var(--color-green); }
.slot-busy { border-left: 4px solid var(--color-gray); background: var(--bg-subtle); }
.slot-hold { border-left: 4px solid var(--color-amber); background: var(--color-amber-bg); }

/* MODAL DIALOGS */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.25rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
}

/* Accordion Component */
.accordion-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-top: 0.75rem;
  overflow: hidden;
}

.accordion-header {
  background: var(--bg-subtle);
  padding: 0.5rem 0.85rem;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.accordion-body {
  padding: 0.85rem;
  background: var(--bg-surface);
  display: none;
}

.accordion-item.open .accordion-body {
  display: block;
}

/* RESPONSIVE MEDIA QUERIES */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .main-wrapper {
    margin-left: 0;
  }
  .mobile-nav-toggle {
    display: block;
  }
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }
  .month-grid {
    overflow-x: auto;
  }
  .week-day-grid {
    grid-template-columns: 45px repeat(7, 120px);
  }
}

/* Current day highlight */
.month-header-cell.today-header {
  background: var(--color-blue-bg);
  color: var(--color-blue);
  font-weight: 700;
  box-shadow: inset 0 -2px 0 var(--color-blue);
}

.grid-day-col.today-column {
  background: var(--color-blue-bg);
}

.today-label {
  display: block;
  margin-top: 2px;
  font-size: 9px;
  font-weight: 700;
  color: var(--color-blue);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Owner management additions */
.muted { color: var(--text-muted); font-size: 12px; line-height: 1.5; }
.compact-details { display:grid; grid-template-columns:minmax(110px, .8fr) 1.2fr; gap:.55rem .8rem; font-size:13px; }
.compact-details dt { color:var(--text-muted); }
.compact-details dd { margin:0; font-weight:600; overflow-wrap:anywhere; }
.permission-row { display:grid; grid-template-columns:24px 1fr auto; gap:.5rem; align-items:center; padding:.65rem 0; border-bottom:1px solid var(--border-color); font-size:13px; }
.permission-row small { color:var(--text-muted); }
.table-wrap { overflow-x:auto; }
.empty-state { padding:2rem 1rem; text-align:center; color:var(--text-muted); }
@media (max-width: 768px) {
  .month-grid { display:block !important; border:0; background:transparent; overflow:visible; }
  .month-header-cell { display:none; }
  .month-day-cell { min-height:0; padding:.65rem; margin-bottom:.5rem; border:1px solid var(--border-color); border-radius:var(--radius-sm); flex-direction:row; align-items:flex-start; flex-wrap:wrap; gap:.45rem; }
  .month-day-cell.muted { display:none; }
  .month-day-num { flex:0 0 22px; }
  .event-pill { flex:1 1 calc(100% - 30px); min-width:0; white-space:normal; }
  .permission-row { grid-template-columns:24px 1fr; }
  .permission-row small { grid-column:2; }
}
