/* ==========================================================================
   ND30 LIVE - Admin Dashboard & Integration Hub Stylesheet
   ========================================================================== */

:root {
  --admin-bg: #0d1117;
  --admin-card: #161b22;
  --admin-card-hover: #1f242c;
  --admin-sidebar: #090d13;
  --admin-border: #30363d;
  
  --admin-red: #ef4444;
  --admin-red-dark: #b91c1c;
  --admin-green: #10b981;
  --admin-blue: #3b82f6;
  --admin-purple: #8b5cf6;
  --admin-amber: #f59e0b;
  
  --admin-text: #f0f6fc;
  --admin-muted: #8b949e;
  --admin-subtle: #484f58;
  
  --font-admin: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body.admin-body {
  font-family: var(--font-admin);
  background: var(--admin-bg);
  color: var(--admin-text);
  min-height: 100vh;
  display: flex;
}

/* Sidebar */
.admin-sidebar {
  width: 260px;
  background: var(--admin-sidebar);
  border-right: 1px solid var(--admin-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
}

.admin-sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--admin-border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-nav {
  padding: 20px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--admin-muted);
  font-size: 0.92rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.admin-nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--admin-text);
}

.admin-nav-item.active {
  background: rgba(239, 68, 68, 0.15);
  color: var(--admin-red);
  font-weight: 600;
  border-left: 3px solid var(--admin-red);
}

.admin-nav-heading {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--admin-subtle);
  padding: 16px 14px 6px;
  font-weight: 700;
}

/* Main Admin Workspace */
.admin-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.admin-header {
  height: 64px;
  background: var(--admin-card);
  border-bottom: 1px solid var(--admin-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
}

.admin-title-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
}

.admin-page-title {
  font-size: 1.25rem;
  font-weight: 700;
}

.admin-content {
  padding: 28px;
  flex: 1;
  overflow-y: auto;
}

/* Cards & Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}

@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.stat-card {
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: 10px;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--admin-muted);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--admin-text);
}

.stat-footer {
  font-size: 0.75rem;
  margin-top: 6px;
  color: var(--admin-green);
}

/* Tabbed Multilingual News Editor */
.multilingual-editor-container {
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.editor-lang-tabs-bar {
  display: flex;
  align-items: center;
  background: #10141d;
  border-bottom: 1px solid var(--admin-border);
  padding: 10px 16px 0;
  gap: 8px;
}

.editor-lang-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 8px 8px 0 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--admin-muted);
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.editor-lang-tab:hover {
  color: var(--admin-text);
  background: rgba(255, 255, 255, 0.04);
}

.editor-lang-tab.active {
  background: var(--admin-card);
  color: #fff;
  border-color: var(--admin-border);
  border-top: 3px solid var(--admin-red);
}

.tab-status-pill {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  font-weight: 700;
}

.status-published { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.status-draft { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.status-empty { background: rgba(139, 148, 158, 0.2); color: #8b949e; }

.tab-actions-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 10px;
}

.btn-ai-translate {
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 10px rgba(124, 58, 237, 0.3);
  transition: all 0.2s ease;
}

.btn-ai-translate:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

/* Editor Form */
.editor-body-panel {
  padding: 24px;
  display: none;
}

.editor-body-panel.active {
  display: block;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}

@media (max-width: 900px) {
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--admin-text);
}

.form-label-desc {
  font-size: 0.75rem;
  color: var(--admin-muted);
  font-weight: 400;
}

.form-control {
  width: 100%;
  background: #090d13;
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--admin-text);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.2s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--admin-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

textarea.form-control {
  resize: vertical;
  min-height: 120px;
  line-height: 1.5;
}

textarea.editor-content-area {
  min-height: 320px;
  font-family: monospace;
  font-size: 0.95rem;
}

/* Action Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--admin-red);
  color: #fff;
}

.btn-primary:hover {
  background: var(--admin-red-dark);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--admin-text);
  border-color: var(--admin-border);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.14);
}

.btn-success {
  background: var(--admin-green);
  color: #fff;
}

.btn-danger {
  background: #dc2626;
  color: #fff;
  border-color: #ef4444;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-warning {
  background: #d97706;
  color: #fff;
  border-color: #f59e0b;
}

.btn-warning:hover {
  background: #b45309;
}

.btn-outline-danger {
  background: transparent;
  border-color: var(--admin-red);
  color: var(--admin-red);
}

.filter-pill {
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.filter-pill:hover {
  filter: brightness(1.2);
  transform: translateY(-1px);
}

.filter-pill.active {
  box-shadow: 0 0 0 2px #fff;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: 6px;
}

/* Tables */
.admin-table-container {
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 24px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.admin-table th {
  background: #11151c;
  color: var(--admin-muted);
  padding: 12px 18px;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  border-bottom: 1px solid var(--admin-border);
}

.admin-table td {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--admin-text);
  vertical-align: middle;
}

.admin-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-success { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.badge-info { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.badge-purple { background: rgba(139, 92, 246, 0.15); color: #a78bfa; }

/* Integrations Hub Cards */
.integrations-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  margin-bottom: 32px;
}

@media (max-width: 900px) {
  .integrations-grid {
    grid-template-columns: 1fr;
  }
}

.integration-card {
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: border-color 0.2s ease;
}

.integration-card:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.integration-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}

.integration-icon-title {
  display: flex;
  align-items: center;
  gap: 14px;
}

.integration-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.integration-card-body {
  font-size: 0.88rem;
  color: var(--admin-muted);
  line-height: 1.5;
  margin-bottom: 20px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal-dialog {
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: 14px;
  width: 100%;
  max-width: 760px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--admin-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--admin-muted);
  font-size: 1.4rem;
  cursor: pointer;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--admin-border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Console Log Box */
.terminal-box {
  background: #05080e;
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  padding: 14px;
  font-family: monospace;
  font-size: 0.85rem;
  color: #38bdf8;
  max-height: 240px;
  overflow-y: auto;
  line-height: 1.6;
}

/* ==========================================================================
   ND30 LIVE - Comprehensive Admin Mobile & Tablet Responsive Architecture
   Fully Optimized for iOS Safari (iPhone / iPad) & Android Chrome
   ========================================================================== */

/* Hamburger Button */
.admin-hamburger-btn {
  display: none;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--admin-border);
  color: var(--admin-text);
  width: 38px;
  height: 38px;
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.admin-hamburger-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--admin-red);
}

/* Sidebar Close Button */
.admin-sidebar-close-btn {
  display: none;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

/* Sidebar Backdrop */
.admin-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1040;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.admin-sidebar-backdrop.active {
  display: block;
  opacity: 1;
  visibility: visible;
}

/* Header Actions */
.admin-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-text-full { display: inline; }
.btn-text-short { display: none; }

.admin-user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.06);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.78rem;
}

