/* ── Variables ───────────────────────────────────────────────────────────── */
:root {
  --sidebar-bg: #1e1b4b;
  --sidebar-width: 260px;
  --sidebar-accent: #6366f1;
  --sidebar-text: rgba(255, 255, 255, 0.85);
  --sidebar-muted: rgba(255, 255, 255, 0.42);
  --sidebar-hover: rgba(255, 255, 255, 0.08);
  --sidebar-active: rgba(99, 102, 241, 0.28);
  --topbar-h: 60px;
  --content-bg: #f1f5f9;
}

/* ── Base ─────────────────────────────────────────────────────────────────── */
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--content-bg);
}

/* ── App layout ──────────────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 200;
  transition: transform 0.3s ease;
}

.sidebar-brand {
  padding: 1.125rem 1.25rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  letter-spacing: -0.01em;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
  padding: 0.5rem 0.625rem 0.25rem;
  margin-top: 0.25rem;
}

.nav-link-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.875rem;
  border-radius: 0.5rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  margin-bottom: 2px;
}
.nav-link-item i {
  font-size: 1rem;
  flex-shrink: 0;
  opacity: 0.8;
}
.nav-link-item:hover {
  background: var(--sidebar-hover);
  color: #fff;
}
.nav-link-item:hover i {
  opacity: 1;
}
.nav-link-item.active {
  background: var(--sidebar-active);
  color: #fff;
}
.nav-link-item.active i {
  opacity: 1;
}

.sidebar-footer {
  padding: 0.875rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.sidebar-avatar {
  font-size: 1.75rem;
  color: var(--sidebar-muted);
  line-height: 1;
}
.sidebar-user-email {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-type {
  font-size: 0.7rem;
  color: var(--sidebar-muted);
  text-transform: capitalize;
}

/* ── Main wrapper ─────────────────────────────────────────────────────────── */
.main-wrapper {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Topbar ─────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  flex-shrink: 0;
}

/* ── Page content ─────────────────────────────────────────────────────────── */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  background: var(--content-bg);
}

/* ── Sidebar overlay (mobile) ─────────────────────────────────────────────── */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 190;
}

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
  border: none;
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.05);
}
.card-header {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 1rem 1.25rem;
  border-radius: 0.75rem 0.75rem 0 0 !important;
}

/* ── Stat cards ──────────────────────────────────────────────────────────── */
.stat-card {
  transition: transform 0.15s, box-shadow 0.15s;
  cursor: pointer;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}
.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 0.625rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
}

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table-card {
  overflow: hidden;
}
.table-card .table {
  margin-bottom: 0;
}
.table th {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  background: #f8fafc;
  border-bottom-width: 1px;
  padding: 0.75rem 1rem;
  white-space: nowrap;
}
.table td {
  vertical-align: middle;
  font-size: 0.875rem;
  padding: 0.625rem 1rem;
  border-color: #f1f5f9;
}
.table-hover tbody tr:hover td {
  background: #f8fafc;
}

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge-status {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.3em 0.65em;
  border-radius: 999px;
}

/* ── Image thumbnails ─────────────────────────────────────────────────────── */
.img-thumb {
  width: 38px;
  height: 38px;
  object-fit: cover;
  border-radius: 0.375rem;
  background: #e2e8f0;
  display: block;
  flex-shrink: 0;
}
.img-placeholder {
  width: 38px;
  height: 38px;
  border-radius: 0.375rem;
  background: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 1rem;
  flex-shrink: 0;
}

/* ── Preview ─────────────────────────────────────────────────────────────── */
.img-preview-box {
  width: 100px;
  height: 80px;
  border-radius: 0.5rem;
  background: #e2e8f0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 2px dashed #cbd5e1;
}
.img-preview-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.img-preview-box i {
  font-size: 1.5rem;
  color: #94a3b8;
}

/* ── Action buttons ───────────────────────────────────────────────────────── */
.btn-action {
  padding: 0.2rem 0.45rem;
  font-size: 0.8rem;
  line-height: 1.2;
}

/* ── Storage grid ─────────────────────────────────────────────────────────── */
.storage-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 0.5rem;
  overflow: hidden;
  background: #e2e8f0;
  cursor: pointer;
}
.storage-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.storage-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  opacity: 0;
  transition: opacity 0.18s;
}
.storage-item:hover .storage-overlay {
  opacity: 1;
}
.storage-key {
  font-size: 0.68rem;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.25rem;
}

/* ── Page loading ─────────────────────────────────────────────────────────── */
.page-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 240px;
  color: #64748b;
  gap: 0.75rem;
}
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #94a3b8;
}
.empty-state i {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 0.5rem;
}

/* ── Confirm modal ────────────────────────────────────────────────────────── */
.confirm-modal-content {
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
  border-radius: 1rem !important;
}
.confirm-modal-strip {
  height: 5px;
  background: linear-gradient(90deg, #ef4444, #dc2626);
  border-radius: 1rem 1rem 0 0;
}
.confirm-modal-icon {
  width: 64px;
  height: 64px;
  background: #fee2e2;
  color: #dc2626;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  margin: 0 auto;
}

/* ── Lightbox ─────────────────────────────────────────────────────────────── */
.lightbox-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: lb-fade .15s ease;
}
@keyframes lb-fade { from { opacity: 0 } to { opacity: 1 } }

.lightbox-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 92vw;
  max-height: 92vh;
}
.lightbox-content #lightbox-img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 0.5rem;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  object-fit: contain;
}
.lightbox-label {
  color: rgba(255,255,255,0.75);
  font-size: 0.8rem;
  margin-top: 0.75rem;
  word-break: break-all;
  text-align: center;
}
.lightbox-actions { opacity: 0.85; }
.lightbox-close {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  font-size: 1.25rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s;
  z-index: 9001;
}
.lightbox-close:hover { background: rgba(255,255,255,0.25); }

/* ── Login ────────────────────────────────────────────────────────────────── */
.login-bg {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4338ca 100%);
}
.login-card {
  width: 100%;
  max-width: 420px;
  border-radius: 1rem;
}
.login-logo {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #6366f1, #818cf8);
  border-radius: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  color: #fff;
  font-size: 1.75rem;
}

/* ── Form ────────────────────────────────────────────────────────────────── */
.form-label {
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
}
.form-control, .form-select {
  font-size: 0.875rem;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 991.98px) {
  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    transform: translateX(-100%);
  }
  #sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
  }
  .app-layout {
    flex-direction: column;
  }
}
