/* ── MS Client Portal — Customer Dashboard ───────────────────────── */
:root {
  --mscp-orange:   #ED804B;
  --mscp-blue:     #19639A;
  --mscp-dark:     #0F172A;
  --mscp-dark2:    #1E293B;
  --mscp-sidebar-w: 260px;
  --mscp-topbar-h:  64px;
  --mscp-gray50:   #F8FAFC;
  --mscp-gray100:  #F1F5F9;
  --mscp-gray200:  #E2E8F0;
  --mscp-gray300:  #CBD5E1;
  --mscp-gray400:  #94A3B8;
  --mscp-gray500:  #64748B;
  --mscp-gray700:  #334155;
  --mscp-gray900:  #0F172A;
  --mscp-white:    #FFFFFF;
  --mscp-green:    #22C55E;
  --mscp-yellow:   #F59E0B;
  --mscp-red:      #EF4444;
  --mscp-radius:   14px;
  --mscp-radius-sm:8px;
  --mscp-shadow:   0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.06);
  --mscp-shadow-md:0 4px 16px rgba(0,0,0,.1);
}

/* ── Reset inside dashboard ──────────────────────────────────────── */
.mscp-dashboard-wrap * { box-sizing: border-box; }

/* ── Wrapper ─────────────────────────────────────────────────────── */
.mscp-dashboard-wrap {
  display: flex;
  min-height: 100vh;
  background: var(--mscp-gray100);
  font-family: inherit;
}

/* ── Sidebar ─────────────────────────────────────────────────────── */
.mscp-sidebar {
  width: var(--mscp-sidebar-w);
  min-height: 100vh;
  background: var(--mscp-dark);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
  z-index: 100;
  transition: transform .3s ease;
}

.mscp-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.mscp-sidebar-logo { display: flex; align-items: center; text-decoration: none; }
.mscp-logo-img    { height: 30px; width: auto; }
.mscp-logo-text   { color: var(--mscp-white); font-size: 17px; font-weight: 700; letter-spacing: .3px; }

.mscp-sidebar-toggle {
  display: none;
  border: none; background: rgba(255,255,255,.1);
  color: var(--mscp-white); border-radius: 8px;
  width: 32px; height: 32px;
  align-items: center; justify-content: center;
  cursor: pointer;
}

/* User block */
.mscp-user-block {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.mscp-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
}
.mscp-avatar-img {
  width: 100%; height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,.15);
}
.mscp-avatar-initials {
  position: absolute; inset: 0;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--mscp-orange);
  color: white; font-weight: 700; font-size: 16px;
  /* shown only if image fails */
  opacity: 0;
}

