/* ==========================================================================
    ALDOCODE iOS 18 PRO THEME
   Pixel-perfect Apple Cupertino Design System
   ========================================================================== */

:root {
  --ios-bg: #000000;
  --ios-card-bg: rgba(28, 28, 30, 0.72);
  --ios-card-solid: #1c1c1e;
  --ios-card-hover: rgba(44, 44, 46, 0.85);
  --ios-card-border: rgba(255, 255, 255, 0.12);
  --ios-blue: #007aff;
  --ios-blue-light: #0a84ff;
  --ios-indigo: #5e5ce6;
  --ios-purple: #af52de;
  --ios-pink: #ff2d55;
  --ios-red: #ff453a;
  --ios-orange: #ff9f0a;
  --ios-yellow: #ffd60a;
  --ios-green: #30d158;
  --ios-teal: #64d2ff;
  --ios-text-primary: #ffffff;
  --ios-text-secondary: rgba(235, 235, 245, 0.6);
  --ios-text-tertiary: rgba(235, 235, 245, 0.3);
  --ios-separator: rgba(84, 84, 88, 0.36);
  --ios-tabbar-bg: rgba(22, 22, 24, 0.82);
  --ios-blur: blur(28px) saturate(190%);
  --ios-font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", sans-serif;
  --ios-radius-lg: 24px;
  --ios-radius-md: 16px;
  --ios-radius-sm: 10px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  font-family: var(--ios-font);
}

body {
  background-color: var(--ios-bg);
  color: var(--ios-text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  padding-bottom: 96px; /* Space for bottom tab bar */
  -webkit-font-smoothing: antialiased;
}

/* Scrollbar iOS */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.35);
}

/* ==========================================================================
   DYNAMIC ISLAND & TOP STATUS BAR
   ========================================================================== */
.ios-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 24px 6px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--ios-text-primary);
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: var(--ios-blur);
  -webkit-backdrop-filter: var(--ios-blur);
}

.status-left {
  font-size: 14px;
  font-weight: 600;
}

.dynamic-island {
  background: #000000;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  height: 32px;
  min-width: 120px;
  padding: 4px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.8), inset 0 1px 1px rgba(255, 255, 255, 0.15);
}

.dynamic-island.expanded {
  min-width: 280px;
  height: 48px;
  border-radius: 24px;
  padding: 6px 18px;
}

.island-camera-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #080808;
  border: 1.5px solid #1c1c1e;
}

.island-content {
  font-size: 12px;
  font-weight: 500;
  color: var(--ios-text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.island-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ios-green);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(48, 209, 88, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(48, 209, 88, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(48, 209, 88, 0); }
}

.status-right {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

/* ==========================================================================
   NAVIGATION BAR
   ========================================================================== */
.ios-nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  position: sticky;
  top: 48px;
  z-index: 99;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: var(--ios-blur);
  -webkit-backdrop-filter: var(--ios-blur);
  border-bottom: 0.5px solid var(--ios-separator);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0a84ff, #5e5ce6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: 0 4px 12px rgba(10, 132, 255, 0.35);
}

.brand-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.4px;
}

.brand-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.12);
  padding: 2px 6px;
  border-radius: 6px;
  color: var(--ios-teal);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-avatar-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid var(--ios-blue);
  overflow: hidden;
  cursor: pointer;
  background: var(--ios-card-solid);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-avatar-btn:active {
  transform: scale(0.92);
}

.nav-avatar-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.nav-admin-badge {
  background: linear-gradient(135deg, #ff9f0a, #ff453a);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
  cursor: pointer;
}

/* ==========================================================================
   BOTTOM TAB BAR (Cupertino 5 Menus)
   ========================================================================== */
.ios-tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 84px;
  background: var(--ios-tabbar-bg);
  backdrop-filter: var(--ios-blur);
  -webkit-backdrop-filter: var(--ios-blur);
  border-top: 0.5px solid var(--ios-separator);
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  padding-top: 8px;
  z-index: 1000;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: none;
  color: var(--ios-text-secondary);
  cursor: pointer;
  width: 20%;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tab-item:active {
  transform: scale(0.88);
}

.tab-item.active {
  color: var(--ios-blue);
}

.tab-icon {
  font-size: 22px;
  line-height: 1;
  transition: transform 0.2s ease;
}

.tab-item.active .tab-icon {
  transform: translateY(-2px);
  filter: drop-shadow(0 2px 8px rgba(0, 122, 255, 0.45));
}

.tab-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

/* ==========================================================================
   CONTAINER & LAYOUT
   ========================================================================== */
.ios-container {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px;
}

.page-view {
  display: none;
  animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.page-view.active {
  display: block;
}

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

.page-header {
  margin-bottom: 20px;
}

.large-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--ios-text-primary);
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: 14px;
  color: var(--ios-text-secondary);
}

