/* ==========================================================
   PORTAL — SaaS Dashboard for Stillwater Wellness
   Aesthetic: Clean, data-dense, Linear/Stripe inspired
   ========================================================== */

/* --- Portal Layout --- */
.portal {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
  background: #f5f5f7;
}

/* --- Sidebar --- */
.portal-sidebar {
  background: var(--primary-dark);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.portal-sidebar-header {
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.portal-sidebar-header .portal-brand {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 500;
  color: #fff;
  text-decoration: none;
  display: block;
  margin-bottom: 0.25rem;
}

.portal-sidebar-header .portal-brand span {
  color: var(--secondary);
  font-weight: 300;
}

.portal-sidebar-header .portal-env {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--secondary);
  background: rgba(201,168,108,0.12);
  padding: 2px 8px;
  border-radius: 3px;
  display: inline-block;
}

.portal-nav {
  flex: 1;
  padding: 1rem 0;
}

.portal-nav-group {
  margin-bottom: 1.5rem;
}

.portal-nav-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  padding: 0 1.25rem;
  margin-bottom: 0.5rem;
}

.portal-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1.25rem;
  font-size: 13px;
  font-weight: 400;
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  transition: all 0.15s ease;
  border-left: 2px solid transparent;
  cursor: pointer;
}

.portal-nav-item:hover {
  color: #fff;
  background: rgba(255,255,255,0.04);
}

.portal-nav-item.active {
  color: #fff;
  background: rgba(255,255,255,0.06);
  border-left-color: var(--secondary);
}

.portal-nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

.portal-nav-item.active svg {
  opacity: 1;
  color: var(--secondary);
}

.portal-nav-badge {
  margin-left: auto;
  background: var(--secondary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.portal-sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.portal-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.portal-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--secondary), var(--secondary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.portal-user-info {
  min-width: 0;
}

.portal-user-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-user-role {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
}

/* --- Main Content Area --- */
.portal-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Top Bar */
.portal-topbar {
  background: #fff;
  border-bottom: 1px solid #e8e8ec;
  padding: 0.875rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.portal-topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.portal-topbar h1 {
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-dark);
  letter-spacing: -0.01em;
}

.portal-topbar-date {
  font-size: 13px;
  color: var(--text-muted);
}

.portal-topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.portal-topbar-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid #e8e8ec;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  background: #fff;
  position: relative;
}

.portal-topbar-btn:hover {
  border-color: var(--secondary);
  color: var(--secondary);
}

.notification-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ef4444;
  border: 1.5px solid #fff;
}

.portal-back-link {
  font-size: 13px;
  color: var(--secondary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-weight: 500;
}

.portal-back-link:hover {
  color: var(--secondary-dark);
}

/* Content */
.portal-content {
  padding: 1.75rem 2rem;
  flex: 1;
}

/* --- Stats Cards --- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 1.25rem;
  border: 1px solid #e8e8ec;
}

.stat-card-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.stat-card-label svg {
  width: 14px;
  height: 14px;
  color: var(--secondary);
}

.stat-card-value {
  font-family: var(--font-body);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-dark);
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 0.375rem;
}

.stat-card-change {
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.stat-card-change.up { color: #16a34a; }
.stat-card-change.down { color: #dc2626; }

/* --- Section Panels --- */
.portal-panel {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e8e8ec;
  margin-bottom: 1.25rem;
}

.portal-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #f0f0f3;
}

.portal-panel-title {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dark);
}

.portal-panel-action {
  font-size: 12px;
  font-weight: 500;
  color: var(--secondary);
  cursor: pointer;
  text-decoration: none;
}

.portal-panel-action:hover {
  color: var(--secondary-dark);
}

.portal-panel-body {
  padding: 1.25rem;
}

/* --- Data Tables --- */
.portal-table {
  width: 100%;
  border-collapse: collapse;
}

.portal-table th {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: left;
  padding: 0.625rem 1rem;
  border-bottom: 1px solid #f0f0f3;
  background: #fafafa;
}

.portal-table td {
  font-size: 13px;
  color: var(--text-dark);
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f5f5f7;
  vertical-align: middle;
}

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