.admin-user-name {
  font-weight: 600;
  color: #fff;
}

/* Safe areas on mobile iOS / Android */
body.admin-body {
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* Base Form Control inputs font-size >= 16px on mobile to prevent iOS auto-zoom */
@media (max-width: 768px) {
  .form-control,
  input[type="text"],
  input[type="password"],
  input[type="email"],
  input[type="number"],
  input[type="url"],
  input[type="tel"],
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* --- Tablets & Mobile Devices (max-width: 1024px) --- */
@media (max-width: 1024px) {
  body.admin-body {
    display: block;
    position: relative;
    width: 100%;
    overflow-x: hidden;
  }

  body.admin-body.sidebar-open {
    overflow: hidden;
  }

  /* Transform Sidebar into Off-Canvas Slide Drawer */
  .admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    height: 100vh;
    height: 100dvh;
    z-index: 1050;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: none;
  }

  .admin-sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 35px rgba(0, 0, 0, 0.85);
  }

  .admin-sidebar-close-btn {
    display: flex;
  }

  .admin-hamburger-btn {
    display: flex;
  }

  /* Main Area takes 100% full width */
  .admin-main {
    width: 100%;
    min-width: 0;
    display: block;
  }

  .admin-header {
    padding: 0 16px;
    height: 60px;
  }

  .admin-content {
    padding: 20px 16px;
  }
}

/* --- Mobile Landscape & Small Tablets (max-width: 768px) --- */
@media (max-width: 768px) {
  .admin-page-title {
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
  }

  .admin-title-wrap {
    gap: 10px;
  }

  .admin-header-actions {
    gap: 8px;
  }

  .btn-text-full { display: none; }
  .btn-text-short { display: inline; }

  /* Editor Responsiveness */
  .editor-lang-tabs-bar {
    flex-wrap: wrap;
    padding: 8px 10px 0;
    gap: 6px;
  }

  .editor-lang-tab {
    padding: 9px 12px;
    font-size: 0.86rem;
  }

  .tab-actions-right {
    width: 100%;
    margin-left: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 8px 0;
  }

  .btn-ai-translate {
    width: 100%;
    justify-content: center;
    font-size: 0.78rem;
    padding: 8px 10px;
  }

  .editor-body-panel {
    padding: 16px 12px;
  }

  .form-grid-2 {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }

  /* Tables Fluid Horizontal Scrolling */
  .admin-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }

  .admin-table th,
  .admin-table td {
    padding: 10px 12px;
    font-size: 0.82rem;
    white-space: nowrap;
  }

  /* Grid Layouts in Admin */
  .admin-dashboard-grid,
  .admin-ifttt-grid,
  .admin-notice-grid,
  .admin-ads-grid {
    grid-template-columns: 1fr !important;
    gap: 18px !important;
  }

  .admin-socialqr-form,
  .admin-adsense-form {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
}

/* --- Mobile Phones (Android & iPhone: max-width: 520px) --- */
@media (max-width: 520px) {
  .admin-header {
    padding: 0 12px;
  }

  .admin-content {
    padding: 16px 12px;
  }

  .admin-page-title {
    font-size: 0.98rem;
    max-width: 130px;
  }

  .admin-user-name {
    display: none; /* Hide name on small phone headers to avoid overflow */
  }

  .logout-text {
    display: none; /* Show only door icon on small screens */
  }

  .admin-create-btn {
    padding: 5px 9px;
    font-size: 0.76rem;
  }

  .admin-logout-btn {
    padding: 5px 8px;
  }

  /* Stats grid 1-col on small phones */
  .stats-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }

  /* Editor Buttons full width */
  #publishAllBtn {
    width: 100% !important;
    text-align: center;
    justify-content: center;
    padding: 12px 14px !important;
    font-size: 0.92rem !important;
  }

  #publishCurrentTabBtn,
  #saveDraftsBtn {
    width: 100%;
    justify-content: center;
  }
}
