/* ============================================
   KinzaOS Client Portal - Mobile-First Theme
   Microinteractions & Animations
   ============================================ */

/* ---------- Bottom Navigation (Mobile) ---------- */
.client-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  z-index: 200;
  padding: 6px 0 env(safe-area-inset-bottom, 8px);
}

.client-bottom-nav-inner {
  display: flex;
  justify-content: space-around;
  align-items: center;
  max-width: 500px;
  margin: 0 auto;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-decoration: none;
  color: var(--ink-soft);
  font-size: 0.625rem;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 12px;
  transition: color 0.2s ease, transform 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
}

.bottom-nav-item svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.8;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.bottom-nav-item.active {
  color: var(--brand);
}

.bottom-nav-item.active svg {
  transform: scale(1.1);
}

.bottom-nav-item:active {
  transform: scale(0.9);
}

@media (max-width: 768px) {
  .client-bottom-nav {
    display: block;
  }

  body.client-portal {
    padding-bottom: 72px;
  }

  body.client-portal > footer {
    margin-bottom: 72px;
  }

  .client-nav-menu {
    display: none !important;
  }

  .client-nav-toggle {
    display: none !important;
  }
}

/* ---------- Page Enter Animation ---------- */
@keyframes cp-fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.cp-animate-in {
  animation: cp-fadeSlideUp 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

.cp-stagger-1 { animation-delay: 0.05s; }
.cp-stagger-2 { animation-delay: 0.1s; }
.cp-stagger-3 { animation-delay: 0.15s; }
.cp-stagger-4 { animation-delay: 0.2s; }
.cp-stagger-5 { animation-delay: 0.25s; }

/* ---------- Metric Cards ---------- */
.cp-metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (min-width: 600px) {
  .cp-metrics-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }
}

.cp-metric-card {
  background: var(--surface);
  border-radius: 18px;
  padding: 20px 16px;
  text-align: center;
  border: 1px solid var(--surface-border);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
  transition: transform 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.25s ease;
  -webkit-tap-highlight-color: transparent;
  cursor: default;
  position: relative;
  overflow: hidden;
}

.cp-metric-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 18px;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.cp-metric-card:active {
  transform: scale(0.97);
}

.cp-metric-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.cp-metric-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 10px;
}

.cp-metric-icon svg {
  width: 20px;
  height: 20px;
}

.cp-metric-icon.green  { background: rgba(48, 209, 88, 0.12); color: #30d158; }
.cp-metric-icon.blue   { background: rgba(74, 126, 162, 0.12); color: var(--brand); }
.cp-metric-icon.orange { background: rgba(255, 149, 0, 0.12); color: #ff9500; }
.cp-metric-icon.purple { background: rgba(175, 82, 222, 0.12); color: #af52de; }

.cp-metric-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}

.cp-metric-label {
  font-size: 0.75rem;
  color: var(--ink-soft);
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* ---------- Counter Animation ---------- */
@keyframes cp-countPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.cp-counter-done {
  animation: cp-countPulse 0.3s ease;
}

/* ---------- Quick Action Grid ---------- */
.cp-actions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (min-width: 600px) {
  .cp-actions-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }
}

.cp-action-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 12px;
  background: var(--surface);
  border-radius: 16px;
  border: 1px solid var(--surface-border);
  text-decoration: none;
  color: var(--ink);
  transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
}

.cp-action-card:active {
  transform: scale(0.95);
}

.cp-action-card:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.cp-action-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cp-action-icon svg {
  width: 22px;
  height: 22px;
  stroke: white;
  stroke-width: 2;
}

.cp-action-icon.grad-purple { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.cp-action-icon.grad-pink   { background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%); }
.cp-action-icon.grad-green  { background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%); }
.cp-action-icon.grad-blue   { background: linear-gradient(135deg, #4A7EA2 0%, #6baed6 100%); }

.cp-action-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
}

.cp-action-sublabel {
  font-size: 0.7rem;
  color: var(--ink-soft);
  text-align: center;
}

/* ---------- Ripple Effect ---------- */
.cp-ripple {
  position: relative;
  overflow: hidden;
}

.cp-ripple-wave {
  position: absolute;
  border-radius: 50%;
  background: rgba(74, 126, 162, 0.15);
  transform: scale(0);
  animation: cp-rippleAnim 0.5s ease-out;
  pointer-events: none;
}

@keyframes cp-rippleAnim {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* ---------- Section Headers ---------- */
.cp-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.cp-section-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0;
}

.cp-section-link {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--brand);
  text-decoration: none;
}

/* ---------- Activity List ---------- */
.cp-activity-list {
  background: var(--surface);
  border-radius: 16px;
  border: 1px solid var(--surface-border);
  overflow: hidden;
}

.cp-activity-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--surface-border);
  transition: background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

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

