/* ==========================================================================
   Broken Wings Initiative (BWI) - Real-Time Admin CMS Portal Styles
   ========================================================================== */

/* Centring and spacing are handled by .portal-stage in admin.html, so this
   wrapper only needs to fill it. No min-height here: inside the isolated
   portal the stage already owns vertical centring, and a 70vh floor would
   push the login card off-centre and add a phantom scrollbar. */
.admin-auth-container {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 3rem 2.5rem;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
}

.auth-card-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-logo {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  background: var(--dark-slate);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  margin: 0 auto 1.2rem;
}

.auth-card-header h2 {
  font-size: 1.6rem;
  margin-bottom: 0.35rem;
}

.auth-card-header p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.password-input-wrap {
  position: relative;
}

.btn-toggle-pwd {
  position: absolute;
  right: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.4rem;
}

.auth-error {
  background: #fff0f3;
  color: var(--primary-red);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1.2rem;
  border-left: 3px solid var(--primary-red);
}

/* Inline field validation on the login form. The red border only appears
   after a field has been touched, so a pristine form never looks broken. */
.auth-form .form-error {
  display: block;
  min-height: 1rem;
  margin-top: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--primary-red);
}

.auth-form .form-error:empty {
  min-height: 0;
  margin-top: 0;
}

.auth-form input.is-invalid {
  border-color: var(--primary-red);
  background: #fff5f5;
}

.auth-form input.is-invalid:focus {
  border-color: #c1121f;
  box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.15);
}

.auth-footer-help {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.88rem;
}

.back-link {
  color: var(--text-muted);
}

.back-link:hover {
  color: var(--primary-red);
}

/* ==========================================================================
   CMS DASHBOARD SHELL
   ========================================================================== */

.cms-dashboard {
  background: #ffffff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  margin: 2rem 0 4rem;
}

.cms-header {
  background: var(--dark-slate);
  color: #ffffff;
  padding: 1.6rem 2.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cms-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.cms-badge {
  background: var(--primary-red);
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 800;
  padding: 0.25rem 0.7rem;
  border-radius: var(--radius-full);
}

.cms-header h2 {
  font-size: 1.35rem;
  color: #ffffff;
}

.cms-user-controls {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

/* Static role badge for the signed-in operator. Presentation only: it carries
   no identity claim of its own and no credential data. */
.cms-user-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 4px 12px;
  border-radius: 4px;
  white-space: nowrap;
}

.cms-user-badge i {
  font-size: 0.75rem;
  opacity: 0.9;
}

/* Stats Bar */
.cms-stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
  padding: 1.8rem 2.2rem;
  background: #f8f9fa;
  border-bottom: 1px solid var(--border-color);
}

.cms-stat-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.2rem 1.4rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: #ffffff;
}

.stat-icon.bg-red { background: var(--primary-red); }
.stat-icon.bg-navy { background: var(--dark-slate); }
.stat-icon.bg-teal { background: var(--teal-green); }
.stat-icon.bg-amber { background: var(--amber-gold); }

.stat-info .stat-count {
  display: block;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--dark-slate);
  line-height: 1.1;
}

.stat-info .stat-title {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Nav Tabs */
.cms-nav-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background: #ffffff;
  padding: 0 1.5rem;
  overflow-x: auto;
}

.cms-tab-btn {
  padding: 1.1rem 1.4rem;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-gray);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  transition: var(--transition);
}

.cms-tab-btn:hover {
  color: var(--primary-red);
}

.cms-tab-btn.active {
  color: var(--primary-red);
  border-bottom-color: var(--primary-red);
}

