@import url('https://fonts.googleapis.com/css2?family=Hind+Siliguri:wght@400;500;600;700&display=swap');

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --success-light: #dcfce7;
  --danger: #dc2626;
  --warning: #d97706;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --radius: 12px;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Hind Siliguri', sans-serif;
}

body {
  background-color: var(--bg);
  color: var(--text-main);
  min-height: 100vh;
  min-width: 1200px;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1e293b;
}

.brand-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.nav-tabs {
  display: flex;
  gap: 8px;
}

.tab-btn {
  padding: 8px 18px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tab-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.tab-btn.active {
  background: var(--primary);
  color: #ffffff;
}

/* Main Container */
.container {
  max-width: 1280px;
  margin: 2rem auto;
  padding: 0 1.5rem;
  flex: 1;
  width: 100%;
}

.tab-content {
  display: none;
}

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

/* Card & Sections */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #1e293b;
}

.section-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.4rem;
  font-size: 0.95rem;
  color: #334155;
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.2s ease;
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

textarea.form-control {
  resize: vertical;
  min-height: 180px;
}

/* Image Upload Area */
.upload-dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: 10px;
  padding: 2rem;
  text-align: center;
  background: #f8fafc;
  cursor: pointer;
  transition: all 0.2s;
}

.upload-dropzone:hover {
  border-color: var(--primary);
  background: #eff6ff;
}

.upload-icon {
  font-size: 2.5rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.image-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  margin-top: 1rem;
}

.preview-thumb {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--border);
  aspect-ratio: 16/10;
  background: #000;
}

.preview-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-thumb .img-num {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(0,0,0,0.75);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: bold;
}

.preview-thumb .remove-img-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(220, 38, 38, 0.85);
  color: #fff;
  border: none;
  border-radius: 4px;
  width: 22px;
  height: 22px;
  cursor: pointer;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

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

.btn-success {
  background: var(--success);
  color: #ffffff;
}

.btn-success:hover {
  background: #15803d;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-main);
}

.btn-outline:hover {
  background: #f1f5f9;
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

/* Variations Grid */
.variations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.portal-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, box-shadow 0.2s;
}

.portal-card:hover {
  box-shadow: var(--shadow-lg);
}

.portal-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #f1f5f9;
}

.portal-badge {
  background: #e0f2fe;
  color: #0369a1;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.portal-image-select {
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.portal-image-thumb {
  width: 60px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border);
}

/* Results Table & Cards */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.result-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.result-card.success {
  border-top: 4px solid var(--success);
}

.result-card.failed {
  border-top: 4px solid var(--danger);
}

.news-card-preview {
  margin-top: 1rem;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #f1f5f9;
  text-align: center;
}

.news-card-preview img {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  display: block;
}

/* Portals Table */
.table-responsive {
  overflow-x: auto;
}

.portals-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.portals-table th, .portals-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}

.portals-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
}

/* Alert Notification Banner */
.banner-info {
  background: #e0f2fe;
  border-left: 4px solid #0284c7;
  padding: 1rem;
  border-radius: 6px;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
  color: #0c4a6e;
}

/* History Management Styles */
.history-item-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
  transition: all 0.2s;
}

.history-item-card:hover {
  box-shadow: var(--shadow-lg);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  cursor: pointer;
}

.history-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #1e293b;
}

.history-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  gap: 16px;
  align-items: center;
  margin-top: 4px;
}

.history-details {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid #f1f5f9;
}

.history-portal-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.history-portal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.badge-deleted {
  background: #fee2e2;
  color: #b91c1c;
  font-size: 0.78rem;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
}

.badge-active {
  background: #dcfce7;
  color: #15803d;
  font-size: 0.78rem;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
}

.edit-panel {
  display: none;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 1rem;
  margin-top: 10px;
}

.edit-panel.active {
  display: block;
}

/* 14 Headlines Suggestions Grid */
.headlines-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 10px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 6px;
}

.headline-item {
  background: #ffffff;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
  transition: all 0.2s;
}

.headline-item:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 4px rgba(37,99,235,0.1);
}

.headline-num {
  font-size: 0.8rem;
  font-weight: 700;
  color: #0284c7;
  background: #e0f2fe;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

.headline-text {
  font-size: 0.92rem;
  font-weight: 600;
  color: #1e293b;
  flex: 1;
  line-height: 1.35;
}

@keyframes popInNew {
  0% { transform: scale(0.96); background-color: #fef08a; border-color: #eab308; }
  100% { transform: scale(1); background-color: #ffffff; border-color: #bae6fd; }
}

.headline-item.just-added {
  animation: popInNew 1.8s ease-out;
  border-color: #f59e0b;
}

.badge-new-headline {
  background: #f59e0b;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 6px;
  display: inline-block;
  vertical-align: middle;
}

.flash-success {
  animation: flashGreen 1.2s ease;
}

@keyframes flashGreen {
  0% { background-color: #bbf7d0; border-color: #22c55e; }
  100% { background-color: #ffffff; border-color: var(--border); }
}

/* Category Checkbox Grid (6+6 in 2 lines) */
.category-grid-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.category-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

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

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

.cat-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease-in-out;
}

.cat-chip:hover {
  background: #f1f5f9;
  border-color: var(--primary);
}

.cat-chip input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.cat-chip.special-cat {
  border-color: #93c5fd;
  background: #f0f9ff;
  color: #0369a1;
}

.cat-chip.active,
.cat-chip:has(input:checked) {
  background: #dbeafe !important;
  border-color: #2563eb !important;
  color: #1d4ed8 !important;
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(37, 99, 235, 0.25);
}

/* Selected Category Summary Bar inside Portal Cards */
.portal-cat-summary-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  padding: 6px 10px;
  margin-bottom: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #166534;
}

.portal-cat-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #16a34a;
  color: #ffffff;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  letter-spacing: 0.2px;
}

/* Compact portal category chips inside preview cards */
.portal-cats-compact-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 115px;
  overflow-y: auto;
  padding: 6px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
}

.portal-cat-mini {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 7px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease-in-out;
}

.portal-cat-mini.active,
.portal-cat-mini:has(input:checked) {
  background: #dbeafe !important;
  border-color: #2563eb !important;
  color: #1d4ed8 !important;
  font-weight: 700;
}

@keyframes slideInDown {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes pulseRed {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.pulse-red-badge {
  animation: pulseRed 1.5s infinite ease-in-out;
}