.cp-activity-item:active {
  background: rgba(74, 126, 162, 0.04);
}

.cp-activity-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink);
  margin: 0;
}

.cp-activity-date {
  font-size: 0.75rem;
  color: var(--ink-soft);
  margin: 2px 0 0;
}

.cp-badge {
  display: inline-flex;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}

.cp-badge-green  { background: rgba(48, 209, 88, 0.12); color: #28a745; }
.cp-badge-orange { background: rgba(255, 149, 0, 0.12); color: #e67e00; }
.cp-badge-gray   { background: rgba(142, 142, 147, 0.12); color: #6e6e73; }

/* ---------- Empty State ---------- */
.cp-empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--ink-soft);
}

.cp-empty-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: rgba(74, 126, 162, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
}

.cp-empty-icon svg {
  width: 24px;
  height: 24px;
  stroke: var(--ink-soft);
  stroke-width: 1.5;
}

/* ---------- Card Fullscreen Overlay ---------- */
.cp-card-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.cp-card-overlay.open {
  opacity: 1;
  visibility: visible;
}

.cp-card-overlay-content {
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.92);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  -webkit-overflow-scrolling: touch;
}

.cp-card-overlay.open .cp-card-overlay-content {
  transform: scale(1);
}

.cp-card-overlay-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 501;
  transition: transform 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.cp-card-overlay-close:active {
  transform: scale(0.9);
}

.cp-card-overlay-close svg {
  width: 18px;
  height: 18px;
  stroke: var(--ink);
  stroke-width: 2;
}

/* ---------- Card List Item (Tap-to-Lift) ---------- */
.cp-card-item {
  transition: transform 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.25s ease;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

.cp-card-item:active {
  transform: scale(0.98);
}

.cp-card-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1);
}

/* ---------- Input Focus Glow ---------- */
.cp-input-glow {
  transition: border-color 0.2s ease, box-shadow 0.3s ease, transform 0.2s ease;
}

.cp-input-glow:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(74, 126, 162, 0.12), 0 2px 8px rgba(74, 126, 162, 0.08);
  transform: translateY(-1px);
}

.cp-input-glow.valid {
  border-color: var(--success-green);
  box-shadow: 0 0 0 4px rgba(48, 209, 88, 0.1);
}

.cp-input-glow.invalid {
  border-color: var(--error-red);
  box-shadow: 0 0 0 4px rgba(255, 59, 48, 0.1);
  animation: cp-shake 0.4s ease;
}

@keyframes cp-shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-3px); }
  40%, 60% { transform: translateX(3px); }
}

/* ---------- Inline Validation ---------- */
.cp-validation-msg {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  margin-top: 6px;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.cp-validation-msg.show {
  opacity: 1;
  transform: translateY(0);
}

.cp-validation-msg.success { color: var(--success-green); }
.cp-validation-msg.error   { color: var(--error-red); }

/* ---------- Emoji Bounce-Select ---------- */
.cp-emoji-btn {
  font-size: 2.2rem;
  padding: 10px 16px;
  border: 2px solid var(--surface-border);
  border-radius: 16px;
  background: var(--surface);
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.2s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
}

.cp-emoji-btn:active {
  transform: scale(0.9);
}

.cp-emoji-btn.selected {
  border-color: var(--brand);
  background: rgba(74, 126, 162, 0.06);
  box-shadow: 0 0 0 3px rgba(74, 126, 162, 0.12);
  animation: cp-emojiBounce 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes cp-emojiBounce {
  0%   { transform: scale(0.8); }
  50%  { transform: scale(1.2); }
  100% { transform: scale(1.05); }
}

.cp-emoji-row {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.cp-rating-category {
  margin-bottom: 24px;
}

.cp-rating-label {
  display: block;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--ink);
  font-size: 0.9rem;
}

/* ---------- Success Celebration ---------- */
.cp-success-overlay {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.cp-success-overlay.show {
  opacity: 1;
  visibility: visible;
}

.cp-success-check {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--success-green);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  animation: cp-checkPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.cp-success-check svg {
  width: 40px;
  height: 40px;
  stroke: white;
  stroke-width: 3;
  stroke-dasharray: 60;
  stroke-dashoffset: 60;
  animation: cp-checkDraw 0.4s 0.3s ease forwards;
}

@keyframes cp-checkPop {
  0%   { transform: scale(0); }
  60%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

@keyframes cp-checkDraw {
  to { stroke-dashoffset: 0; }
}

.cp-success-text {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 8px;
  animation: cp-fadeSlideUp 0.4s 0.4s both;
}

.cp-success-subtext {
  font-size: 0.9rem;
  color: var(--ink-soft);
  animation: cp-fadeSlideUp 0.4s 0.5s both;
}

.cp-confetti-particle {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  animation: cp-confettiFall 1.2s ease-out forwards;
}

@keyframes cp-confettiFall {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--cp-cx), var(--cp-cy)) rotate(720deg) scale(0);
  }
}

/* ---------- Button Press ---------- */
.cp-btn-press {
  transition: transform 0.15s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.cp-btn-press:active {
  transform: scale(0.97) translateY(1px);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* ---------- Toast Notification ---------- */
.cp-toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100%);
  background: var(--ink);
  color: white;
  padding: 12px 24px;
  border-radius: 14px;
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 700;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 90%;
}

.cp-toast.show {
  transform: translateX(-50%) translateY(0);
}

.cp-toast.success { background: #28a745; }
.cp-toast.error   { background: #dc3545; }
.cp-toast.info    { background: var(--brand); }

/* ---------- Business Card (My Businesses) ---------- */
.cp-biz-card {
  background: var(--surface);
  border-radius: 18px;
  border: 1px solid var(--surface-border);
  overflow: hidden;
  transition: transform 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}

.cp-biz-card:active {
  transform: scale(0.98);
}

.cp-biz-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.1);
}

.cp-biz-card.current {
  border: 2px solid var(--brand);
  box-shadow: 0 0 0 3px rgba(74, 126, 162, 0.1);
}

.cp-biz-header {
  padding: 20px;
  background: linear-gradient(135deg, var(--brand) 0%, #5a8fb8 100%);
  color: white;
}

.cp-biz-header h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0 0 4px;
  color: white;
}

.cp-biz-header p {
  font-size: 0.8rem;
  opacity: 0.85;
  margin: 0;
  color: rgba(255, 255, 255, 0.9);
}

.cp-biz-body {
  padding: 20px;
}

.cp-biz-stat-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 0.85rem;
}