.mscp-user-info { min-width: 0; }
.mscp-user-info strong {
  display: block;
  color: var(--mscp-white);
  font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mscp-user-info span {
  display: block;
  color: var(--mscp-gray400);
  font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Nav */
.mscp-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mscp-nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  border-radius: 10px;
  color: rgba(255,255,255,.6);
  text-decoration: none;
  font-size: 14px; font-weight: 500;
  transition: background .18s, color .18s;
  position: relative;
}
.mscp-nav-item:hover {
  background: rgba(255,255,255,.07);
  color: var(--mscp-white);
}
.mscp-nav-item.active {
  background: var(--mscp-orange);
  color: var(--mscp-white);
  font-weight: 600;
}
.mscp-nav-item svg { flex-shrink: 0; }

.mscp-nav-badge {
  margin-left: auto;
  background: var(--mscp-yellow);
  color: var(--mscp-dark);
  font-size: 11px; font-weight: 700;
  min-width: 20px; height: 20px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
}

/* Sidebar footer */
.mscp-sidebar-footer {
  padding: 10px 10px 20px;
  border-top: 1px solid rgba(255,255,255,.07);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mscp-logout-link { color: rgba(239,68,68,.75) !important; }
.mscp-logout-link:hover { background: rgba(239,68,68,.12) !important; color: #EF4444 !important; }

/* ── Main area ───────────────────────────────────────────────────── */
.mscp-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Topbar */
.mscp-topbar {
  position: sticky; top: 0; z-index: 90;
  height: var(--mscp-topbar-h);
  background: var(--mscp-white);
  border-bottom: 1px solid var(--mscp-gray200);
  display: flex; align-items: center;
  padding: 0 28px;
  gap: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.mscp-menu-toggle {
  display: none;
  border: none; background: none;
  color: var(--mscp-gray700); cursor: pointer;
  padding: 6px; border-radius: 8px;
}
.mscp-menu-toggle:hover { background: var(--mscp-gray100); }

.mscp-topbar-title {
  font-size: 17px; font-weight: 700; color: var(--mscp-dark);
}
.mscp-topbar-right {
  margin-left: auto;
  display: flex; align-items: center; gap: 12px;
}
.mscp-topbar-greeting {
  font-size: 13px; color: var(--mscp-gray500);
}
.mscp-topbar-avatar {
  width: 36px; height: 36px; border-radius: 50%; overflow: hidden;
  border: 2px solid var(--mscp-gray200);
}
.mscp-topbar-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Content area */
.mscp-content {
  flex: 1;
  padding: 28px;
  max-width: 1100px;
  width: 100%;
}

/* Section header */
.mscp-section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.mscp-section-title {
  font-size: 20px; font-weight: 700; color: var(--mscp-dark);
  margin: 0;
}

/* ── Stat cards grid ─────────────────────────────────────────────── */
.mscp-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.mscp-stat-card {
  background: var(--mscp-white);
  border-radius: var(--mscp-radius);
  padding: 20px;
  display: flex; align-items: center; gap: 16px;
  box-shadow: var(--mscp-shadow);
  border-left: 3px solid var(--accent, var(--mscp-orange));
}
.mscp-stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.mscp-stat-body { min-width: 0; }
.mscp-stat-value {
  display: block;
  font-size: 24px; font-weight: 800; color: var(--mscp-dark);
  line-height: 1;
}
.mscp-stat-value .woocommerce-Price-amount { font-size: inherit; }
.mscp-stat-label {
  display: block;
  font-size: 12px; font-weight: 500; color: var(--mscp-gray500);
  margin-top: 4px;
}

/* ── Cards ───────────────────────────────────────────────────────── */
.mscp-card {
  background: var(--mscp-white);
  border-radius: var(--mscp-radius);
  box-shadow: var(--mscp-shadow);
  padding: 24px;
  margin-bottom: 20px;
}
.mscp-card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.mscp-card-title {
  font-size: 16px; font-weight: 700; color: var(--mscp-dark);
  margin: 0;
}
.mscp-card-subtitle {
  font-size: 15px; font-weight: 700; color: var(--mscp-dark);
  margin: 0 0 16px;
}
.mscp-card-link {
  font-size: 13px; font-weight: 600; color: var(--mscp-orange);
  text-decoration: none;
}
.mscp-card-link:hover { text-decoration: underline; }

/* ── Table ───────────────────────────────────────────────────────── */
.mscp-orders-table-wrap { overflow-x: auto; }
.mscp-table {
  width: 100%; border-collapse: collapse;
  font-size: 14px;
}
.mscp-table th {
  text-align: left; padding: 0 12px 12px;
  font-size: 11px; font-weight: 700; color: var(--mscp-gray500);
  text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 1px solid var(--mscp-gray200);
}
.mscp-table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--mscp-gray100);
  color: var(--mscp-gray700);
  vertical-align: middle;
}
.mscp-table tr:last-child td { border-bottom: none; }
.mscp-table tr:hover td { background: var(--mscp-gray50); }

.mscp-order-link {
  color: var(--mscp-blue); font-weight: 600; text-decoration: none;
}
.mscp-order-link:hover { text-decoration: underline; }

.mscp-status-dot {
  display: inline-block;
  width: 8px; height: 8px; border-radius: 50%;
  margin-right: 6px; vertical-align: middle;
}

/* ── Quick links ─────────────────────────────────────────────────── */
.mscp-quick-links {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
.mscp-quick-link {
  background: var(--mscp-white);
  border-radius: var(--mscp-radius);
  box-shadow: var(--mscp-shadow);
  padding: 18px 16px;
  display: flex; align-items: center; gap: 12px;
  text-decoration: none;
  color: var(--mscp-gray700);
  font-size: 14px; font-weight: 600;
  transition: box-shadow .2s, transform .15s;
  border: 1.5px solid transparent;
}
.mscp-quick-link:hover {
  box-shadow: var(--mscp-shadow-md);
  border-color: var(--mscp-orange);
  color: var(--mscp-orange);
  transform: translateY(-2px);
}
.mscp-quick-link svg { color: var(--mscp-orange); flex-shrink: 0; }

/* ── Empty state ─────────────────────────────────────────────────── */
.mscp-empty-state {
  text-align: center; padding: 40px 20px;
  color: var(--mscp-gray400);
}
.mscp-empty-state svg { display: block; margin: 0 auto 14px; opacity: .5; }
.mscp-empty-state p { font-size: 14px; margin: 0; }
.mscp-empty-state a { color: var(--mscp-orange); font-weight: 600; }

/* ── Badges ──────────────────────────────────────────────────────── */
.mscp-badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
  white-space: nowrap;
}
.mscp-badge-orange  { background: #FEF3EC; color: #C05221; }
.mscp-badge-blue    { background: #EFF6FF; color: #1D4ED8; }
.mscp-badge-green   { background: #F0FDF4; color: #166534; }
.mscp-badge-gray    { background: #F1F5F9; color: #475569; }
.mscp-badge-active  { background: #F0FDF4; color: #166534; }
.mscp-badge-pending { background: #FFFBEB; color: #92400E; }
.mscp-badge-cancelled { background: #FEF2F2; color: #991B1B; }

/* ── Tickets ─────────────────────────────────────────────────────── */
.mscp-tickets-list { display: flex; flex-direction: column; gap: 12px; }
.mscp-ticket-card {
  background: var(--mscp-white);
  border: 1.5px solid var(--mscp-gray200);
  border-radius: var(--mscp-radius);
  padding: 18px 20px;
  transition: border-color .2s, box-shadow .2s;
}
.mscp-ticket-card:hover {
  border-color: var(--mscp-orange);
  box-shadow: 0 4px 12px rgba(237,128,75,.1);
}
.mscp-ticket-top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 8px;
}
.mscp-ticket-subject { font-weight: 600; color: var(--mscp-dark); font-size: 15px; }
.mscp-ticket-preview { font-size: 13px; color: var(--mscp-gray500); margin: 0 0 8px; }
.mscp-ticket-reply {
  background: var(--mscp-gray50);
  border-left: 3px solid var(--mscp-blue);
  padding: 10px 14px; border-radius: 0 8px 8px 0;
  margin-bottom: 8px;
}
.mscp-ticket-reply strong { font-size: 12px; color: var(--mscp-blue); }
.mscp-ticket-reply p { font-size: 13px; color: var(--mscp-gray700); margin: 4px 0 0; }
.mscp-ticket-date { font-size: 11px; color: var(--mscp-gray400); }

/* ── Subscriptions ───────────────────────────────────────────────── */
.mscp-sub-card {
  background: var(--mscp-white);
  border: 1.5px solid var(--mscp-gray200);
  border-radius: var(--mscp-radius);
  padding: 18px 20px; margin-bottom: 12px;
}
.mscp-sub-top {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.mscp-sub-name { font-weight: 600; color: var(--mscp-dark); }
.mscp-sub-meta { font-size: 13px; color: var(--mscp-gray500); }
.mscp-sub-placeholder {
  text-align: center;
}
.mscp-sub-placeholder-inner {
  padding: 32px 20px;
}
.mscp-sub-placeholder-inner svg {
  display: block; margin: 0 auto 16px;
}
.mscp-sub-placeholder-inner h3 {
  font-size: 18px; font-weight: 700; color: var(--mscp-dark); margin: 0 0 8px;
}
.mscp-sub-placeholder-inner p {
  font-size: 14px; color: var(--mscp-gray500); margin: 0 0 20px; max-width: 420px; margin-left: auto; margin-right: auto;
}

/* ── Form fields ─────────────────────────────────────────────────── */
.mscp-field { margin-bottom: 16px; }
.mscp-field label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--mscp-dark); margin-bottom: 6px;
}
.mscp-input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--mscp-gray200);
  border-radius: 9px;
  font-size: 14px; color: var(--mscp-dark);
  background: var(--mscp-white);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  font-family: inherit;
}
.mscp-input:focus {
  border-color: var(--mscp-orange);
  box-shadow: 0 0 0 3px rgba(237,128,75,.12);
}
.mscp-textarea { resize: vertical; min-height: 120px; }

/* Message result box */
.mscp-msg {
  display: none; padding: 12px 14px; border-radius: 8px;
  font-size: 13px; margin-bottom: 16px;
}
.mscp-msg.error   { display: block; background: #FEF2F2; color: #B91C1C; border: 1px solid #FECACA; }
.mscp-msg.success { display: block; background: #F0FDF4; color: #166534; border: 1px solid #BBF7D0; }

/* ── Buttons ─────────────────────────────────────────────────────── */
.mscp-btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 20px;
  background: var(--mscp-orange); color: var(--mscp-white);
  border: none; border-radius: 9px;
  font-size: 14px; font-weight: 700; cursor: pointer;
  text-decoration: none;
  transition: background .2s, box-shadow .2s, transform .1s;
  box-shadow: 0 3px 10px rgba(237,128,75,.35);
}
.mscp-btn-primary:hover {
  background: #d96e38;
  box-shadow: 0 5px 16px rgba(237,128,75,.5);
  color: var(--mscp-white);
}
.mscp-btn-primary:active { transform: translateY(1px); }
.mscp-btn-primary:disabled { opacity: .6; pointer-events: none; }
.mscp-btn-primary.loading .mscp-btn-text { opacity: 0; position: absolute; }
.mscp-btn-primary.loading .mscp-spinner { display: block; }

.mscp-btn-outline {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 20px;
  background: transparent; color: var(--mscp-gray700);
  border: 1.5px solid var(--mscp-gray200);
  border-radius: 9px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: border-color .2s, color .2s;
}
.mscp-btn-outline:hover { border-color: var(--mscp-gray400); color: var(--mscp-dark); }

.mscp-spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: white; border-radius: 50%;
  animation: mscp-spin .7s linear infinite; display: none;
}
@keyframes mscp-spin { to { transform: rotate(360deg); } }

/* ── New ticket form ─────────────────────────────────────────────── */
.mscp-new-ticket-form { margin-bottom: 20px; }

/* ── Mobile overlay ──────────────────────────────────────────────── */
.mscp-mob-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 99;
  background: rgba(15,23,42,.55);
  backdrop-filter: blur(4px);
}
.mscp-mob-overlay.open { display: block; }

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .mscp-stats-grid      { grid-template-columns: repeat(2, 1fr); }
  .mscp-quick-links     { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  /* Sidebar becomes a drawer on mobile */
  .mscp-sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    box-shadow: var(--mscp-shadow-md);
  }
  .mscp-sidebar.open  { transform: translateX(0); }
  .mscp-sidebar-toggle { display: flex; }

  .mscp-menu-toggle { display: flex; }
  .mscp-topbar      { padding: 0 16px; }
  .mscp-topbar-greeting { display: none; }
  .mscp-content     { padding: 16px; }

  .mscp-stats-grid  { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .mscp-quick-links { grid-template-columns: 1fr 1fr; gap: 10px; }
}

@media (max-width: 480px) {
  .mscp-stats-grid  { grid-template-columns: 1fr 1fr; }
  .mscp-quick-links { grid-template-columns: 1fr 1fr; }
}

/* ── WooCommerce My Account nav override — hide default nav ──────── */
.woocommerce-account .woocommerce-MyAccount-navigation { display: none !important; }
.woocommerce-account .woocommerce-MyAccount-content    { padding: 0 !important; background: none !important; border: none !important; }
.woocommerce-account .woocommerce { max-width: 100% !important; padding: 0 !important; }
.woocommerce-account .woocommerce-notices-wrapper { padding: 0 28px; }

/* Profile page (edit-account) */
.woocommerce-account .woocommerce-MyAccount-content .woocommerce-EditAccountForm {
  background: var(--mscp-white); border-radius: var(--mscp-radius);
  box-shadow: var(--mscp-shadow); padding: 28px;
}
.woocommerce-account .woocommerce-MyAccount-content .woocommerce-EditAccountForm fieldset {
  border: 1.5px solid var(--mscp-gray200); border-radius: 10px;
  padding: 20px; margin: 20px 0 10px;
}
.woocommerce-account .woocommerce-MyAccount-content .woocommerce-EditAccountForm fieldset legend {
  font-weight: 700; color: var(--mscp-dark); padding: 0 8px;
}

/* ── Theme container breakout ────────────────────────────────────────
   The active theme renders the account page inside a narrow wrapper
   (e.g. <main class="ms-fallback"> with max-width:760px), which squeezed
   the 260px sidebar + content into ~720px total. Let the dashboard use
   the full page width on account pages only.                          */
body.woocommerce-account main,
body.woocommerce-account .site-main,
body.woocommerce-account .ms-fallback,
body.woocommerce-account article.page,
body.woocommerce-account .woocommerce,
body.woocommerce-account .entry-content {
  max-width: none !important;
  width: 100% !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* The dashboard prints its own "Overview" heading, so the theme's
   duplicate page title above it is redundant. */
body.woocommerce-account .entry-title,
body.woocommerce-account .page-title,
body.woocommerce-account .woocommerce-products-header__title {
  display: none !important;
}

/* ── Sidebar logo ────────────────────────────────────────────────────
   Theme/WooCommerce image rules (img{width:100%;height:auto}) beat the
   plain .mscp-logo-img rule and rendered the 1080x1080 logo at 220x220,
   filling the whole sidebar. Pin it down with matching specificity.   */
.mscp-dashboard-wrap .mscp-sidebar .mscp-sidebar-logo {
  display: flex !important;
  align-items: center !important;
  gap: 10px;
  min-height: 0 !important;
}
.mscp-dashboard-wrap .mscp-sidebar img.mscp-logo-img,
.mscp-dashboard-wrap .mscp-sidebar .mscp-sidebar-logo img {
  height: 32px !important;
  width: auto !important;
  max-width: 150px !important;
  max-height: 32px !important;
  object-fit: contain !important;
  aspect-ratio: auto !important;
}
