/* Data Stories Edit Form CSS - UNESCO Design System */
/* Aligned with rapid-response styling */

:root {
  --unesco-blue: #0072BC;
  --unesco-blue-dark: #005A9C;
  --unesco-blue-light: #009EE0;
  --unesco-blue-pale: #E3F2FD;
  --unesco-gray: #f8f9fa;
  --text-primary: #2c3e50;
  --text-secondary: #6c757d;
  --shadow-light: 0 2px 8px rgba(0, 114, 188, 0.08);
  --shadow-medium: 0 4px 16px rgba(0, 114, 188, 0.12);
  --shadow-strong: 0 8px 32px rgba(0, 114, 188, 0.16);
}

/* Layout containers (aligned with Rapid Response) - Scoped to data stories page */
.homepage.layout-1 {
  background: #f8f9fa;
  min-height: 100vh;
}

.homepage.layout-1 .main {
  padding-bottom: 3rem;
}

/* Full width layout for edit page (no sidebar) */
.data-stories-form-wrapper .primary {
  width: 100%;
  max-width: 100%;
}

.homepage.layout-1 .toolbar,
.homepage.layout-1 .container {
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
}

/* Remove Bootstrap grid borders for layout only - More specific selectors */
.homepage.layout-1 .row,
.homepage.layout-1 .primary,
.homepage.layout-1 .secondary {
  border: none;
  background: transparent;
  box-shadow: none;
}

/* Breadcrumb (aligned with Rapid Response) - Scoped to data stories */
.homepage.layout-1 .toolbar {
  margin-bottom: 2rem;
  padding: 1rem 0;
}

.homepage.layout-1 .breadcrumb {
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  padding: 12px 20px;
  margin: 0;
  border-radius: 12px;
  border: 1px solid #e9ecef;
  box-shadow: var(--shadow-light);
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  list-style: none;
}

.homepage.layout-1 .breadcrumb > li {
  display: inline-flex;
  align-items: center;
  line-height: 1.5;
}

.homepage.layout-1 .breadcrumb > li + li:before {
  content: "›";
  padding: 0 12px;
  color: var(--text-secondary);
  font-weight: 600;
  line-height: 1;
}

.homepage.layout-1 .breadcrumb > li.active {
  color: var(--unesco-blue);
  font-weight: 600;
}

.homepage.layout-1 .breadcrumb > li a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.homepage.layout-1 .breadcrumb > li a:hover {
  color: var(--unesco-blue);
}

.homepage.layout-1 .breadcrumb > li.home a i {
  font-size: 1rem;
}

/* Header Banner (aligned with Rapid Response) - Scoped to data stories */
.homepage.layout-1 .section-title {
  position: relative;
  height: 300px;
  overflow: hidden;
  border-radius: 16px;
  margin-bottom: 3rem;
  box-shadow: var(--shadow-strong);
}

.homepage.layout-1 .section-title-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-image: linear-gradient(135deg, #0072BC 0%, #009EE0 100%);
  filter: brightness(0.8);
  transition: transform 0.3s ease;
}

.homepage.layout-1 .section-title:hover .section-title-bg {
  transform: scale(1.02);
}

.homepage.layout-1 .section-title-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(0, 114, 188, 0.9) 0%, rgba(0, 158, 224, 0.8) 100%);
}

.homepage.layout-1 .section-title-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: white;
  z-index: 10;
  width: 90%;
  max-width: 700px;
}

.homepage.layout-1 .section-title-content h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  text-shadow: 2px 2px 8px rgba(0,0,0,0.4);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.homepage.layout-1 .section-title-description {
  font-size: 1.2rem;
  margin-bottom: 0;
  opacity: 0.95;
  text-shadow: 1px 1px 4px rgba(0,0,0,0.4);
  font-weight: 300;
  line-height: 1.4;
}

/* Form wrapper (aligned with Rapid Response) */
.data-stories-form-wrapper {
  margin-bottom: 3rem;
}

.data-stories-form-wrapper .module {
  background: #fff;
  border: none;
  border-radius: 20px;
  box-shadow: var(--shadow-medium);
  transition: all 0.3s ease;
  overflow: hidden;
  margin-bottom: 2rem;
}

.data-stories-form-wrapper .module:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-strong);
}

.data-stories-form-wrapper .module-content {
  padding: 2.5rem;
}