.cp-biz-stat-label {
  color: var(--ink-soft);
}

.cp-biz-stat-value {
  font-weight: 600;
  color: var(--ink);
}

.cp-current-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(48, 209, 88, 0.1);
  color: #28a745;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-bottom: 12px;
}

/* ---------- Form Card ---------- */
.cp-form-card {
  background: var(--surface);
  border-radius: 18px;
  border: 1px solid var(--surface-border);
  overflow: hidden;
}

.cp-form-card-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--surface-border);
}

.cp-form-card-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0;
}

.cp-form-card-body {
  padding: 20px;
}

/* ---------- Profile Info Grid ---------- */
.cp-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.cp-info-item {
  padding: 12px;
  background: var(--surface-subtle);
  border-radius: 12px;
}

.cp-info-label {
  font-size: 0.7rem;
  color: var(--ink-soft);
  font-weight: 500;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.cp-info-value {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
}

/* ---------- Page Container ---------- */
.cp-page {
  padding: 16px;
  max-width: 600px;
  margin: 0 auto;
}

@media (min-width: 769px) {
  .cp-page {
    padding: 32px 16px;
  }
}

.cp-page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 4px;
}

.cp-page-subtitle {
  font-size: 0.875rem;
  color: var(--ink-soft);
  margin: 0 0 24px;
}

/* ---------- Help / Info Box ---------- */
.cp-info-box {
  background: rgba(74, 126, 162, 0.04);
  border: 1px solid rgba(74, 126, 162, 0.1);
  border-radius: 16px;
  padding: 20px;
}

.cp-info-box h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 8px;
}

.cp-info-box ul {
  color: var(--ink-soft);
  font-size: 0.85rem;
  line-height: 1.8;
  padding-left: 18px;
  margin: 0;
}

/* ---------- Password Modal Redesign ---------- */
.cp-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 500;
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.cp-modal-backdrop.open {
  display: flex;
}

@media (min-width: 600px) {
  .cp-modal-backdrop.open {
    align-items: center;
  }
}

.cp-modal-sheet {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 440px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px 20px env(safe-area-inset-bottom, 20px);
  animation: cp-slideUp 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

@media (min-width: 600px) {
  .cp-modal-sheet {
    border-radius: 20px;
    margin: 20px;
  }
}

@keyframes cp-slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.cp-modal-handle {
  width: 36px;
  height: 4px;
  background: var(--surface-border);
  border-radius: 2px;
  margin: 0 auto 16px;
}

@media (min-width: 600px) {
  .cp-modal-handle {
    display: none;
  }
}

/* ---------- Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .cp-animate-in,
  .cp-emoji-btn.selected,
  .cp-success-check,
  .cp-success-check svg,
  .cp-confetti-particle,
  .cp-counter-done {
    animation: none !important;
  }
  
  .cp-metric-card:active,
  .cp-action-card:active,
  .cp-emoji-btn:active,
  .cp-btn-press:active,
  .bottom-nav-item:active {
    transform: none !important;
  }
}
