/* ============================================================
   MED OFFICE 365 — Custom Launcher
   Adapted for Corteza 2024.9 actual DOM structure

   One app (root /):
     .app-selector → container
     .card.app     → each app card
     .thumbnail    → app logo
     h6            → app name

   Compose (/compose/namespaces/):
     .ns-wrapper      → container
     .namespace-item   → each card
     .circled-avatar   → logo circle
     h5                → namespace name
   ============================================================ */

/* ── LAYOUT SWITCHER BUTTON (always visible) ── */
#mo365-switcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 6px;
  background: #111;
  border: none;
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  transition: background 0.15s;
}
#mo365-switcher:hover { background: #333; }
#mo365-switcher span {
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  font-family: 'Lexend', sans-serif;
  letter-spacing: 0.3px;
}
#mo365-switcher-icon { color: #fff; font-size: 14px; }

/* ── LAYOUT PICKER MODAL ── */
#mo365-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 10000;
  align-items: center;
  justify-content: center;
}
#mo365-modal-overlay.open { display: flex; }
#mo365-modal {
  background: #fff;
  border-radius: 16px;
  padding: 28px 28px 24px;
  width: 480px;
  max-width: 96vw;
  box-shadow: 0 24px 64px rgba(0,0,0,0.2);
}
#mo365-modal h3 {
  font-size: 15px; font-weight: 600; color: #111;
  margin: 0 0 4px; font-family: 'Lexend', sans-serif;
}
#mo365-modal p {
  font-size: 12px; color: #9ca3af;
  margin: 0 0 20px; font-family: 'Lexend', sans-serif;
}
.mo365-layout-options {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; margin-bottom: 20px;
}
.mo365-layout-card {
  border: 1.5px solid #e5e7eb; border-radius: 10px;
  padding: 14px 12px; cursor: pointer;
  transition: all 0.15s; text-align: center;
  font-family: 'Lexend', sans-serif;
}
.mo365-layout-card:hover { border-color: #111; background: #f9f9f9; }
.mo365-layout-card.active { border-color: #111; background: #111; }
.mo365-layout-card.active .lc-name { color: #fff; }
.mo365-layout-card.active .lc-desc { color: #9ca3af; }
.mo365-layout-card.active .lc-icon { color: #fff; }
.lc-icon { font-size: 20px; margin-bottom: 8px; line-height: 1; }
.lc-name { font-size: 12px; font-weight: 600; color: #111; margin-bottom: 2px; }
.lc-desc { font-size: 10px; color: #9ca3af; line-height: 1.4; }
#mo365-modal-close {
  width: 100%; padding: 10px; background: transparent;
  border: 1px solid #e5e7eb; border-radius: 8px;
  font-size: 13px; font-weight: 500; color: #6b7280;
  cursor: pointer; font-family: 'Lexend', sans-serif;
  transition: all 0.1s;
}
#mo365-modal-close:hover { border-color: #111; color: #111; }

/* ── WELCOME HEADER ── */
#mo365-welcome {
  font-family: 'Lexend', sans-serif;
  border-bottom: 1px solid #e5e7eb;
  padding: 20px 32px 16px;
  display: flex; align-items: baseline;
  justify-content: space-between;
  background: #fff;
}
#mo365-welcome h2 {
  font-size: 22px; font-weight: 700; color: #111;
  letter-spacing: -0.5px; margin: 0 0 2px;
}
#mo365-welcome p { font-size: 12px; color: #9ca3af; margin: 0; }
#mo365-welcome-meta { text-align: right; }
#mo365-welcome-meta .user-name { font-size: 13px; font-weight: 500; color: #374151; }
#mo365-welcome-meta .user-role { font-size: 11px; color: #9ca3af; }

/* ── B: DATELINE ── */
#mo365-dateline {
  font-size: 10px; font-weight: 700; color: #9ca3af;
  letter-spacing: 1.5px; text-transform: uppercase;
  padding: 8px 32px; border-bottom: 1px solid #e5e7eb;
  background: #fff; font-family: 'Lexend', sans-serif;
}

/* ============================================================
   LAYOUT A — COMMAND PALETTE
   ============================================================ */
body[data-layout="a"] .app-selector .container,
body[data-layout="a"] .ns-wrapper {
  max-width: 600px !important;
  margin: 0 auto !important;
}
body[data-layout="a"] .app-selector .row,
body[data-layout="a"] .ns-wrapper .row {
  display: flex !important;
  flex-direction: column !important;
  gap: 0 !important;
}

body[data-layout="a"] #mo365-cmd-wrapper {
  max-width: 600px; margin: 0 auto 32px;
  border: 1.5px solid #111; border-radius: 12px;
  overflow: hidden; background: #fff;
}
body[data-layout="a"] #mo365-cmd-search {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid #e5e7eb;
}
body[data-layout="a"] #mo365-cmd-search input {
  flex: 1; border: none; outline: none;
  font-size: 14px; font-family: 'Lexend', sans-serif;
  color: #111; background: transparent;
}
body[data-layout="a"] #mo365-cmd-search input::placeholder { color: #9ca3af; }
body[data-layout="a"] #mo365-cmd-kbd {
  font-size: 10px; color: #9ca3af; background: #f3f4f6;
  border: 1px solid #e5e7eb; border-radius: 5px;
  padding: 2px 7px; font-family: 'Lexend', sans-serif;
}
body[data-layout="a"] #mo365-cmd-section {
  font-size: 10px; font-weight: 600; color: #9ca3af;
  letter-spacing: 1.2px; text-transform: uppercase;
  padding: 10px 14px 4px;
}