.cms-tab-content {
  padding: 2.5rem 2.2rem;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

.cms-topbar-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

/* ==========================================================================
   WYSIWYG EDITOR & ARTICLE COMPOSER
   ========================================================================== */

.news-manager-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.news-editor-card, .story-editor-card {
  background: #ffffff;
  border: 2px solid var(--blue-accent);
  border-radius: var(--radius-md);
  padding: 2.2rem;
  margin-bottom: 2.5rem;
  box-shadow: var(--shadow-md);
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.8rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.btn-close-editor {
  background: none;
  border: none;
  font-size: 1.6rem;
  color: var(--text-muted);
  cursor: pointer;
}

.cover-image-input-group {
  display: flex;
  gap: 0.8rem;
}

.image-preview-slot {
  margin-top: 0.8rem;
  max-width: 320px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.image-preview-slot img {
  width: 100%;
  height: 160px;
  object-fit: cover;
}

/* WYSIWYG Toolbar */
.wysiwyg-container {
  margin-bottom: 1.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.wysiwyg-label {
  display: block;
  background: #f1f3f5;
  padding: 0.5rem 1rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--dark-slate);
  border-bottom: 1px solid var(--border-color);
}

.wysiwyg-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.8rem;
  background: #fafafa;
  border-bottom: 1px solid var(--border-color);
}

.tool-btn {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dark-slate);
  cursor: pointer;
  font-size: 0.88rem;
  transition: var(--transition);
}

.tool-btn:hover {
  background: var(--dark-slate-soft);
  border-color: var(--dark-slate);
}

.tool-sep {
  width: 1px;
  height: 20px;
  background: var(--border-color);
  margin: 0 0.25rem;
}

.wysiwyg-content {
  min-height: 220px;
  max-height: 480px;
  overflow-y: auto;
  padding: 1.2rem;
  background: #ffffff;
  font-size: 0.95rem;
  line-height: 1.6;
}

.wysiwyg-content:focus {
  outline: none;
}

.editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 1.5rem;
}

/* CMS Data Tables */
.table-responsive {
  overflow-x: auto;
}

.cms-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.cms-table th {
  text-align: left;
  padding: 0.9rem 1rem;
  background: #f8f9fa;
  color: var(--dark-slate);
  font-weight: 700;
  border-bottom: 2px solid var(--border-color);
}

.cms-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.table-thumb {
  width: 64px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
}

.table-excerpt {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0.2rem 0 0;
}

.badge-cat {
  background: rgba(69, 123, 157, 0.12);
  color: var(--blue-accent);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
}

.btn-action {
  background: none;
  border: 1px solid var(--border-color);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  margin-right: 0.3rem;
  color: var(--text-gray);
  transition: var(--transition);
}

.btn-action:hover {
  background: var(--dark-slate);
  color: #ffffff;
}

.btn-action.delete-btn:hover {
  background: var(--primary-red);
  border-color: var(--primary-red);
  color: #ffffff;
}

/* ==========================================================================
   MEDIA & IMAGE UPLOADER
   ========================================================================== */

.upload-dropzone {
  border: 2px dashed var(--blue-accent);
  background: #f8fafd;
  border-radius: var(--radius-md);
  padding: 3rem 2rem;
  text-align: center;
  margin-bottom: 3rem;
  transition: var(--transition);
}

.upload-dropzone.drag-active {
  background: #e2eafc;
  border-color: var(--primary-red);
}

.upload-icon-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--primary-red-soft);
  color: var(--primary-red);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin: 0 auto 1.2rem;
}

.btn-browse-link {
  background: none;
  border: none;
  color: var(--primary-red);
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

.dropzone-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.upload-staging {
  display: flex;
  gap: 2rem;
  text-align: left;
  align-items: center;
}

.staging-preview img {
  width: 220px;
  height: 150px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.staging-form {
  flex: 1;
}

.staging-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
}

/* Media Gallery Grid */
.media-gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
}

.media-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.media-card-img {
  height: 150px;
  overflow: hidden;
}

.media-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-card-info {
  padding: 0.8rem 1rem;
}

.media-name {
  display: block;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--dark-slate);
}

.media-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.media-card-actions {
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
}

.btn-media-action {
  background: none;
  border: none;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--text-gray);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.btn-media-action:hover {
  color: var(--primary-red);
}

/* ==========================================================================
   INQUIRIES & BACKUP LAYOUTS
   ========================================================================== */

.inquiries-grid-dual {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 2rem;
}

.inquiry-item {
  background: #f8f9fa;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1.2rem;
  margin-bottom: 1rem;
}

.inquiry-item.unread {
  border-left: 4px solid var(--primary-red);
  background: #ffffff;
}

.inq-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.inq-contact {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  gap: 1rem;
  margin-bottom: 0.6rem;
}

.inq-body {
  font-size: 0.88rem;
  color: var(--dark-slate);
}

.settings-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  margin-top: 2rem;
}

.setting-action-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 2.2rem 1.8rem;
  text-align: center;
}

.setting-action-card.danger-card {
  border-color: #ffccd5;
  background: #fffafa;
}

.action-icon {
  font-size: 2.2rem;
  margin-bottom: 1rem;
}

.setting-action-card h4 {
  margin-bottom: 0.6rem;
}

.setting-action-card p {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

@media (max-width: 992px) {
  .cms-stats-bar, .media-gallery-grid, .settings-cards-grid, .inquiries-grid-dual {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .cms-user-badge {
    display: none;
  }
}
