/*
 * Jaipur Cloth App Install Bar — Frontend Styles
 * Version: 1.0.0
 *
 * Design: Premium dark gradient bar — modern e-commerce aesthetic.
 * Uses CSS custom properties so it is easy to retheme.
 */

/* ─── Custom Properties ──────────────────────────────────────────────────────── */
:root {
  --jcab-bg-from:        #0f0c29;
  --jcab-bg-mid:         #302b63;
  --jcab-bg-to:          #24243e;
  --jcab-accent:         #f97316;        /* Brand orange */
  --jcab-accent-hover:   #ea6c0e;
  --jcab-ios-bg:         #1c1c1e;
  --jcab-ios-hover:      #2c2c2e;
  --jcab-text-primary:   #ffffff;
  --jcab-text-secondary: rgba(255,255,255,0.70);
  --jcab-border:         rgba(255,255,255,0.08);
  --jcab-close-bg:       rgba(255,255,255,0.10);
  --jcab-close-hover-bg: rgba(255,255,255,0.20);
  --jcab-icon-bg:        rgba(255,255,255,0.12);
  --jcab-height-desktop: 52px;
  --jcab-height-mobile:  52px;
  --jcab-z-index:        999999;
  --jcab-transition:     0.2s ease;
  --jcab-font:           -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
}

/* ─── Bar Wrapper ─────────────────────────────────────────────────────────────── */
#jcab-bar {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--jcab-z-index);
  width: 100%;
  background: linear-gradient(135deg, var(--jcab-bg-from) 0%, var(--jcab-bg-mid) 50%, var(--jcab-bg-to) 100%);
  border-bottom: 1px solid var(--jcab-border);
  font-family: var(--jcab-font);
  /* Subtle shimmer animation */
  background-size: 200% 200%;
  animation: jcabGradientShift 8s ease infinite;
  /* Ensure it sits above everything */
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.35);
  /* Hidden state (JS toggles) */
  transition: transform var(--jcab-transition), opacity var(--jcab-transition);
}

#jcab-bar.jcab--hidden {
  display: none !important;
}

@keyframes jcabGradientShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ─── Inner Layout ────────────────────────────────────────────────────────────── */
.jcab__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 16px;
  height: var(--jcab-height-desktop);
}

/* ─── Brand (Icon + Text) ─────────────────────────────────────────────────────── */
.jcab__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

/* Icon wrapper */
.jcab__icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--jcab-icon-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--jcab-border);
}

.jcab__icon-img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 10px;
  display: block;
}

.jcab__icon-default {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--jcab-accent);
  width: 100%;
  height: 100%;
}

/* Text */
.jcab__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.jcab__title {
  font-size: 14px;
  font-weight: 700;
  color: var(--jcab-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.jcab__subtitle {
  font-size: 11px;
  color: var(--jcab-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
  margin-top: 1px;
}

/* ─── Actions ─────────────────────────────────────────────────────────────────── */
.jcab__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ─── Store Buttons ───────────────────────────────────────────────────────────── */
.jcab__btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border-radius: 8px;
  text-decoration: none !important;
  font-family: var(--jcab-font);
  cursor: pointer;
  border: none;
  outline: none;
  transition: transform var(--jcab-transition), box-shadow var(--jcab-transition), background var(--jcab-transition);
  flex-shrink: 0;
  white-space: nowrap;
}

.jcab__btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  text-decoration: none !important;
}

.jcab__btn:active {
  transform: translateY(0);
}

/* Android button */
.jcab__btn--android {
  background: var(--jcab-accent);
  color: #ffffff !important;
}

.jcab__btn--android:hover {
  background: var(--jcab-accent-hover);
  color: #ffffff !important;
}

/* iOS button */
.jcab__btn--ios {
  background: var(--jcab-ios-bg);
  color: #ffffff !important;
  border: 1px solid rgba(255,255,255,0.15);
}

.jcab__btn--ios:hover {
  background: var(--jcab-ios-hover);
  color: #ffffff !important;
}

/* Button label */
.jcab__btn-label {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.jcab__btn-sub {
  font-size: 9px;
  font-weight: 400;
  opacity: 0.85;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.jcab__btn-main {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ─── Close Button ────────────────────────────────────────────────────────────── */
.jcab__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--jcab-close-bg);
  border: 1px solid var(--jcab-border);
  color: var(--jcab-text-primary);
  cursor: pointer;
  padding: 0;
  transition: background var(--jcab-transition), transform var(--jcab-transition);
  flex-shrink: 0;
}

.jcab__close:hover {
  background: var(--jcab-close-hover-bg);
  transform: rotate(90deg) scale(1.1);
}

.jcab__close:focus-visible {
  outline: 2px solid var(--jcab-accent);
  outline-offset: 2px;
}

/* ─── Device Visibility Classes ──────────────────────────────────────────────── */
/* Mobile-only: hide on desktop */
#jcab-bar.jcab--mobile-only {
  display: none;
}

/* Desktop-only: hide on mobile */
/* (handled below in responsive media query) */

/* ─── Responsive — Mobile & Tablet ───────────────────────────────────────────── */
@media (max-width: 768px) {

  /* Show mobile-only bar */
  #jcab-bar.jcab--mobile-only {
    display: block;
  }

  /* Hide desktop-only bar */
  #jcab-bar.jcab--desktop-only {
    display: none !important;
  }

  .jcab__inner {
    height: var(--jcab-height-mobile);
    padding: 0 12px;
    gap: 8px;
  }

  /* Compact text on mobile */
  .jcab__subtitle {
    display: none;
  }

  .jcab__title {
    font-size: 13px;
  }

  /* Make icon smaller */
  .jcab__icon {
    width: 32px;
    height: 32px;
  }

  /* Compact buttons */
  .jcab__btn {
    padding: 5px 10px;
    gap: 5px;
  }

  .jcab__btn-sub {
    font-size: 8px;
  }

  .jcab__btn-main {
    font-size: 11px;
  }
}

@media (max-width: 480px) {
  /* On very small screens, further compact */
  .jcab__actions {
    gap: 5px;
  }

  .jcab__btn-label {
    display: none;
  }

  .jcab__btn {
    padding: 7px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
  }

  /* Show abbreviated text labels */
  .jcab__btn--android::after {
    content: "Android";
    font-size: 12px;
    font-weight: 700;
    color: #fff;
  }

  .jcab__btn--ios::after {
    content: "iOS";
    font-size: 12px;
    font-weight: 700;
    color: #fff;
  }
}

/* ─── Accessibility — Respect Reduced Motion ─────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  #jcab-bar {
    animation: none;
  }

  .jcab__btn,
  .jcab__close {
    transition: none;
  }
}

/* ─── Admin Bar Offset ────────────────────────────────────────────────────────── */
/*
 * When the WP admin bar is visible, sticky positioning needs to account for it.
 * The admin bar is 32px tall on desktop, 46px on mobile when logged in.
 */
.admin-bar #jcab-bar {
  top: 32px;
}

@media screen and (max-width: 782px) {
  .admin-bar #jcab-bar {
    top: 46px;
  }
}
