/* =========================================================
   Elite Instagram App Theme — Light Theme Default
   ========================================================= */

:root {
  --ig-bg: #fafafa;
  --ig-bg-dark: #121212;
  --ig-surface: #fff;
  --ig-surface-dark: #1e1e1e;
  --ig-card: #fff;
  --ig-card-dark: #262626;
  --ig-text: #262626;
  --ig-text-dark: #f5f5f5;
  --ig-text-secondary: #8e8e8e;
  --ig-border: #dbdbdb;
  --ig-border-dark: #363636;
  --ig-primary: #8900fa;
  --ig-primary-rgb: 137, 0, 250;
  --ig-gradient: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
  --ig-success: #00d26a;
  --ig-danger: #ed4956;
  --ig-warning: #ffc107;
  --ig-radius: 12px;
  --ig-radius-sm: 8px;
  --ig-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  --ig-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1);
  --ig-transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1),
                    box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1),
                    background-color 0.2s ease,
                    border-color 0.2s ease,
                    opacity 0.2s ease;
  --ig-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --sidebar-width: 72px;
  --topbar-height: 56px;
  --bottom-nav-height: 56px;
}

/* ── Layout ── */
.app-layout {
  background: var(--ig-bg);
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar (scoped under .app-layout) ── */
.app-layout .main-menu {
  align-items: center;
  background: var(--ig-surface);
  border-right: 1px solid var(--ig-border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  left: 0;
  padding: 12px 0;
  position: fixed;
  top: 0;
  transition: width 0.3s ease;
  width: var(--sidebar-width);
  z-index: 1000;
}

.app-layout .main-menu.hover-open,
.app-layout .main-menu:hover {
  width: 240px;
}

.app-layout .main-menu .sidebar-logo {
  align-items: center;
  background: var(--ig-gradient);
  border-radius: 50%;
  color: #fff;
  display: flex;
  font-weight: 700;
  height: 40px;
  justify-content: center;
  margin-bottom: 24px;
  width: 40px;
}

.app-layout .main-menu .sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 8px;
  width: 100%;
}

.app-layout .main-menu .sidebar-item {
  align-items: center;
  border-radius: var(--ig-radius);
  color: var(--ig-text);
  display: flex;
  gap: 16px;
  overflow: hidden;
  padding: 12px 16px;
  text-decoration: none;
  transition: var(--ig-transition);
  white-space: nowrap;
}

.app-layout .main-menu .sidebar-item.active,
.app-layout .main-menu .sidebar-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

.app-layout .main-menu .sidebar-item:focus-visible {
  outline: 2px solid var(--ig-primary);
  outline-offset: -2px;
}

.app-layout .main-menu .sidebar-item .icon {
  align-items: center;
  display: flex;
  flex-shrink: 0;
  height: 24px;
  justify-content: center;
  width: 24px;
}

.app-layout .main-menu .sidebar-item .label {
  opacity: 0;
  transition: opacity 0.2s ease 0.1s;
}

.app-layout .main-menu.hover-open .sidebar-item .label,
.app-layout .main-menu:hover .sidebar-item .label {
  opacity: 1;
}

/* ── Main content ── */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
}

/* ── Topbar ── */
.app-topbar {
  align-items: center;
  background: var(--ig-surface);
  border-bottom: 1px solid var(--ig-border);
  display: flex;
  height: var(--topbar-height);
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 999;
}

/* ── Bottom nav ── */
.app-bottom-nav {
  align-items: center;
  background: var(--ig-surface);
  border-top: 1px solid var(--ig-border);
  bottom: 0;
  display: none;
  height: var(--bottom-nav-height);
  justify-content: space-around;
  left: 0;
  padding: 0 8px;
  padding-bottom: env(safe-area-inset-bottom, 0);
  position: fixed;
  right: 0;
  z-index: 1000;
}

.app-bottom-nav .nav-item {
  align-items: center;
  color: var(--ig-text-secondary);
  display: flex;
  flex-direction: column;
  font-size: 10px;
  gap: 2px;
  padding: 4px 12px;
  text-decoration: none;
  transition: var(--ig-transition);
  border-radius: var(--ig-radius-sm);
}

