/* ===== DinnApps - Premium Blue Theme ===== */
:root {
  --bg-primary: #070d1a;
  --bg-secondary: #0c1528;
  --bg-card: #111c33;
  --bg-card-hover: #162440;
  --bg-elevated: #1a2a4a;
  --border: rgba(59, 130, 246, 0.12);
  --border-strong: rgba(59, 130, 246, 0.25);

  --blue-400: #60a5fa;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --cyan: #22d3ee;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Background subtle gradient */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(37, 99, 235, 0.15), transparent),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(34, 211, 238, 0.06), transparent);
  pointer-events: none;
  z-index: 0;
}

/* ===== Header ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(7, 13, 26, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--blue-500), var(--cyan));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.logo-icon.small {
  width: 28px;
  height: 28px;
  font-size: 0.9rem;
  border-radius: 8px;
}

/* Search */
.search-wrap {
  flex: 1;
  max-width: 520px;
  position: relative;
}

.search-wrap input {
  width: 100%;
  padding: 12px 44px 12px 44px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50px;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

.search-wrap input::placeholder {
  color: var(--text-muted);
}

.search-wrap input:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
  background: var(--bg-elevated);
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-clear {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  display: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  line-height: 1;
}

.search-clear.visible {
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-clear:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

/* Nav */
.nav-links {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.nav-item {
  padding: 8px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  border-radius: 8px;
  transition: var(--transition);
}

.nav-item:hover,
.nav-item.active {
  color: var(--text-primary);
  background: rgba(59, 130, 246, 0.15);
}

/* ===== Main ===== */
.main {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 24px 60px;
}

.hidden {
  display: none !important;
}

/* Hero */
.hero {
  position: relative;
  background: linear-gradient(135deg, #0f1c38 0%, #0c2548 50%, #0a1a35 100%);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 48px 40px;
  margin-bottom: 40px;
  overflow: hidden;
}

.hero-content {
  position: relative;
  z-index: 2;
  max-width: 500px;
}

.hero h1 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
  background: linear-gradient(135deg, #fff 0%, var(--blue-400) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  color: var(--text-secondary);
  font-size: 1.05rem;
}

.hero-glow {
  position: absolute;
  right: -60px;
  top: -60px;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.25) 0%, transparent 70%);
  pointer-events: none;
}

/* Sections */
.section {
  margin-bottom: 44px;
}

.section-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 18px;
}

.section-header h2 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.result-count {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Featured Grid */
.featured-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.featured-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  gap: 16px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.featured-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.featured-card .app-icon {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  flex-shrink: 0;
  object-fit: cover;
  background: var(--bg-elevated);
}

.featured-info h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.featured-info .developer {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.featured-info .meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.rating {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #fbbf24;
}

/* App Row (horizontal scroll) */
.app-row {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-elevated) transparent;
}

.app-row::-webkit-scrollbar {
  height: 6px;
}

.app-row::-webkit-scrollbar-thumb {
  background: var(--bg-elevated);
  border-radius: 3px;
}

.app-card {
  flex: 0 0 140px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

.app-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.app-card .app-icon {
  width: 80px;
  height: 80px;
  border-radius: 18px;
  margin: 0 auto 12px;
  display: block;
  object-fit: cover;
  background: var(--bg-elevated);
}

.app-card h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-card .developer {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-card .rating {
  justify-content: center;
  font-size: 0.8rem;
}

/* App Grid (for search & category) */
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.app-grid .app-card {
  flex: none;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

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

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  transform: scale(0.95) translateY(20px);
  transition: var(--transition);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

.modal-overlay.open .modal {
  transform: scale(1) translateY(0);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--blue-600);
  color: white;
}

.modal-body {
  padding: 28px;
}

.modal-header {
  display: flex;
  gap: 20px;
  margin-bottom: 24px;
}

.modal-icon {
  width: 96px;
  height: 96px;
  border-radius: 22px;
  flex-shrink: 0;
  object-fit: cover;
  background: var(--bg-elevated);
}

.modal-title h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.modal-title .developer {
  color: var(--blue-400);
  font-size: 0.95rem;
  margin-bottom: 10px;
}

.modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.modal-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 28px;
}

.btn-install {
  flex: 1;
  padding: 14px 28px;
  background: linear-gradient(135deg, var(--blue-500), var(--blue-600));
  color: white;
  border: none;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.35);
}

.btn-install:hover {
  background: linear-gradient(135deg, var(--blue-400), var(--blue-500));
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.45);
}

.btn-install:active {
  transform: translateY(0);
}

.btn-install.downloading {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  pointer-events: none;
  box-shadow: none;
}

.modal-section {
  margin-bottom: 24px;
}

.modal-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.modal-section p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
}

.screenshots {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.screenshot {
  width: 140px;
  height: 250px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  flex-shrink: 0;
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.update-box {
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 12px;
  padding: 16px !important;
}

.update-box h3 {
  color: var(--blue-400) !important;
  margin-bottom: 8px !important;
}

.badge-updated {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 10px;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 20px;
}

.version-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.version-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  transition: var(--transition);
}

.version-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
}

.version-item.active {
  border-color: var(--blue-500);
  background: rgba(59, 130, 246, 0.12);
  box-shadow: 0 0 0 1px var(--blue-500);
}

.version-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.version-info strong {
  font-size: 1rem;
  color: var(--text-primary);
}

.version-info span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.version-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  padding: 14px 24px;
  border-radius: 50px;
  font-weight: 500;
  font-size: 0.95rem;
  z-index: 300;
  opacity: 0;
  transition: var(--transition);
  box-shadow: var(--shadow);
  pointer-events: none;
}

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

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 28px 24px;
  position: relative;
  z-index: 1;
}

.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.footer p {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state h3 {
  font-size: 1.2rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

/* Responsive */
@media (max-width: 768px) {
  .header-inner {
    flex-wrap: wrap;
    gap: 12px;
  }

  .nav-links {
    order: 3;
    width: 100%;
    justify-content: center;
  }

  .search-wrap {
    max-width: none;
    order: 2;
    flex: 1 1 100%;
  }

  .hero {
    padding: 32px 24px;
  }

  .hero h1 {
    font-size: 1.6rem;
  }

  .featured-grid {
    grid-template-columns: 1fr;
  }

  .modal-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .modal-meta {
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .app-card {
    flex: 0 0 120px;
    padding: 10px;
  }

  .app-card .app-icon {
    width: 64px;
    height: 64px;
  }
}

/* Version selector di modal detail aplikasi */
.version-select {
  width: 100%;
  padding: 11px 13px;
  background: #0c1528;
  border: 1px solid rgba(59,130,246,0.15);
  border-radius: 10px;
  color: #f1f5f9;
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  cursor: pointer;
}
.version-select:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
}