/* Form styling */
.data-stories-form fieldset {
  margin: 0 0 3rem 0;
  padding: 0 2.5rem 2rem 2.5rem;
  border: none;
  border-radius: 20px;
  background: #fff;
  box-shadow: var(--shadow-medium);
  transition: all 0.3s ease;
  overflow: hidden;
  border-left: 6px solid var(--unesco-blue);
  position: relative;
  z-index: 1;
  width: 100%;
  box-sizing: border-box;
}

.data-stories-form fieldset:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-strong);
}

.data-stories-form legend {
  background: linear-gradient(135deg, var(--unesco-blue-pale) 0%, #ffffff 100%);
  color: var(--unesco-blue);
  font-weight: 700;
  padding: 1.5rem 2rem;
  margin: 0 0 2rem 0;
  font-size: 1.4rem;
  border: none;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
  border-bottom: 3px solid var(--unesco-blue-pale);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  position: relative;
  z-index: 2;
  box-sizing: border-box;
}

.data-stories-form legend::before {
  content: '';
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--unesco-blue) 0%, var(--unesco-blue-light) 100%);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-light);
}

.data-stories-form legend::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 2rem;
  width: 60px;
  height: 3px;
  background: linear-gradient(90deg, var(--unesco-blue) 0%, var(--unesco-blue-light) 100%);
  border-radius: 2px;
}

/* Form groups inside fieldsets need no extra margin (padding from fieldset) */
.data-stories-form fieldset > .form-group {
  margin-bottom: 1.5rem;
}

/* Last element in fieldset */
.data-stories-form fieldset > *:last-child {
  margin-bottom: 0;
}

/* Help block at top of fieldset */
.data-stories-form fieldset > p.help-block {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  background: transparent;
  border-bottom: 1px solid #e9ecef;
  color: var(--text-secondary);
}

/* Alert info boxes inside fieldsets */
.data-stories-form fieldset > .alert {
  margin-bottom: 1.5rem;
  padding: 1.5rem;
  border-radius: 12px;
  border: none;
}

.data-stories-form fieldset .alert.alert-info {
  background: linear-gradient(135deg, #E3F2FD 0%, #ffffff 100%) !important;
  border-left: 4px solid var(--unesco-blue) !important;
}

/* Sections container */
.data-stories-form #sections-container {
  margin-bottom: 1.5rem;
}

.data-stories-form #sections-container > p.text-muted {
  padding: 1.5rem;
  margin: 0;
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  border-radius: 12px;
  border: 2px dashed #dee2e6;
  text-align: center;
  color: var(--text-secondary);
}

/* Table styling inside fieldsets */
.data-stories-form fieldset .table-responsive {
  margin-bottom: 1rem;
}

.data-stories-form fieldset .table {
  margin-bottom: 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e9ecef;
}

.data-stories-form fieldset .table thead th {
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  border-bottom: 2px solid #e9ecef;
  color: var(--text-primary);
  font-weight: 600;
  padding: 1rem;
}

.data-stories-form fieldset .table tbody td {
  padding: 1rem;
  vertical-align: middle;
  border-bottom: 1px solid #e9ecef;
}

.data-stories-form fieldset .table tbody tr:last-child td {
  border-bottom: none;
}

.data-stories-form fieldset .table .empty-state td {
  text-align: center;
  color: var(--text-secondary);
  font-style: italic;
  padding: 2rem 1rem;
}

/* Form inline (for datasets input) */
.data-stories-form fieldset .form-inline {
  margin-bottom: 1.5rem;
}

/* Input group styling */
.data-stories-form .input-group {
  display: flex;
  align-items: stretch;
  width: 100%;
}

.data-stories-form .input-group .input-group-addon {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, #E3F2FD 0%, #ffffff 100%);
  border: 2px solid #e9ecef;
  border-right: none;
  border-radius: 12px 0 0 12px;
  color: var(--unesco-blue);
  font-weight: 600;
  flex-shrink: 0;
}

.data-stories-form .input-group .form-control {
  border-radius: 0;
  border-left: none;
  flex: 1;
  min-width: 0;
}

.data-stories-form .input-group .form-control:last-child,
.data-stories-form .input-group .form-control:only-child {
  border-radius: 0 12px 12px 0;
}

.data-stories-form .input-group .input-group-btn {
  display: flex;
}

.data-stories-form .input-group .input-group-btn .btn {
  border-radius: 0 12px 12px 0;
  margin-left: -1px;
}