/* Cards in layout A: compact rows */
body[data-layout="a"] .app-selector .col-12 {
  max-width: 100% !important; flex: none !important;
  padding: 0 !important;
}
body[data-layout="a"] .card.app,
body[data-layout="a"] .namespace-item {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 12px !important;
  padding: 9px 14px !important;
  margin: 0 8px !important;
  border-radius: 7px !important;
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
  min-height: auto !important;
}
body[data-layout="a"] .card.app:hover,
body[data-layout="a"] .namespace-item:hover {
  background: #f3f4f6 !important;
  transform: none !important;
}
body[data-layout="a"] .card.app .thumbnail,
body[data-layout="a"] .namespace-item .circled-avatar {
  width: 30px !important; height: 30px !important;
  min-width: 30px !important; border-radius: 7px !important;
  border: 1px solid #e5e7eb !important;
  background: #f3f4f6 !important;
  margin: 0 !important; padding: 2px !important;
}
body[data-layout="a"] .card.app h6,
body[data-layout="a"] .namespace-item h5 {
  font-size: 13px !important; font-weight: 500 !important;
  color: #111 !important; margin: 0 !important;
  text-align: left !important;
}
body[data-layout="a"] .card.app .align-content-center {
  flex-grow: 0 !important;
}

/* ============================================================
   LAYOUT B — EDITORIAL / NEWSPAPER
   ============================================================ */
body[data-layout="b"] .app-selector .container,
body[data-layout="b"] .ns-wrapper {
  max-width: 1100px !important;
  margin: 0 auto !important;
}
body[data-layout="b"] .app-selector .row,
body[data-layout="b"] .ns-wrapper .row {
  display: grid !important;
  grid-template-columns: 2fr 1fr !important;
  gap: 32px !important;
  align-items: start !important;
}

/* First item = featured big card */
body[data-layout="b"] .app-selector .col-12:first-child,
body[data-layout="b"] .ns-wrapper .col-12:first-child {
  grid-column: 1 !important;
  grid-row: 1 / 3 !important;
  max-width: 100% !important;
  flex: none !important;
}
body[data-layout="b"] .app-selector .col-12:first-child .card.app,
body[data-layout="b"] .ns-wrapper .col-12:first-child .namespace-item {
  padding: 28px !important;
  border: 1.5px solid #111 !important;
  border-radius: 14px !important;
  min-height: 280px !important;
}
body[data-layout="b"] .app-selector .col-12:first-child .card.app:hover,
body[data-layout="b"] .ns-wrapper .col-12:first-child .namespace-item:hover {
  background: #f9f9f9 !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.07) !important;
}
body[data-layout="b"] .app-selector .col-12:first-child h6,
body[data-layout="b"] .ns-wrapper .col-12:first-child h5 {
  font-size: 22px !important; font-weight: 700 !important;
  letter-spacing: -0.5px !important;
}
body[data-layout="b"] .app-selector .col-12:first-child .thumbnail,
body[data-layout="b"] .ns-wrapper .col-12:first-child .circled-avatar {
  width: 52px !important; height: 52px !important;
  border-radius: 12px !important; margin-bottom: 16px !important;
}