/* ==========================================================================
   iOS CARDS & GROUPED TABLES
   ========================================================================== */
.ios-card {
  background: var(--ios-card-bg);
  border: 1px solid var(--ios-card-border);
  backdrop-filter: var(--ios-blur);
  -webkit-backdrop-filter: var(--ios-blur);
  border-radius: var(--ios-radius-lg);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.ios-card:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.widget-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.ios-widget {
  background: var(--ios-card-bg);
  border: 1px solid var(--ios-card-border);
  backdrop-filter: var(--ios-blur);
  border-radius: var(--ios-radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 94px;
}

.widget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.widget-icon {
  font-size: 20px;
}

.widget-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--ios-text-secondary);
  text-transform: uppercase;
}

.widget-value {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-top: 6px;
}

/* Badges */
.badge-verified {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #0a84ff;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  margin-left: 4px;
  vertical-align: middle;
  box-shadow: 0 0 8px rgba(10, 132, 255, 0.6);
}

.badge-crown {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ffd700, #ff8c00);
  color: #000;
  font-size: 11px;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  margin-left: 4px;
  vertical-align: middle;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.7);
  animation: shine 3s infinite;
}

@keyframes shine {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.3); }
}

/* ==========================================================================
   CODE SNIPPET CARDS
   ========================================================================== */
.snippet-card {
  background: var(--ios-card-bg);
  border: 1px solid var(--ios-card-border);
  backdrop-filter: var(--ios-blur);
  border-radius: var(--ios-radius-lg);
  padding: 18px;
  margin-bottom: 14px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.snippet-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.22);
}

.snippet-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.author-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.author-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid rgba(255, 255, 255, 0.15);
}

.author-info {
  display: flex;
  flex-direction: column;
}

.author-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--ios-text-primary);
  display: flex;
  align-items: center;
}

.snippet-time {
  font-size: 11px;
  color: var(--ios-text-tertiary);
}

.lang-pill {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 12px;
  background: rgba(10, 132, 255, 0.15);
  color: var(--ios-blue-light);
  border: 1px solid rgba(10, 132, 255, 0.3);
}

.snippet-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 6px;
  line-height: 1.3;
}

.snippet-desc {
  font-size: 13px;
  color: var(--ios-text-secondary);
  line-height: 1.45;
  margin-bottom: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.snippet-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  border-top: 0.5px solid var(--ios-separator);
}

.snippet-stats {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: var(--ios-text-secondary);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.reaction-btn {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--ios-text-secondary);
  padding: 6px 10px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

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

.reaction-btn.active-like {
  background: rgba(48, 209, 88, 0.2);
  color: var(--ios-green);
  border: 1px solid rgba(48, 209, 88, 0.4);
}

.reaction-btn.active-dislike {
  background: rgba(255, 69, 58, 0.2);
  color: var(--ios-red);
  border: 1px solid rgba(255, 69, 58, 0.4);
}

.btn-view-code {
  background: var(--ios-blue);
  color: #fff;
  border: none;
  padding: 7px 16px;
  border-radius: 18px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.35);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-view-code:active {
  transform: scale(0.92);
}

/* ==========================================================================
   INPUTS & FORMS (Cupertino Style)
   ========================================================================== */
.ios-form-group {
  margin-bottom: 16px;
}

.ios-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ios-text-secondary);
  margin-bottom: 8px;
  letter-spacing: -0.1px;
}

.ios-input, .ios-textarea, .ios-select {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--ios-card-border);
  border-radius: var(--ios-radius-md);
  padding: 12px 16px;
  font-size: 15px;
  color: var(--ios-text-primary);
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.ios-input:focus, .ios-textarea:focus, .ios-select:focus {
  border-color: var(--ios-blue);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.2);
}

.ios-textarea {
  font-family: "SF Mono", Menlo, Consolas, Monaco, monospace;
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
  min-height: 180px;
}