/* Form actions - Scoped to data stories */
.data-stories-form .form-actions {
  margin-top: 3rem;
  padding: 2rem;
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  border-radius: 16px;
  border: 2px solid #e9ecef;
  display: flex;
  gap: 1rem;
  align-items: center;
}

.data-stories-form .form-actions .pull-right {
  margin-left: auto;
}

/* Section Editor Styling - Scoped to data stories form */
.data-stories-form .content-section-editor {
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow-medium);
  margin-bottom: 2rem;
  border-left: 5px solid var(--unesco-blue);
  transition: all 0.3s ease;
  overflow: hidden;
}

.data-stories-form .content-section-editor:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-strong);
}

.data-stories-form .section-header {
  background: linear-gradient(135deg, var(--unesco-blue-pale) 0%, #ffffff 100%);
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--unesco-blue-pale);
}

.data-stories-form .section-title-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
}

.data-stories-form .section-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--unesco-blue) 0%, var(--unesco-blue-light) 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.2rem;
  box-shadow: var(--shadow-light);
}

.data-stories-form .section-title-input {
  flex: 1;
  font-size: 1.3rem;
  font-weight: 700;
  border: 2px solid transparent;
  background: transparent;
  color: var(--unesco-blue);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.data-stories-form .section-title-input:focus {
  outline: none;
  border-color: var(--unesco-blue);
  background: white;
}

.data-stories-form .section-controls {
  display: flex;
  gap: 0.5rem;
}

.data-stories-form .section-body {
  padding: 2rem;
}

/* Content Blocks Styling */
.data-stories-form .section-content-blocks {
  margin-bottom: 1.5rem;
  min-height: 100px;
}

.data-stories-form .content-block {
  background: #fff;
  border: 2px solid #e9ecef;
  border-radius: 12px;
  margin-bottom: 1.5rem;
  transition: all 0.3s ease;
  overflow: hidden;
}

.data-stories-form .content-block:hover {
  border-color: var(--unesco-blue-pale);
  box-shadow: var(--shadow-light);
}

.data-stories-form .content-block-header {
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #e9ecef;
}

.data-stories-form .content-block-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.data-stories-form .content-block-title i {
  color: var(--unesco-blue);
}

.data-stories-form .content-block-controls {
  display: flex;
  gap: 0.5rem;
}

.data-stories-form .content-block-body {
  padding: 1.5rem;
}

.data-stories-form .insert-block-controls {
  border-top: 1px dashed #e9ecef;
  background: #f8f9fa;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.data-stories-form .insert-block-label {
  color: #6c757d;
  font-size: 0.85rem;
}

.data-stories-form .insert-block-controls .btn {
  padding: 0.2rem 0.5rem;
}

/* Quill Editor Styling - Scoped to data stories */
.data-stories-form .quill-editor {
  background: white;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  min-height: 300px;
  display: flex;
  flex-direction: column;
}

/* Small Quill Editor for basic fields */
.data-stories-form .quill-editor-wrapper {
  margin-bottom: 0.5rem;
}

.data-stories-form .quill-editor-small {
  min-height: 150px;
}

.data-stories-form .quill-editor-small .ql-editor {
  min-height: 100px !important;
}

.data-stories-form .hidden-textarea {
  display: none !important;
}

.data-stories-form .quill-editor:focus-within {
  border-color: var(--unesco-blue);
  box-shadow: 0 0 0 3px rgba(0, 114, 188, 0.1);
}

.data-stories-form .ql-toolbar {
  border: none !important;
  border-bottom: 2px solid #e9ecef !important;
  background: #f8f9fa;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

.data-stories-form .ql-container {
  border: none !important;
  font-size: 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* This is the actual editable area inside Quill */
.data-stories-form .ql-editor {
  min-height: 250px !important;
  padding: 1.5rem !important;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-primary);
  flex: 1;
}

.data-stories-form .ql-editor.ql-blank::before {
  color: #adb5bd;
  font-style: normal;
  font-size: 1rem;
  padding: 1.5rem;
}

/* Terria Map Block Styling */
.data-stories-form .terria-block-form {
  background: #f8f9fa;
  padding: 1.5rem;
  border-radius: 8px;
}

.data-stories-form .terria-share-input,
.data-stories-form .terria-config-textarea {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
  font-size: 0.9rem;
}

.data-stories-form .terria-preview {
  margin-top: 1rem;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  overflow: hidden;
  background: #f8f9fa;
}

.data-stories-form .terria-preview iframe {
  width: 100%;
  height: 400px;
  border: none;
}

/* Media Block Styling */
.data-stories-form .media-block-form .form-group {
  margin-bottom: 1rem;
}

.data-stories-form .media-preview {
  margin-top: 1rem;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}

.data-stories-form .media-preview iframe {
  width: 100%;
  height: 400px;
  border: none;
}

/* Add Block Controls */
.data-stories-form .add-block-controls {
  padding: 1.5rem;
  border: 2px dashed #dee2e6;
  border-radius: 12px;
  text-align: center;
  background: #f8f9fa;
  margin-top: 1rem;
}

.data-stories-form .add-block-controls .text-muted {
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

/* Image Upload Section */
.data-stories-form .upload-dropzone {
  border: 3px dashed #dee2e6;
  border-radius: 12px;
  padding: 3rem 2rem;
  text-align: center;
  background: #f8f9fa;
  cursor: pointer;
  transition: all 0.3s ease;
}

.data-stories-form .upload-dropzone:hover,
.data-stories-form .upload-dropzone.dragover {
  border-color: var(--unesco-blue);
  background: var(--unesco-blue-pale);
}

.data-stories-form .dropzone-content i {
  color: var(--unesco-blue);
  margin-bottom: 1rem;
}

.data-stories-form .uploaded-images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.data-stories-form .uploaded-image-item {
  border: 2px solid #e9ecef;
  border-radius: 12px;
  overflow: visible;
  background: white;
  transition: all 0.3s ease;
}

.data-stories-form .uploaded-image-item:hover {
  border-color: var(--unesco-blue);
  box-shadow: var(--shadow-medium);
  transform: translateY(-2px);
}

.data-stories-form .uploaded-image-preview {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: 10px 10px 0 0;
}

.data-stories-form .uploaded-image-info {
  padding: 1rem;
}

.data-stories-form .uploaded-image-info input {
  width: 100%;
  margin-bottom: 0.5rem;
  padding: 0.5rem;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  font-size: 0.9rem;
}

.data-stories-form .uploaded-image-info input.image-copyright {
  font-size: 0.85rem;
  color: #6c757d;
  font-style: italic;
  background-color: #fafafa;
}

.data-stories-form .uploaded-image-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.data-stories-form .uploaded-image-actions button {
  flex: 1 1 auto;
  min-width: fit-content;
  padding: 0.4rem 0.6rem;
  font-size: 0.8rem;
  white-space: nowrap;
}

/* Featured Image Styles */
.data-stories-form .uploaded-image-item.is-featured {
  border-color: #FFB800;
  box-shadow: 0 0 0 2px rgba(255, 184, 0, 0.2);
  position: relative;
}

.data-stories-form .featured-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: linear-gradient(135deg, #FFB800 0%, #FF8800 100%);
  color: white;
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(255, 136, 0, 0.3);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.data-stories-form .featured-badge i {
  font-size: 0.85rem;
}

/* Progress Indicator */
.data-stories-form .upload-progress {
  padding: 1rem;
  background: var(--unesco-blue-pale);
  border-radius: 8px;
  margin-bottom: 1rem;
}

.data-stories-form .upload-progress .progress {
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: white;
  margin-top: 0.5rem;
}

.data-stories-form .upload-progress .progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--unesco-blue) 0%, var(--unesco-blue-light) 100%);
  transition: width 0.3s ease;
}

/* Button Styling - Enhanced - Scoped to data stories form */
.data-stories-form .btn,
.data-stories-form-wrapper .btn,
.homepage.layout-1 .form-actions .btn {
  border-radius: 25px;
  padding: 12px 24px;
  font-weight: 600;
  transition: all 0.3s ease;
  border: none;
  text-transform: none;
  letter-spacing: 0.3px;
  cursor: pointer;
  position: relative;
  z-index: 10;
}

.data-stories-form .btn-primary,
.data-stories-form-wrapper .btn-primary,
.homepage.layout-1 .form-actions .btn-primary {
  background: linear-gradient(135deg, var(--unesco-blue) 0%, var(--unesco-blue-dark) 100%);
  color: white;
  box-shadow: var(--shadow-light);
  border: none;
}

.data-stories-form .btn-primary:hover,
.data-stories-form-wrapper .btn-primary:hover,
.homepage.layout-1 .form-actions .btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-medium);
  background: linear-gradient(135deg, var(--unesco-blue-dark) 0%, var(--unesco-blue) 100%);
  color: white;
}

