/* ============================================================
   FFA Progressive Web App — styles.css
   Modern App UI built on FFA brand tokens
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700&display=swap');

/* ── Design Tokens ──────────────────────────────────────────── */
:root {
  /* Brand */
  --red:            #E30613;
  --red-dark:       #c62828;
  --red-soft:       rgba(227, 6, 19, 0.09);
  --red-gradient:   linear-gradient(135deg, #E30613 0%, #c62828 100%);

  /* Neutral scale */
  --gray-50:  #f8f9fa;
  --gray-100: #f1f3f5;
  --gray-200: #e9ecef;
  --gray-400: #adb5bd;
  --gray-600: #6c757d;
  --gray-800: #343a40;
  --gray-900: #1a1a2e;

  /* Semantic */
  --bg:             var(--gray-50);
  --surface:        #ffffff;
  --text:           var(--gray-900);
  --text-secondary: var(--gray-600);
  --border:         var(--gray-200);

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.07), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.09), 0 2px 8px rgba(0,0,0,0.04);
  --shadow-red: 0 4px 16px rgba(227, 6, 19, 0.35);

  /* Radius */
  --r-sm:  8px;
  --r-md:  16px;
  --r-lg:  20px;
  --r-xl:  32px;
  --r-full: 9999px;

  /* Typography */
  --font: 'Montserrat', system-ui, -apple-system, sans-serif;

  /* Layout */
  --header-h:    68px;
  --content-max: 620px;
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100dvh;
  padding-top: calc(var(--header-h) + var(--safe-top));
  padding-bottom: calc(24px + var(--safe-bottom));
  overflow-x: hidden;
}

/* ── App Header ─────────────────────────────────────────────── */
.app-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 100;
  height: calc(var(--header-h) + var(--safe-top));
  padding-top: var(--safe-top);
  background: var(--red-gradient);
  box-shadow: 0 2px 16px rgba(200, 0, 0, 0.28);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: 0 20px;
  max-width: var(--content-max);
  margin: 0 auto;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.header-logo {
  width: 38px;
  height: 38px;
  background: white;
  border-radius: var(--r-sm);
  padding: 4px;
  object-fit: contain;
  flex-shrink: 0;
}

.header-titles {
  display: flex;
  flex-direction: column;
}

.header-title {
  font-size: 1rem;
  font-weight: 700;
  color: white;
  line-height: 1.2;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.header-subtitle {
  font-size: 0.7rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.82);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: clamp(120px, 40vw, 220px);
  transition: opacity 0.3s;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Login button */
.btn-login {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: rgba(255, 255, 255, 0.15);
  border: 1.5px solid rgba(255, 255, 255, 0.45);
  border-radius: var(--r-full);
  color: white;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  white-space: nowrap;
}

.btn-login:hover,
.btn-login:focus-visible {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.8);
  outline: none;
}

.btn-login:active {
  transform: scale(0.96);
}

/* User chip */
.user-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 255, 255, 0.15);
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--r-full);
  padding: 4px 10px 4px 4px;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: white;
  color: var(--red);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.user-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: white;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.65);
  cursor: pointer;
  padding: 3px;
  display: flex;
  align-items: center;
  border-radius: 4px;
  transition: color 0.15s;
}

.btn-logout:hover {
  color: white;
}

/* ── Main Content ────────────────────────────────────────────── */
.app-main {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 28px 16px 16px;
}

/* ── Welcome Section ─────────────────────────────────────────── */
.welcome-section {
  margin-bottom: 24px;
  animation: fadeUp 0.35s ease both;
}