.ios-select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
}

.ios-button {
  width: 100%;
  background: var(--ios-blue);
  color: #fff;
  border: none;
  padding: 14px 20px;
  border-radius: var(--ios-radius-md);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 122, 255, 0.4);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.ios-button:active {
  transform: scale(0.96);
}

.ios-button.secondary {
  background: rgba(255, 255, 255, 0.1);
  box-shadow: none;
  border: 1px solid var(--ios-card-border);
}

.ios-button.danger {
  background: var(--ios-red);
  box-shadow: 0 4px 16px rgba(255, 69, 58, 0.35);
}

/* ==========================================================================
   SEGMENTED CONTROL
   ========================================================================== */
.segmented-control {
  display: flex;
  background: rgba(118, 118, 128, 0.24);
  padding: 3px;
  border-radius: 12px;
  margin-bottom: 16px;
}

.segment-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ios-text-secondary);
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.segment-btn.active {
  background: #636366;
  color: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

/* ==========================================================================
   SEARCH BAR
   ========================================================================== */
.ios-search-box {
  position: relative;
  margin-bottom: 14px;
}

.ios-search-box input {
  width: 100%;
  background: rgba(118, 118, 128, 0.24);
  border: none;
  border-radius: 12px;
  padding: 10px 14px 10px 38px;
  font-size: 15px;
  color: #fff;
  outline: none;
}

.search-icon-pos {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ios-text-secondary);
  font-size: 15px;
}

/* ==========================================================================
   TOP CREATORS & HALL OF FAME (Menu 4)
   ========================================================================== */
.podium-container {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 12px;
  margin: 24px 0 28px;
}

.podium-card {
  flex: 1;
  background: var(--ios-card-bg);
  border: 1px solid var(--ios-card-border);
  backdrop-filter: var(--ios-blur);
  border-radius: var(--ios-radius-lg);
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.podium-card:hover {
  transform: translateY(-4px);
}

.podium-rank-1 {
  order: 2;
  transform: translateY(-12px);
  border: 1.5px solid rgba(255, 215, 0, 0.5);
  box-shadow: 0 10px 30px rgba(255, 215, 0, 0.2);
}

.podium-rank-2 {
  order: 1;
}

.podium-rank-3 {
  order: 3;
}

.podium-badge-icon {
  font-size: 24px;
  position: absolute;
  top: -14px;
}

.podium-avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 8px;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.podium-rank-1 .podium-avatar {
  width: 64px;
  height: 64px;
  border-color: #ffd700;
}

.podium-name {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
}

.podium-stat {
  font-size: 11px;
  color: var(--ios-text-secondary);
}

/* ==========================================================================
   SHEET MODAL (iOS Slide-Up Sheet)
   ========================================================================== */
.ios-sheet-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.ios-sheet-overlay.active {
  display: block;
  opacity: 1;
}

.ios-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 680px;
  margin: 0 auto;
  max-height: 92vh;
  background: #1c1c1e;
  border-top-left-radius: 28px;
  border-top-right-radius: 28px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  padding: 16px 20px 32px;
  z-index: 2001;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.7);
}

.ios-sheet.active {
  transform: translateY(0);
}

.sheet-handle {
  width: 40px;
  height: 5px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
  margin: 0 auto 16px;
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.sheet-close-btn {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Code Viewer Sheet Styling */
.code-viewer-container {
  background: #0d0d0f;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--ios-radius-md);
  overflow: hidden;
  margin-bottom: 16px;
}

.code-viewer-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.code-actions {
  display: flex;
  gap: 8px;
}

.btn-code-action {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 6px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-code-action:active {
  transform: scale(0.92);
}

.code-pre {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  font-family: "SF Mono", Menlo, Consolas, Monaco, monospace;
  font-size: 13px;
  line-height: 1.6;
  color: #e6e6e6;
  tab-size: 2;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ==========================================================================
   TOAST NOTIFICATION (iOS Pill)
   ========================================================================== */
.ios-toast {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(30, 30, 32, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: var(--ios-blur);
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  z-index: 3000;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  gap: 8px;
}

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

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 480px) {
  .ios-container {
    padding: 12px 12px;
  }
  .dynamic-island {
    min-width: 90px;
  }
  .dynamic-island.expanded {
    min-width: 240px;
  }
}
