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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
    Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, #181c24 0%, #23283a 100%);
  min-height: 100vh;
  color: #f3f4f8;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  background: none;
}

.header {
  text-align: center;
  margin-bottom: 40px;
  color: #f3f4f8;
}

.header h1 {
  font-size: 2.5rem;
  margin-bottom: 10px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.header p {
  font-size: 1.1rem;
  opacity: 0.8;
  color: #b0b3c2;
}

.form-section {
  background: #23283a;
  border-radius: 15px;
  padding: 30px;
  margin-bottom: 30px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.form-group {
  display: flex;
  gap: 15px;
  align-items: center;
  flex-wrap: wrap;
}

.button-group {
  display: flex;
  gap: 10px;
  align-items: center;
}

.form-group input {
  flex: 1;
  padding: 15px 20px;
  border: 2px solid #353b4b;
  border-radius: 10px;
  font-size: 16px;
  background: #181c24;
  color: #f3f4f8;
  transition: all 0.3s ease;
}

.form-group input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.btn {
  background: linear-gradient(135deg, #3840a8 0%, #667eea 100%);
  color: #fff;
  border: none;
  padding: 15px 30px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.25);
}

.btn-stories {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
}

.btn-stories:hover {
  box-shadow: 0 5px 15px rgba(255, 107, 107, 0.4);
}

.btn-primary {
  background: linear-gradient(135deg, #3840a8 0%, #667eea 100%);
  font-size: 18px;
  padding: 18px 35px;
}

.btn-primary:hover {
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.25);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.loading {
  text-align: center;
  padding: 40px;
  background: #23283a;
  border-radius: 15px;
  margin-bottom: 30px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  color: #f3f4f8;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.results {
  background: #23283a;
  border-radius: 15px;
  padding: 30px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.results-header {
  margin-bottom: 30px;
  text-align: center;
}

.results-header h3 {
  font-size: 1.8rem;
  margin-bottom: 15px;
  color: #f3f4f8;
}

.results-info {
  display: flex;
  justify-content: center;
  gap: 30px;
  flex-wrap: wrap;
}

.info-item {
  background: #23283a;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 500;
  color: #b0b3c2;
  border: 1px solid #353b4b;
}

.images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.image-item {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  background: #f8f9fa;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.image-item img {
  width: 100%;
  height: auto;
  max-height: 300px;
  object-fit: contain;
  display: block;
  border-radius: 12px;
}

.image-item video {
  width: 100%;
  height: auto;
  max-height: 300px;
  object-fit: cover;
  display: block;
  border-radius: 12px;
  background: #000;
}

.image-overlay {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(30, 34, 54, 0.85);
  color: #fff;
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.success,
.error {
  padding: 15px 20px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-weight: 500;
}

.success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.results-actions {
  margin-top: 20px;
  text-align: center;
}

.btn-secondary {
  background: #6c757d;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-secondary:hover {
  background: #5a6268;
  transform: translateY(-1px);
}

.json-section {
  background: #f8f9fa;
  border-radius: 10px;
  padding: 20px;
  margin: 20px 0;
  border: 1px solid #e9ecef;
}

.json-section h4 {
  margin-bottom: 15px;
  color: #495057;
  font-size: 1.1rem;
}

.json-data {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.5;
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid #e1e5e9;
}

.content-section {
  margin-bottom: 50px;
  background: #f8f9fa;
  border-radius: 15px;
  padding: 25px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
}

.content-section:last-child {
  margin-bottom: 0;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
  padding-bottom: 15px;
  border-bottom: 2px solid #e9ecef;
}

.section-header h4 {
  margin: 0;
  text-align: left;
  border: none;
  background: none;
  padding: 0;
  font-size: 1.6rem;
  color: #333;
}

.section-info {
  display: flex;
  gap: 10px;
}

.source-badge {
  padding: 8px 15px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.source-badge.scraped {
  background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
  color: white;
}

.source-badge.extracted {
  background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
  color: white;
}

.source-badge.cached {
  background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
  color: white;
}

.posts-section {
  border-left: 5px solid #4caf50;
  margin-top: 40px;
}

.stories-section {
  border-left: 5px solid #ff6b6b;
}

.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 15px;
  margin-top: 20px;
}

.stories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.post-item {
  border: 2px solid #e9ecef;
  transition: all 0.3s ease;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  background: #f8f9fa;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.post-item:hover {
  border-color: #4caf50;
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(76, 175, 80, 0.2);
}

.story-item {
  border: 2px solid #e9ecef;
  transition: all 0.3s ease;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  background: #f8f9fa;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.story-item:hover {
  border-color: #ff6b6b;
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(255, 107, 107, 0.2);
}

.overlay-text {
  font-weight: 600;
  font-size: 0.9rem;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.no-content {
  text-align: center;
  padding: 40px;
  color: #666;
  font-size: 1.1rem;
}

@media (max-width: 768px) {
  .container {
    padding: 15px;
  }

  .header h1 {
    font-size: 2rem;
  }

  .form-group {
    flex-direction: column;
  }

  .form-group input {
    margin-bottom: 15px;
  }

  .images-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
  }

  .posts-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
  }

  .stories-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
  }

  .results-info {
    flex-direction: column;
    gap: 15px;
  }

  .section-header {
    flex-direction: column;
    gap: 15px;
    text-align: center;
  }

  .section-header h4 {
    text-align: center;
    font-size: 1.4rem;
  }

  .content-section {
    padding: 20px;
    margin-bottom: 30px;
  }

  .button-group {
    flex-direction: column;
    gap: 10px;
  }

  .btn {
    width: 100%;
  }
}

/* Success and Error Messages */
.success-message,
.error-message {
  padding: 12px 16px;
  margin: 16px 0;
  border-radius: 8px;
  font-weight: 500;
  display: none;
}

.success-message {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.error-message {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

/* Initial hidden states */
.loading.hidden,
.results.hidden,
.json-section.hidden {
  display: none;
}

/* --- UI REVAMP STYLES --- */
.image-item.compact {
  min-height: 180px;
  max-width: 220px;
  margin: 0 auto;
  padding: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  background: #f8f9fa;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.images-grid {
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 10px;
}
.download-overlay {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(30, 34, 54, 0.85);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  opacity: 1;
  transition: background 0.2s;
}
.download-overlay:hover {
  background: #667eea;
  color: #fff;
}
.image-item.compact img,
.image-item.compact video {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-radius: 10px;
}
@media (max-width: 600px) {
  .images-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .image-item.compact {
    min-height: 120px;
    max-width: 100%;
  }
  .image-item.compact img,
  .image-item.compact video {
    height: 120px;
  }
}
/* --- END UI REVAMP STYLES --- */

.media-separator {
  border: none;
  border-top: 1.5px solid #353b4b;
  margin: 48px 0 48px 0;
  width: 100%;
  background: none;
  opacity: 0.85;
}

#storiesGridContainer {
  margin-bottom: 32px;
}
#postsGridContainer {
  margin-top: 32px;
}

.json-tab {
  background: #23283a;
  border: 1px solid #353b4b;
  border-bottom: none;
  color: #b0b3c2;
  padding: 8px 18px;
  font-size: 15px;
  border-radius: 8px 8px 0 0;
  margin-right: 4px;
  cursor: pointer;
  outline: none;
  transition: background 0.2s, color 0.2s;
}
.json-tab-active {
  background: #667eea;
  color: #fff;
  border-bottom: 2px solid #667eea;
  font-weight: 600;
}
#jsonTabs {
  margin-bottom: 0.5rem;
  margin-top: 1rem;
}
#jsonSection {
  background: #181c24;
  border-radius: 10px;
  padding: 18px 12px 12px 12px;
  color: #f3f4f8;
  border: 1px solid #353b4b;
}
#jsonData {
  color: #f3f4f8;
}
.force-checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 0 16px;
}
.force-checkbox-row input[type='checkbox'] {
  width: 18px;
  height: 18px;
  accent-color: #667eea;
  margin: 0;
}
.force-checkbox-row label {
  font-size: 15px;
  color: #b0b3c2;
  font-weight: 500;
  margin: 0;
  cursor: pointer;
}

#storiesTitle,
#postsTitle {
  color: #f3f4f8;
  font-weight: 600;
  letter-spacing: 0.5px;
}