.data-stories-form .btn-default,
.data-stories-form-wrapper .btn-default,
.homepage.layout-1 .form-actions .btn-default {
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  border: 2px solid #e9ecef;
  color: var(--text-primary);
  box-shadow: var(--shadow-light);
}

.data-stories-form .btn-default:hover,
.data-stories-form-wrapper .btn-default:hover,
.homepage.layout-1 .form-actions .btn-default:hover {
  background: var(--unesco-blue-pale);
  border-color: var(--unesco-blue);
  color: var(--unesco-blue);
  transform: translateY(-1px);
}

.data-stories-form .btn-success,
.data-stories-form-wrapper .btn-success {
  background: linear-gradient(135deg, #28a745 0%, #34ce57 100%);
  border: none;
  color: white;
}

.data-stories-form .btn-info,
.data-stories-form-wrapper .btn-info {
  background: linear-gradient(135deg, #17a2b8 0%, #1fc8e3 100%);
  border: none;
  color: white;
}

.data-stories-form .btn-danger,
.data-stories-form-wrapper .btn-danger,
.homepage.layout-1 .form-actions .btn-danger {
  background: linear-gradient(135deg, #dc3545 0%, #e4606d 100%);
  border: none;
  color: white;
}

/* Form Controls - Enhanced (matching rapid-response) - Scoped to data stories */
.data-stories-form .form-control,
.data-stories-form input[type="text"],
.data-stories-form input[type="email"],
.data-stories-form input[type="url"],
.data-stories-form input[type="date"],
.data-stories-form select,
.data-stories-form textarea {
  border-radius: 12px;
  border: 2px solid #e9ecef;
  padding: 14px 18px;
  font-size: 1.05rem;
  transition: all 0.3s ease;
  min-height: 3.2em;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  box-shadow: var(--shadow-light);
  width: 100%;
}

.data-stories-form .form-control:not([readonly]):not([disabled]),
.data-stories-form input[type="text"]:not([readonly]):not([disabled]),
.data-stories-form input[type="email"]:not([readonly]):not([disabled]),
.data-stories-form input[type="url"]:not([readonly]):not([disabled]),
.data-stories-form input[type="date"]:not([readonly]):not([disabled]),
.data-stories-form select:not([readonly]):not([disabled]),
.data-stories-form textarea:not([readonly]):not([disabled]) {
  cursor: text;
}

.data-stories-form .form-control[readonly],
.data-stories-form input[readonly],
.data-stories-form select[readonly],
.data-stories-form textarea[readonly] {
  background: linear-gradient(135deg, #e9ecef 0%, #f8f9fa 100%);
  cursor: not-allowed;
  color: var(--text-secondary);
}

.data-stories-form .form-control:focus,
.data-stories-form input[type="text"]:focus,
.data-stories-form input[type="email"]:focus,
.data-stories-form input[type="url"]:focus,
.data-stories-form input[type="date"]:focus,
.data-stories-form select:focus,
.data-stories-form textarea:focus {
  border-color: var(--unesco-blue);
  box-shadow: 0 0 0 0.2rem rgba(0, 114, 188, 0.25);
  outline: none;
  background: #ffffff;
  transform: translateY(-1px);
}

.data-stories-form .form-control:hover:not([readonly]):not(:focus),
.data-stories-form input[type="text"]:hover:not([readonly]):not(:focus),
.data-stories-form input[type="email"]:hover:not([readonly]):not(:focus),
.data-stories-form input[type="url"]:hover:not([readonly]):not(:focus),
.data-stories-form input[type="date"]:hover:not([readonly]):not(:focus),
.data-stories-form select:hover:not([readonly]):not(:focus),
.data-stories-form textarea:hover:not([readonly]):not(:focus) {
  border-color: var(--unesco-blue-light);
  transform: translateY(-1px);
}

.data-stories-form textarea.form-control,
.data-stories-form textarea {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
}

/* Form Group Styling - Scoped to data stories */
.data-stories-form .form-group {
  margin-bottom: 2rem;
  position: relative;
  z-index: 1;
}

.data-stories-form .control-label,
.data-stories-form label {
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.8rem;
  display: block;
  font-size: 1.05rem;
}

.data-stories-form .control-label i,
.data-stories-form label i {
  margin-right: 0.5rem;
}

.data-stories-form .control-label .text-muted,
.data-stories-form label .text-muted {
  font-weight: 400;
  font-size: 0.9rem;
  margin-left: 0.5rem;
}

/* Help Text - Scoped to data stories */
.data-stories-form .help-block,
.data-stories-form .form-text,
.data-stories-form .help-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
  line-height: 1.5;
  display: block;
  clear: both;
}

.data-stories-form .form-group > .help-block {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: #f8f9fa;
  border-radius: 8px;
  border-left: 3px solid #6c757d;
}

.data-stories-form .help-block.error {
  color: #dc3545;
  font-weight: 600;
}

/* Error Styling */
.data-stories-form .error-block {
  color: #dc3545;
  font-size: 0.875rem;
  margin-top: 0.5rem;
  display: block;
  font-weight: 600;
}

.data-stories-form .form-group.has-error .form-control,
.data-stories-form .form-group.has-error input,
.data-stories-form .form-group.has-error select,
.data-stories-form .form-group.has-error textarea {
  border-color: #dc3545;
}

.data-stories-form .form-group.has-error .control-label {
  color: #dc3545;
}

/* Ensure all interactive elements are clickable - Scoped to data stories */
.data-stories-form input,
.data-stories-form select,
.data-stories-form textarea,
.data-stories-form button,
.data-stories-form .btn,
.data-stories-form .upload-dropzone,
.data-stories-form label {
  pointer-events: auto;
  position: relative;
}

/* Make sure form controls are on top */
.data-stories-form .form-group input,
.data-stories-form .form-group select,
.data-stories-form .form-group textarea,
.data-stories-form .form-group button {
  position: relative;
  z-index: 5;
}

/* Dropzone should be clickable */
.data-stories-form .upload-dropzone {
  position: relative;
  z-index: 5;
  pointer-events: auto;
}

.data-stories-form .dropzone-content {
  pointer-events: none;
}

/* Buttons should be on top and clickable */
.data-stories-form button,
.data-stories-form .btn,
.data-stories-form input[type="button"],
.data-stories-form input[type="submit"] {
  position: relative;
  z-index: 10;
  pointer-events: auto;
  cursor: pointer;
}

/* ========================================
   Terria Tabs Styling - Scoped to data stories
   ======================================== */

/* Editor Tabs */
.data-stories-form .terria-tabs-block .terria-tabs-nav {
  border-bottom: 2px solid #e9ecef;
  padding-bottom: 0.5rem;
  margin-bottom: 1.5rem;
}

.data-stories-form .terria-tabs-list {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.data-stories-form .terria-tab-btn {
  padding: 0.5rem 1rem !important;
  border-radius: 8px !important;
  border: 2px solid #e9ecef !important;
  background: #f8f9fa !important;
  color: #6c757d !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  transition: all 0.3s ease !important;
  position: relative !important;
  z-index: 5 !important;
  pointer-events: auto !important;
  user-select: none !important;
}

.data-stories-form .terria-tab-btn:hover {
  background: var(--unesco-blue-pale) !important;
  border-color: var(--unesco-blue) !important;
  color: var(--unesco-blue) !important;
  transform: translateY(-1px) !important;
}

.data-stories-form .terria-tab-btn.active {
  background: linear-gradient(135deg, var(--unesco-blue) 0%, var(--unesco-blue-dark) 100%) !important;
  color: white !important;
  border-color: var(--unesco-blue) !important;
  box-shadow: var(--shadow-light) !important;
}

.data-stories-form .add-terria-tab-btn {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 2px dashed var(--unesco-blue);
  background: transparent;
  color: var(--unesco-blue);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  z-index: 5;
}

.data-stories-form .add-terria-tab-btn:hover {
  background: var(--unesco-blue-pale);
  transform: translateY(-1px);
}

.data-stories-form .terria-tab-panel {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.terria-tab-preview iframe {
  width: 100%;
  height: 500px;
  border-radius: 12px;
}

/* Display Tabs (for show page) */
.terria-tabs-display {
  margin: 2rem 0;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-medium);
  background: #fff;
}

.terria-tabs-nav-display {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: 0;
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  border-bottom: 3px solid #e9ecef;
  overflow-x: auto;
}

.terria-tabs-nav-display li {
  padding: 1rem 1.5rem;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -3px;
  transition: all 0.3s ease;
  font-weight: 600;
  color: var(--text-secondary);
  position: relative;
  white-space: nowrap;
}

.terria-tabs-nav-display li:hover {
  background: var(--unesco-blue-pale);
  color: var(--unesco-blue);
}

.terria-tabs-nav-display li.active {
  color: var(--unesco-blue);
  border-bottom-color: var(--unesco-blue);
  background: linear-gradient(135deg, var(--unesco-blue-pale) 0%, #ffffff 100%);
}

.terria-tabs-panels-display {
  position: relative;
}

.terria-tab-display {
  display: none;
}

.terria-tab-display.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

.terria-tab-display iframe {
  width: 100%;
  height: 600px;
  border: none;
}

/* ========================================
   Countries Selection (aligned with Rapid Response) - Scoped to data stories
   ======================================== */
.data-stories-form .countries-container {
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  border: 1px solid #e9ecef;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: var(--shadow-light);
}

.data-stories-form .country-selector {
  width: 100%;
}

.data-stories-form .country-selector .input-group {
  width: 100%;
  display: flex;
  flex-wrap: nowrap;
}

.data-stories-form .country-selector .input-group select.form-control {
  flex: 1;
  min-width: 0;
  border-radius: 12px 0 0 12px;
}

.data-stories-form .country-selector .input-group .input-group-btn {
  flex-shrink: 0;
}

.data-stories-form .country-selector .input-group .input-group-btn .btn {
  border-radius: 0 12px 12px 0;
  white-space: nowrap;
}

.data-stories-form .selected-countries {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.data-stories-form .selected-countries:empty::before {
  content: attr(data-empty-text);
  color: var(--text-secondary);
  font-style: italic;
}

.data-stories-form .country-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  background: #e3f2fd;
  color: #0072bc;
  border-radius: 999px;
  border: 1px solid #cfe4fb;
  box-shadow: var(--shadow-light);
}

.data-stories-form .country-item .country-name {
  font-weight: 600;
}

.data-stories-form .country-item .btn {
  border: none;
  padding: 2px 6px;
}

.data-stories-form .selected-partners {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.data-stories-form .selected-partners:empty::before {
  content: attr(data-empty-text);
  color: var(--text-secondary);
  font-style: italic;
}

.data-stories-form .partner-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  background: #e3f2fd;
  color: #0072bc;
  border-radius: 999px;
  border: 1px solid #cfe4fb;
  box-shadow: var(--shadow-light);
}

.data-stories-form .partner-item .partner-name {
  font-weight: 600;
}

.data-stories-form .partner-item .btn {
  border: none;
  padding: 2px 6px;
}

/* ========================================
   Responsive Design - Scoped to data stories
   ======================================== */
@media (max-width: 768px) {
  .data-stories-form .input-group {
    flex-direction: column;
    align-items: stretch;
  }

  .data-stories-form .input-group .input-group-addon {
    width: 100%;
    border-radius: 12px 12px 0 0;
    border-right: 2px solid #e9ecef;
    border-bottom: none;
    justify-content: flex-start;
  }

  .data-stories-form .input-group .form-control {
    width: 100%;
    border-radius: 0 0 12px 12px;
    border-left: 2px solid #e9ecef;
  }

  .data-stories-form .section-header {
    flex-direction: column;
    gap: 1rem;
  }

  .data-stories-form .section-controls {
    width: 100%;
    justify-content: flex-end;
  }

  .data-stories-form .section-body {
    padding: 1rem;
  }

  .data-stories-form .content-block-header {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }

  .data-stories-form .content-block-controls {
    width: 100%;
    justify-content: flex-end;
  }

  .data-stories-form .uploaded-images-grid {
    grid-template-columns: 1fr;
  }

  .data-stories-form fieldset > div:not(legend) {
    padding: 1.5rem;
  }

  .data-stories-form legend {
    padding: 1rem 1.5rem;
    font-size: 1.2rem;
  }

  /* Terria Tabs Responsive */
  .data-stories-form .terria-tabs-list {
    flex-direction: column;
    align-items: stretch;
  }

  .data-stories-form .terria-tab-btn,
  .data-stories-form .add-terria-tab-btn {
    width: 100%;
    justify-content: center;
  }

  .terria-tabs-nav-display {
    flex-direction: column;
    border-bottom: none;
  }

  .terria-tabs-nav-display li {
    border-bottom: none;
    border-left: 3px solid transparent;
    margin-bottom: 0;
    margin-left: -3px;
  }

  .terria-tabs-nav-display li.active {
    border-left-color: var(--unesco-blue);
    border-bottom-color: transparent;
  }

  .terria-tab-display iframe {
    height: 400px;
  }

  .data-stories-form .terria-tab-preview iframe {
    height: 350px;
  }
}

/* ========================================
   FIX: Research Publication DOI/Citation Layout Issues
   ======================================== */

/* Ensure DOI input addon is properly sized and not overlapping */
.data-stories-form .input-group .input-group-addon strong {
  white-space: nowrap;
}

/* Fix DOI input-group to prevent overlap */
.data-stories-form #paper_doi,
.data-stories-form [name="paper_doi"] {
  position: relative;
  z-index: 1;
}

/* Ensure DOI addon has minimum width to display fully */
.data-stories-form .input-group .input-group-addon {
  min-width: fit-content;
  overflow: visible;
}

/* Better spacing for help blocks in Research Publication */
.data-stories-form fieldset > .form-group .help-block {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  border-radius: 8px;
  border-left: 3px solid var(--unesco-blue-pale);
}

.data-stories-form fieldset > .form-group .help-block code {
  background: #fff;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  border: 1px solid #e9ecef;
  font-size: 0.85em;
}

/* ========================================
   FIX: Countries container button alignment
   ======================================== */

/* Ensure countries container doesn't overflow */
.data-stories-form .countries-container {
  overflow: visible;
  width: 100%;
}

/* Fix input-group inside countries container */
.data-stories-form .country-selector .input-group {
  max-width: 100%;
  flex-wrap: nowrap;
}

.data-stories-form .country-selector .input-group select.form-control {
  flex: 1 1 auto;
  min-width: 200px;
}

.data-stories-form .country-selector .input-group .input-group-btn {
  flex: 0 0 auto;
  width: auto;
}

.data-stories-form .country-selector .input-group .input-group-btn .btn {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

/* ========================================
   FIX: Partners container button alignment
   ======================================== */

/* Ensure partners container doesn't overflow */
.data-stories-form .partners-container {
  overflow: visible;
  width: 100%;
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  border: 1px solid #e9ecef;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: var(--shadow-light);
}

.data-stories-form .partner-selector {
  width: 100%;
}

/* Fix input-group inside partners container */
.data-stories-form .partner-selector .input-group {
  width: 100%;
  display: flex;
  flex-wrap: nowrap;
  max-width: 100%;
}

.data-stories-form .partner-selector .input-group input.form-control {
  flex: 1 1 auto;
  min-width: 200px;
  border-radius: 12px 0 0 12px;
}

.data-stories-form .partner-selector .input-group .input-group-btn {
  flex: 0 0 auto;
  width: auto;
  flex-shrink: 0;
}

.data-stories-form .partner-selector .input-group .input-group-btn .btn {
  border-radius: 0 12px 12px 0;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

/* ========================================
   FIX: Breadcrumb alignment
   ======================================== */

/* Ensure breadcrumb is properly contained */
.homepage.layout-1 .toolbar {
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.homepage.layout-1 .breadcrumb {
  margin: 0;
  padding: 0.75rem 1.25rem;
  display: inline-flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.25rem;
}

.homepage.layout-1 .breadcrumb > li {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.homepage.layout-1 .breadcrumb > li span {
  display: inline;
}

/* ========================================
   FIX: Form field padding and spacing
   ======================================== */

/* Improve form-group internal spacing */
.data-stories-form .form-group {
  margin-bottom: 1.75rem;
}

.data-stories-form .form-group .control-label {
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.data-stories-form .form-group .control-label .text-muted {
  font-weight: 400;
  font-size: 0.9em;
}

/* Improve fieldset internal padding */
.data-stories-form fieldset {
  padding: 1.5rem 2rem 2rem 2rem;
}

.data-stories-form legend {
  padding: 1.25rem 2rem;
  margin: 0 0 1.5rem 0;
  width: 100%;
}

/* Reduce overly thick borders */
.data-stories-form fieldset {
  border-left-width: 4px;
}

.data-stories-form legend {
  border-bottom-width: 2px;
}

.data-stories-form legend::after {
  height: 2px;
  left: 2rem;
}
