/**
 * Lumina Gallery - Modern Core Layout & Grid System
 * Original Mobile-First Architecture with Responsive Floating Controls
 */

/* ==========================================================================
   App Shell & Containers
   ========================================================================== */

.app-container {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  position: relative;
}

/* Adaptive Sidebar (Desktop / Tablet) */
.app-sidebar {
  display: none;
}

@media (min-width: 860px) {
  .app-sidebar {
    display: flex;
    flex-direction: column;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px 16px;
    z-index: 50;
    flex-shrink: 0;
    box-shadow: 1px 0 20px rgba(0, 0, 0, 0.02);
  }
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 20px 8px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 18px;
}

/* Lumina Aurora Prism Logo */
.sidebar-logo-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
  flex-shrink: 0;
  transition: transform var(--duration-quick) var(--ease-lumina);
}

.sidebar-logo-icon:hover {
  transform: scale(1.08) rotate(5deg);
}

.sidebar-logo-icon svg {
  width: 20px;
  height: 20px;
  fill: #ffffff;
  stroke: none;
}

.sidebar-brand-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--text-primary) 30%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  overflow-y: auto;
}

.sidebar-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  padding: 14px 10px 6px 10px;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.92rem;
  position: relative;
  transition: all var(--duration-quick) var(--ease-lumina);
}

.sidebar-nav-item:hover {
  background-color: var(--bg-card-hover);
  color: var(--text-primary);
  transform: translateX(2px);
}

.sidebar-nav-item.active {
  background: var(--accent-subtle);
  color: var(--accent);
  font-weight: 700;
}

.sidebar-nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3.5px;
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
  background: var(--accent-gradient);
}

.sidebar-nav-item svg {
  width: 19px;
  height: 19px;
  stroke: currentColor;
  flex-shrink: 0;
  transition: transform var(--duration-quick) ease;
}

.sidebar-nav-item:hover svg {
  transform: scale(1.1);
}

.sidebar-nav-item.active svg {
  stroke: var(--accent);
}

/* Sidebar Storage Widget */
.sidebar-storage-widget {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-top: auto;
  box-shadow: var(--shadow-sm);
}

.storage-widget-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.storage-progress-bar {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 8px;
}

.storage-progress-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: var(--radius-full);
  transition: width 0.4s var(--ease-lumina);
}

.storage-widget-caption {
  font-size: 0.73rem;
  color: var(--text-tertiary);
  font-weight: 500;
}

/* ==========================================================================
   Main Content Layout
   ========================================================================== */

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding-bottom: calc(var(--tab-bar-height) + var(--safe-bottom) + 24px);
}

@media (min-width: 860px) {
  .app-main {
    padding-bottom: 48px;
  }
}

/* Top App Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg-header);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border-light);
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
}

@media (min-width: 860px) {
  .app-header {
    padding: 0 32px;
  }
}

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

.header-page-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.header-subtitle {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  font-weight: 500;
}

.header-center {
  flex: 1;
  max-width: 440px;
  display: none;
}

@media (min-width: 640px) {
  .header-center {
    display: block;
  }
}

.search-input-wrapper {
  position: relative;
  width: 100%;
}

.search-input-wrapper svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  stroke: var(--text-tertiary);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 38px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 0 14px 0 36px;
  font-size: 0.88rem;
  color: var(--text-primary);
  outline: none;
  transition: all var(--duration-quick) ease;
}

.search-input:focus {
  background: var(--bg-card);
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Button & Action Elements */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  cursor: pointer;
  color: var(--text-primary);
  transition: all var(--duration-quick) var(--ease-lumina);
}

.btn-icon:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-quaternary);
  transform: translateY(-1px);
}

.btn-icon svg {
  width: 18px;
  height: 18px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  background: var(--accent-gradient);
  color: #ffffff !important;
  border: none;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
  transition: all var(--duration-quick) var(--ease-lumina);
}

.btn-primary:hover {
  background: var(--accent-gradient-hover);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.45);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0) scale(0.97);
}

.btn-primary svg {
  width: 16px;
  height: 16px;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all var(--duration-quick) var(--ease-lumina);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-tertiary);
  transform: translateY(-1px);
}

/* Lumina Segmented Capsule Control */
.segmented-control {
  display: inline-flex;
  background: var(--bg-tertiary);
  padding: 3px;
  border-radius: var(--radius-full);
  gap: 2px;
}