.portal-table tr:hover td {
  background: #fafafa;
}

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 2px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-green { background: #dcfce7; color: #16a34a; }
.badge-yellow { background: #fef9c3; color: #a16207; }
.badge-red { background: #fee2e2; color: #dc2626; }
.badge-blue { background: #dbeafe; color: #2563eb; }
.badge-gray { background: #f3f4f6; color: #6b7280; }

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* --- Insights Card --- */
.insight-card {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  padding: 1rem;
  border-radius: 10px;
  background: #fafafa;
  margin-bottom: 0.75rem;
  border: 1px solid #f0f0f3;
}

.insight-card:last-child {
  margin-bottom: 0;
}

.insight-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.insight-icon.green { background: #dcfce7; color: #16a34a; }
.insight-icon.blue { background: #dbeafe; color: #2563eb; }
.insight-icon.gold { background: rgba(201,168,108,0.12); color: var(--secondary); }

.insight-text {
  font-size: 13px;
  color: var(--text-dark);
  line-height: 1.5;
}

.insight-text strong {
  font-weight: 600;
}

.insight-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* --- Grid Layouts --- */
.portal-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.portal-grid-3-1 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.25rem;
}

/* --- Timeline / Schedule --- */
.schedule-item {
  display: flex;
  gap: 1rem;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid #f5f5f7;
  transition: background 0.15s ease;
  cursor: pointer;
}

.schedule-item:hover {
  background: #fafafa;
}

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

.schedule-time {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  min-width: 72px;
  flex-shrink: 0;
}

.schedule-details {
  flex: 1;
  min-width: 0;
}

.schedule-client {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dark);
}

.schedule-service {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

.schedule-status {
  align-self: center;
}

/* --- POS Styles --- */
.pos-terminal {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e8e8ec;
  overflow: hidden;
}

.pos-header {
  background: var(--primary);
  color: #fff;
  padding: 1rem 1.5rem;
  font-weight: 600;
  font-size: 14px;
}

.pos-body {
  padding: 1.5rem;
}

.pos-line-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.625rem 0;
  font-size: 14px;
  border-bottom: 1px solid #f5f5f7;
}

.pos-line-item:last-of-type {
  border-bottom: none;
}

.pos-line-item .item-name {
  color: var(--text-dark);
}

.pos-line-item .item-price {
  font-weight: 600;
  color: var(--text-dark);
}

.pos-divider {
  border: none;
  border-top: 2px solid #e8e8ec;
  margin: 0.75rem 0;
}

.pos-total-row {
  display: flex;
  justify-content: space-between;
  padding: 0.375rem 0;
  font-size: 13px;
  color: var(--text-muted);
}

.pos-total-row.grand {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-dark);
  padding: 0.75rem 0 0;
}

.pos-payment-methods {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.625rem;
  margin: 1.25rem 0;
}

.pos-pay-btn {
  padding: 0.875rem;
  border: 2px solid #e8e8ec;
  border-radius: 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
  background: #fff;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dark);
}

.pos-pay-btn:hover {
  border-color: var(--secondary);
}

.pos-pay-btn.selected {
  border-color: var(--secondary);
  background: rgba(201,168,108,0.06);
  color: var(--primary);
}

.pos-pay-btn svg {
  display: block;
  margin: 0 auto 0.375rem;
  color: var(--secondary);
}

.pos-process-btn {
  width: 100%;
  padding: 1rem;
  background: linear-gradient(135deg, var(--secondary), var(--secondary-dark));
  color: #fff;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.02em;
}

.pos-process-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* POS Success Overlay */
.pos-success {
  position: fixed;
  inset: 0;
  background: rgba(26,58,58,0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.pos-success.show {
  opacity: 1;
  pointer-events: auto;
}

.pos-success-card {
  background: #fff;
  border-radius: 20px;
  padding: 3rem;
  text-align: center;
  max-width: 400px;
  width: 90%;
  transform: scale(0.9);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pos-success.show .pos-success-card {
  transform: scale(1);
}

.pos-success-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #dcfce7;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
  color: #16a34a;
}

.pos-success-card h2 {
  font-family: var(--font-body);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 0.5rem;
}

.pos-success-card p {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.pos-success-amount {
  font-family: var(--font-display);
  font-size: 2.5rem;
  color: var(--primary);
  font-weight: 400;
  margin-bottom: 1.5rem;
}

/* --- Research Panel --- */
.research-input-wrap {
  display: flex;
  gap: 0.625rem;
  margin-bottom: 1.5rem;
}

.research-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid #e8e8ec;
  border-radius: 10px;
  font-family: var(--font-body);
  font-size: 14px;
  background: #fff;
}

.research-input:focus {
  outline: none;
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(201,168,108,0.1);
}

.research-btn {
  padding: 0.75rem 1.25rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.research-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.research-tag {
  padding: 0.375rem 0.875rem;
  border: 1px solid #e8e8ec;
  border-radius: 100px;
  font-size: 12px;
  color: var(--text-body);
  cursor: pointer;
  transition: all 0.15s ease;
  background: #fff;
}

.research-tag:hover {
  border-color: var(--secondary);
  color: var(--secondary);
}

.research-result {
  background: #fff;
  border: 1px solid #e8e8ec;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.research-result h3 {
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 0.75rem;
}

.research-result h4 {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  margin: 1rem 0 0.375rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.research-result p {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-body);
  margin-bottom: 0.5rem;
}

.research-result .citation {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}

/* --- Login Page --- */
.portal-login {
  min-height: 100vh;
  display: flex;
  background: #f5f5f7;
}

.portal-login-visual {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.portal-login-visual img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.portal-login-visual-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(26,58,58,0.92), rgba(26,58,58,0.75));
  z-index: 1;
}

.portal-login-visual-content {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 3rem;
}

.portal-login-visual-content h2 {
  font-size: var(--text-h1);
  color: #fff;
  margin-bottom: var(--space-md);
}

.portal-login-visual-content p {
  color: rgba(255,255,255,0.65);
  max-width: 400px;
  margin-inline: auto;
  font-size: var(--text-body-lg);
  font-weight: 300;
}

.portal-login-form {
  width: 520px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 3rem;
}

.portal-login-header {
  margin-bottom: 2.5rem;
}

.portal-login-header h1 {
  font-family: var(--font-body);
  font-size: 24px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 0.375rem;
}

.portal-login-header p {
  font-size: 14px;
  color: var(--text-muted);
}

.role-cards {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.role-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
  background: #fff;
  border: 2px solid #e8e8ec;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.role-card:hover {
  border-color: var(--secondary);
  transform: translateX(6px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}

.role-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.role-card-icon.owner { background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: #fff; }
.role-card-icon.provider { background: linear-gradient(135deg, #2563eb, #3b82f6); color: #fff; }
.role-card-icon.frontdesk { background: linear-gradient(135deg, var(--secondary), var(--secondary-dark)); color: #fff; }

.role-card-info h3 {
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 2px;
}

.role-card-info p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.role-card-arrow {
  margin-left: auto;
  color: var(--text-light);
  transition: color 0.15s ease;
}

.role-card:hover .role-card-arrow {
  color: var(--secondary);
}

.portal-login-footer {
  margin-top: 2.5rem;
  text-align: center;
}

.portal-login-footer a {
  font-size: 13px;
  color: var(--secondary);
  text-decoration: none;
  font-weight: 500;
}

/* --- Mobile Sidebar Toggle --- */
.portal-mobile-toggle {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

/* --- Responsive --- */
@media (max-width: 1024px) {
  .portal {
    grid-template-columns: 1fr;
  }
  .portal-sidebar {
    position: fixed;
    left: -260px;
    width: 260px;
    transition: left 0.3s ease;
    z-index: 200;
  }
  .portal-sidebar.open {
    left: 0;
  }
  .portal-mobile-toggle {
    display: flex;
  }
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .portal-grid-2,
  .portal-grid-3-1 {
    grid-template-columns: 1fr;
  }
  .portal-content {
    padding: 1.25rem;
  }
  .portal-topbar {
    padding: 0.75rem 1.25rem;
  }
}

@media (max-width: 768px) {
  .stats-row {
    grid-template-columns: 1fr;
  }
  .pos-payment-methods {
    grid-template-columns: 1fr;
  }
  .portal-login {
    flex-direction: column;
  }
  .portal-login-visual {
    height: 30vh;
    min-height: 200px;
  }
  .portal-login-form {
    width: 100%;
    padding: 2rem 1.5rem;
  }
}

/* Sidebar overlay on mobile */
.portal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 150;
}

.portal-overlay.show {
  display: block;
}