/* Rest = compact list rows */
body[data-layout="b"] .app-selector .col-12:not(:first-child),
body[data-layout="b"] .ns-wrapper .col-12:not(:first-child) {
  max-width: 100% !important; flex: none !important;
  padding: 0 !important;
}
body[data-layout="b"] .app-selector .col-12:not(:first-child) .card.app,
body[data-layout="b"] .ns-wrapper .col-12:not(:first-child) .namespace-item {
  display: flex !important; flex-direction: row !important;
  align-items: center !important; gap: 12px !important;
  padding: 11px 0 !important; border: none !important;
  border-bottom: 1px solid #f3f4f6 !important;
  border-radius: 0 !important; background: transparent !important;
  box-shadow: none !important; min-height: auto !important;
}
body[data-layout="b"] .app-selector .col-12:not(:first-child) .card.app:hover h6,
body[data-layout="b"] .ns-wrapper .col-12:not(:first-child) .namespace-item:hover h5 {
  text-decoration: underline !important;
}
body[data-layout="b"] .app-selector .col-12:not(:first-child) .thumbnail,
body[data-layout="b"] .ns-wrapper .col-12:not(:first-child) .circled-avatar {
  width: 30px !important; height: 30px !important;
  border-radius: 7px !important; margin: 0 !important;
}
body[data-layout="b"] .app-selector .col-12:not(:first-child) h6,
body[data-layout="b"] .ns-wrapper .col-12:not(:first-child) h5 {
  font-size: 13px !important; font-weight: 500 !important;
  margin: 0 !important; text-align: left !important;
}
body[data-layout="b"] .app-selector .col-12:not(:first-child) .card.app .align-content-center {
  flex-grow: 0 !important;
}

/* ============================================================
   LAYOUT C — DASHBOARD-FIRST
   ============================================================ */
body[data-layout="c"] .app-selector .container,
body[data-layout="c"] .ns-wrapper {
  max-width: 900px !important;
  margin: 0 auto !important;
}
body[data-layout="c"] .app-selector .row,
body[data-layout="c"] .ns-wrapper .row {
  display: grid !important;
  grid-template-columns: repeat(3, 1fr) !important;
  gap: 10px !important;
}
body[data-layout="c"] .app-selector .col-12,
body[data-layout="c"] .ns-wrapper .col-12 {
  max-width: 100% !important; flex: none !important;
  padding: 5px !important;
}
body[data-layout="c"] .card.app,
body[data-layout="c"] .namespace-item {
  display: flex !important; flex-direction: row !important;
  align-items: center !important; gap: 12px !important;
  padding: 14px !important; background: #fff !important;
  border: 1px solid #e5e7eb !important;
  border-radius: 10px !important; box-shadow: none !important;
  min-height: auto !important;
}
body[data-layout="c"] .card.app:hover,
body[data-layout="c"] .namespace-item:hover {
  border-color: #111 !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06) !important;
}
body[data-layout="c"] .card.app .thumbnail,
body[data-layout="c"] .namespace-item .circled-avatar {
  width: 32px !important; height: 32px !important;
  border-radius: 8px !important; background: #f3f4f6 !important;
  border: 1px solid #e5e7eb !important; flex-shrink: 0 !important;
  margin: 0 !important; padding: 2px !important;
}
body[data-layout="c"] .card.app h6,
body[data-layout="c"] .namespace-item h5 {
  font-size: 12px !important; font-weight: 600 !important;
  color: #111 !important; margin: 0 !important;
  text-align: left !important;
}
body[data-layout="c"] .card.app .align-content-center {
  flex-grow: 0 !important;
}

/* C: KPI bar */
#mo365-kpi-bar {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; max-width: 900px; margin: 0 auto;
  padding: 0 32px 20px; font-family: 'Lexend', sans-serif;
}
.mo365-kpi-card {
  background: #fff; border: 1px solid #e5e7eb;
  border-radius: 10px; padding: 14px 16px;
}
.mo365-kpi-label {
  font-size: 10px; font-weight: 600; color: #9ca3af;
  letter-spacing: 0.5px; margin-bottom: 6px; text-transform: uppercase;
}
.mo365-kpi-val {
  font-size: 24px; font-weight: 700; color: #111;
  letter-spacing: -1px; margin-bottom: 2px;
}
.mo365-kpi-delta { font-size: 11px; color: #16a34a; font-weight: 500; }
.mo365-kpi-delta.down { color: #dc2626; }

/* ── HIDE original Corteza logo when welcome bar exists ── */
body[data-layout] .app-selector > .d-flex:first-child .logo {
  display: none !important;
}