.segment-btn {
  padding: 5px 12px;
  border: none;
  background: transparent;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration-quick) var(--ease-lumina);
}

.segment-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   Gallery Grid & Media Elements
   ========================================================================== */

.content-body {
  padding: 16px;
  max-width: 1680px;
  width: 100%;
  margin: 0 auto;
}

@media (min-width: 860px) {
  .content-body {
    padding: 28px 32px;
  }
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

@media (min-width: 480px) {
  .gallery-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }
}

@media (min-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
  }
}

@media (min-width: 1024px) {
  .gallery-grid {
    grid-template-columns: repeat(6, 1fr);
    gap: 14px;
  }
}

@media (min-width: 1440px) {
  .gallery-grid {
    grid-template-columns: repeat(8, 1fr);
    gap: 16px;
  }
}

/* Lumina Squircle Card Item */
.media-card {
  position: relative;
  aspect-ratio: 1 / 1;
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-subtle);
  transition: transform var(--duration-quick) var(--ease-lumina), box-shadow var(--duration-quick) var(--ease-lumina), border-color var(--duration-quick) ease;
}

@media (min-width: 768px) {
  .media-card {
    border-radius: var(--radius-md);
  }
}

.media-card:hover {
  transform: translateY(-2px) scale(1.02);
  z-index: 2;
  box-shadow: var(--shadow-md);
  border-color: var(--accent-subtle);
}

.media-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.media-card:hover img {
  transform: scale(1.04);
}

/* Card Badges */
.card-badge-video {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #ffffff;
  padding: 3px 7px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.card-badge-video svg {
  width: 10px;
  height: 10px;
  fill: #38bdf8;
}

.card-badge-favorite {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f43f5e;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.card-badge-favorite svg {
  width: 14px;
  height: 14px;
  fill: #f43f5e;
}

/* Selection State */
.card-select-overlay {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  border: 2px solid rgba(255, 255, 255, 0.85);
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-quick) var(--ease-lumina);
}

.media-card.selected .card-select-overlay,
.selection-mode-active .card-select-overlay {
  display: flex;
}

.media-card.selected .card-select-overlay {
  background: var(--accent);
  border-color: #ffffff;
  box-shadow: 0 0 10px var(--accent);
}

.card-select-overlay svg {
  width: 12px;
  height: 12px;
  stroke: #ffffff;
  opacity: 0;
}

.media-card.selected .card-select-overlay svg {
  opacity: 1;
}

.media-card.selected {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

/* ==========================================================================
   Mobile-First Floating Capsule Dock
   ========================================================================== */

.mobile-tab-bar {
  position: fixed;
  bottom: 14px;
  left: 14px;
  right: 14px;
  height: 60px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg), 0 0 20px rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  padding: 0 8px;
}

@media (min-width: 860px) {
  .mobile-tab-bar {
    display: none;
  }
}

.tab-bar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-tertiary);
  font-size: 0.68rem;
  font-weight: 600;
  min-width: 52px;
  height: 46px;
  border-radius: var(--radius-full);
  text-decoration: none;
  transition: all var(--duration-quick) var(--ease-lumina);
}

.tab-bar-item:hover,
.tab-bar-item.active {
  color: var(--accent);
}

.tab-bar-item.active {
  background: var(--accent-subtle);
}

.tab-bar-item svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
}

/* Lumina Center Glowing Upload Trigger */
.tab-bar-item.upload-btn-tab {
  background: var(--accent-gradient);
  color: #ffffff !important;
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-glow);
  transform: translateY(-4px);
}

.tab-bar-item.upload-btn-tab:hover {
  transform: translateY(-6px) scale(1.05);
}

.tab-bar-item.upload-btn-tab svg {
  width: 22px;
  height: 22px;
  stroke: #ffffff;
  color: #ffffff;
}

.tab-bar-item.upload-btn-tab span {
  display: none;
}

/* ==========================================================================
   Empty States
   ========================================================================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 64px 20px;
  max-width: 480px;
  margin: 40px auto;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  color: var(--accent);
  margin-bottom: 20px;
  background: var(--accent-subtle);
  padding: 14px;
  border-radius: var(--radius-full);
}

.empty-state-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-state-text {
  font-size: 0.92rem;
  color: var(--text-secondary);
  margin-bottom: 22px;
  line-height: 1.6;
}