.app-bottom-nav .nav-item.active {
  color: var(--ig-primary);
}

.app-bottom-nav .nav-item:focus-visible {
  outline: 2px solid var(--ig-primary);
  outline-offset: 2px;
}

.app-bottom-nav .nav-item .nav-icon {
  font-size: 20px;
  height: 24px;
  width: 24px;
}

/* ── General card ── */
.ig-card {
  background: var(--ig-card);
  border: 1px solid var(--ig-border);
  border-radius: var(--ig-radius);
  box-shadow: var(--ig-shadow);
  overflow: hidden;
  transition: var(--ig-transition);
}

.ig-card:hover {
  box-shadow: var(--ig-shadow-lg);
}

/* ── Story ring ── */
.story-ring {
  align-items: center;
  background: var(--ig-gradient);
  border-radius: 50%;
  display: flex;
  height: 64px;
  justify-content: center;
  padding: 3px;
  width: 64px;
}

.story-ring .story-content {
  align-items: center;
  background: var(--ig-surface);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  font-size: 12px;
  font-weight: 600;
  height: 100%;
  justify-content: center;
  width: 100%;
}

/* ── Stat card ── */
.stat-card {
  padding: 24px;
  position: relative;
  text-align: center;
}

.stat-card .stat-value {
  color: var(--ig-text);
  font-size: 28px;
  font-weight: 700;
}

.stat-card .stat-label {
  color: var(--ig-text-secondary);
  font-size: 13px;
  margin-top: 4px;
}

/* ── Skeleton ── */
.skeleton {
  animation: shimmer 1.5s infinite;
  background: linear-gradient(90deg, #efefef 25%, #f5f5f5 50%, #efefef 75%);
  background-size: 200% 100%;
  border-radius: var(--ig-radius-sm);
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}


/* ── Theme toggle ── */
.theme-toggle-btn,
.theme-toggle-btn-bottom {
  width:36px; height:36px; border-radius:50%;
  border:1px solid var(--ig-border);
  background:var(--ig-surface);
  color:var(--ig-text);
  display:flex; align-items:center; justify-content:center;
  cursor:pointer; transition:var(--ig-transition); padding:0;
}
.theme-toggle-btn:hover,
.theme-toggle-btn-bottom:hover { background:rgba(0,0,0,0.05); border-color:var(--ig-text-secondary); }
/* Bottom nav theme toggle adapts to nav-item layout */
.app-bottom-nav .theme-toggle-btn-bottom {
  width:auto; height:auto;
  border:none; border-radius:0;
  background:transparent !important;
  flex-direction:column; gap:2px;
  padding:6px 8px; min-width:48px;
}
/* Dark mode toggle */
[data-theme="dark"] .theme-toggle-btn,
[data-theme="dark"] .theme-toggle-btn-bottom {
  background:var(--ig-surface-dark);
  border-color:var(--ig-border-dark);
  color:var(--ig-text-dark);
}
[data-theme="dark"] .theme-toggle-btn:hover,
[data-theme="dark"] .theme-toggle-btn-bottom:hover { background:rgba(255,255,255,0.08); border-color:var(--ig-primary); }
[data-theme="dark"] .app-bottom-nav .theme-toggle-btn-bottom { background:transparent !important; border:none; }

/* ── Keyframes (used across components) ── */
@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 210, 106, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(0, 210, 106, 0); }
}

@keyframes pulse-yellow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(255, 193, 7, 0); }
}

/* ── Responsive ── */
@media (max-width: 767.98px) {
  .app-layout .main-menu {
    display: none;
  }

  .app-main {
    margin-bottom: var(--bottom-nav-height);
    margin-left: 0;
    width: 100%;
  }

  .app-bottom-nav {
    display: flex;
  }
}

/* ── Dark mode (opt-in via [data-theme="dark"]) ── */
[data-theme="dark"] {
  --ig-bg: var(--ig-bg-dark);
  --ig-surface: var(--ig-surface-dark);
  --ig-card: var(--ig-card-dark);
  --ig-text: var(--ig-text-dark);
  --ig-border: var(--ig-border-dark);
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .app-layout .main-menu *,
  .ig-card,
  .app-bottom-nav .nav-item,
  .skeleton,
  .story-ring,
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
