/* Prevent horizontal overflow on mobile viewports */
html, body {
  max-width: 100%;
  overflow-x: hidden;
}

#panel[hidden],
#panel[hidden] ~ .savebar,
#panel[hidden] .savebar,
#loginCard[hidden] {
  display: none !important;
}

.adminbody {
  background: #f1f4f8;
  color: #1e293b;
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Professional Login View */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: radial-gradient(circle at 50% 20%, #ffffff 0%, #eef2f6 100%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: #ffffff;
  border-radius: 20px;
  padding: 30px 22px;
  box-shadow: 0 16px 40px -10px rgba(15, 23, 42, 0.08), 0 0 0 1px rgba(226, 232, 240, 0.8);
  text-align: center;
  box-sizing: border-box;
}

.login-brand {
  margin-bottom: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.login-logo-wrap {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: #101828;
  color: #fff;
  display: grid;
  place-content: center;
  box-shadow: 0 8px 18px rgba(16, 24, 40, 0.15);
}

.login-logo-wrap svg {
  stroke: #ffffff;
}

.login-brand h1 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin: 0;
  color: #0f172a;
}

.login-brand p {
  margin: 0;
  color: #64748b;
  font-size: 13px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
  width: 100%;
}

.input-group {
  width: 100%;
  box-sizing: border-box;
}

.input-group label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: #334155;
  margin-bottom: 6px;
}

.input-field {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  border-radius: 10px;
  padding: 12px 14px;
  font: inherit;
  font-size: 14px;
  color: #0f172a;
  outline: none;
  transition: all 0.2s ease;
}

.input-field:focus {
  border-color: #101828;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(16, 24, 40, 0.08);
}

.login-btn {
  width: 100%;
  padding: 12px;
  margin-top: 6px;
  font-size: 14px;
  border-radius: 10px;
}

/* Dashboard Layout */
.admin-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
  position: relative;
}

/* Sidebar */
.sidebar {
  width: 250px;
  max-width: 80vw;
  background: #0c1715;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 100;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

.sidebar-brand {
  padding: 20px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-title {
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.3px;
}

.sidebar-nav {
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: #94a3b8;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: all 0.15s ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.nav-item.active {
  background: #d6a84f;
  color: #0c1715;
  font-weight: 700;
}

.nav-item svg {
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-badge {
  font-size: 11px;
  color: #94a3b8;
  word-break: break-all;
}

/* Main Area */
.main-wrapper {
  flex: 1;
  margin-left: 250px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.topbar {
  height: 60px;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 40;
  box-sizing: border-box;
}

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

.menu-toggle {
  display: none;
  background: none;
  border: 0;
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
  color: #0f172a;
}

.topbar-title {
  font-size: 17px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-content {
  padding: 20px;
  max-width: 1000px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
  padding-bottom: 120px;
}

.card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
  margin-bottom: 16px;
  box-sizing: border-box;
  width: 100%;
  overflow: hidden;
}

.grid2 {
  display: grid;
  gap: 14px;
  width: 100%;
  box-sizing: border-box;
}

@media (min-width: 768px) {
  .grid2 {
    grid-template-columns: 1fr 1fr;
  }
}

.field-item {
  width: 100%;
  box-sizing: border-box;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #475467;
  margin: 10px 0 5px;
}

input, textarea {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease;
}

input:focus, textarea:focus {
  border-color: #101828;
}

textarea {
  min-height: 85px;
  resize: vertical;
}

/* Save Bar */
.savebar {
  position: fixed;
  left: 250px;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-top: 1px solid #e2e8f0;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  gap: 14px;
  align-items: center;
  z-index: 50;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.03);
  box-sizing: border-box;
}

.crow {
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 14px;
  background: #f8fafc;
  margin-bottom: 14px;
  box-sizing: border-box;
  width: 100%;
}

.crow .row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.danger {
  background: #fee4e2;
  color: #b42318;
}

.picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 6px;
  margin: 12px 0;
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  padding: 10px;
  border-radius: 10px;
  background: #fff;
  box-sizing: border-box;
}

.picker label {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0;
  font-weight: 600;
  background: #f8fafc;
  padding: 7px 9px;
  border-radius: 6px;
  font-size: 13px;
}

.picker input {
  width: auto;
}

.upload-box {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  padding: 12px;
  border-radius: 10px;
  margin-top: 6px;
  box-sizing: border-box;
}

.upload-box input[type="file"] {
  padding: 6px 0;
  background: transparent;
  border: none;
}

.upload-preview {
  max-height: 75px;
  max-width: 100%;
  border-radius: 8px;
  margin-top: 8px;
  display: block;
  border: 1px solid #e2e8f0;
  object-fit: contain;
}

.mapprev {
  width: 100%;
  max-width: 320px;
  margin: 14px auto;
  box-sizing: border-box;
}

.ok { color: #176b57; font-weight: 700; font-size: 13px; }
.err { color: #b42318; font-weight: 600; font-size: 13px; margin: 4px 0 0; }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  z-index: 90;
}

/* Phone Layout Adjustments */
@media (max-width: 860px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop.active {
    display: block;
  }

  .main-wrapper {
    margin-left: 0;
    width: 100vw;
  }

  .topbar {
    padding: 0 14px;
  }

  .menu-toggle {
    display: block;
  }

  .admin-content {
    padding: 14px;
    width: 100%;
  }

  .savebar {
    left: 0;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  }

  .picker {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  }
}

/* 16:9 Aspect Ratio Container for Admin Previews */
.preview-16-9-box {
  width: 100%;
  max-width: 380px;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  margin-top: 10px;
  background: #0c1715;
  border: 1px solid #cbd5e1;
  position: relative;
}

.preview-16-9-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
/* Spinner for Save Loading Animation */
.btn-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  border-top-color: #ffffff;
  animation: btnSpin 0.7s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

.btn.outline .btn-spinner {
  border-color: rgba(16, 24, 40, 0.2);
  border-top-color: #101828;
}

@keyframes btnSpin {
  to { transform: rotate(360deg); }
}

.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none !important;
}