.welcome-greeting {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.welcome-sub {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Generic section intro */
.section-intro {
  margin-bottom: 20px;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.section-sub {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 3px;
}

/* ── Card Grid ───────────────────────────────────────────────── */
.card-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Action Card ─────────────────────────────────────────────── */
a.action-card {
  display: block;
  text-decoration: none;
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s;
  animation: fadeUp 0.3s ease both;
}

a.action-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: rgba(227, 6, 19, 0.18);
}

a.action-card:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

a.action-card:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

.card-body {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 16px;
}

.card-icon-wrap {
  width: 50px;
  height: 50px;
  border-radius: var(--r-md);
  background: var(--red-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--red);
  transition: background 0.2s;
}

a.action-card:hover .card-icon-wrap {
  background: rgba(227, 6, 19, 0.14);
}

.card-icon-wrap svg {
  width: 24px;
  height: 24px;
}

.card-text {
  flex: 1;
  min-width: 0;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}

.card-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-arrow {
  color: var(--gray-400);
  flex-shrink: 0;
  transition: color 0.2s, transform 0.2s;
}

a.action-card:hover .card-arrow {
  color: var(--red);
  transform: translateX(2px);
}

.card-arrow svg {
  width: 16px;
  height: 16px;
}

/* ── Skeleton Loading ────────────────────────────────────────── */
.card-skeleton {
  height: 86px;
  border-radius: var(--r-lg);
  background: linear-gradient(
    90deg,
    var(--gray-100) 25%,
    var(--gray-200) 50%,
    var(--gray-100) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

/* ── Login CTA ───────────────────────────────────────────────── */
.login-cta {
  margin-top: 28px;
  padding: 24px 20px;
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  text-align: center;
  animation: fadeUp 0.35s 0.15s ease both;
}

.login-cta-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--red-soft);
  color: var(--red);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
}

.login-cta-icon svg {
  width: 22px;
  height: 22px;
}

.login-cta h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
}

.login-cta p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 18px;
  line-height: 1.5;
}

.btn-login-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 12px 26px;
  background: var(--red-gradient);
  color: white;
  border: none;
  border-radius: var(--r-full);
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.2s;
  box-shadow: var(--shadow-red);
}

.btn-login-cta:hover {
  box-shadow: 0 6px 22px rgba(227, 6, 19, 0.45);
  transform: translateY(-1px);
}

.btn-login-cta:active {
  transform: translateY(0);
  box-shadow: var(--shadow-red);
}

/* Microsoft logo in CTA button */
.ms-logo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.ms-logo span {
  display: block;
  border-radius: 1px;
}

.ms-logo .ms-red   { background: #f25022; }
.ms-logo .ms-green { background: #7fba00; }
.ms-logo .ms-blue  { background: #00a4ef; }
.ms-logo .ms-yellow{ background: #ffb900; }

/* ── Card Wrapper & Favorite Button ─────────────────────────── */
.card-wrap {
  position: relative;
  width: 100%;
  min-width: 0; /* prevent grid blowout */
}

.btn-fav {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  color: var(--gray-400);
  opacity: 0.55;
  transition: color 0.15s, background 0.15s, opacity 0.15s;
}

.btn-fav:hover,
.btn-fav.is-fav {
  opacity: 1;
}

.btn-fav:hover {
  background: var(--gray-100);
  color: var(--gray-600);
}

.btn-fav.is-fav {
  color: #f59e0b;
}

.btn-fav.is-fav:hover {
  color: #d97706;
  background: rgba(245, 158, 11, 0.1);
}

.btn-fav svg {
  width: 15px;
  height: 15px;
  pointer-events: none;
}

/* ── Favorites Section ───────────────────────────────────────── */
.fav-section {
  margin-bottom: 24px;
  animation: fadeUp 0.3s ease both;
}

.fav-section-header {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 12px;
}

.fav-section-icon {
  color: #f59e0b;
  font-size: 1rem;
  line-height: 1;
}

.fav-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* ── All-services label ──────────────────────────────────────── */
.all-cards-header {
  margin-bottom: 12px;
}

.all-cards-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* ── Animations ──────────────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position:  200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0);    }
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (min-width: 480px) {
  .card-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }
}

@media (min-width: 640px) {
  .app-main {
    padding: 32px 24px 24px;
  }

  .header-inner {
    padding: 0 24px;
  }

  .welcome-greeting {
    font-size: 1.65rem;
  }
}

/* ── Utility ─────────────────────────────────────────────────── */
[hidden] { display: none !important; }
