/* ==========================================================================
   Main Layout & Base Styles
   ========================================================================== */

:root {

  --side-width: 200px;
  --gutter: 20px;
  --surface: #ffffff;
  --border: #f3f4f6;
  --text: #111827;
  --muted: #9ca3af;
  --accent: #111827;
  --primary: #111827;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #ffffff;
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
  height: 100vh;
}

/* ==========================================================================
   Layout Grid System
   ========================================================================== */

.layout {
  display: grid;
  grid-template-columns: var(--side-width) minmax(0, 1fr) var(--side-width);
  gap: var(--gutter);
  min-height: 100vh;

  margin: 0 auto;
  padding: 16px 16px;
}

/* ==========================================================================
   Sidebar Components
   ========================================================================== */

.sidebar {
  background: var(--surface);
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  position: sticky;
  top: 16px;
  height: fit-content;
  margin: 0;
  max-height: calc(100vh - 32px);
  overflow: hidden;
}

.sidebar::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

.sidebar.right {
  border-left: 1px solid var(--border);
  background: var(--surface);
}

.sidebar.left {
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.sidebar h3 {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #000000;
  margin-bottom: 8px;
}

.saas-vertical-list {
  margin-top: 4px;
}

.saas-vertical-item {
  margin-bottom: 2px;
}

.saas-vertical-item:last-child {
  margin-bottom: 0;
}

/* Infinite scroll animation */
.saas-vertical-list {
  margin-top: 4px;
  animation: scrollVertical 120s linear infinite;
  display: flex;
  flex-direction: column;
}

@keyframes scrollVertical {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(-50%);
  }
}

/* Pause animation on hover */
.saas-vertical-list:hover {
  animation-play-state: paused;
}

/* Adjust list height for better animation */
.saas-vertical-list {
  max-height: calc(100vh - 100px);
}

/* ==========================================================================
   Sponsored Section - Horizontal Scroll
   ========================================================================== */

.sponsored-section {
  margin: 20px 0;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.sponsored-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  text-align: center;
}

.sponsored-scroll {
  display: flex;
  gap: 12px;
  animation: scrollHorizontal 120s linear infinite;
  width: fit-content;
}

.sponsored-scroll:hover {
  animation-play-state: paused;
}

@keyframes scrollHorizontal {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-50%);
  }
}

.sponsored-card {
  flex-shrink: 0;
  width: 200px;
  height: 80px;
  perspective: 1000px;
}

.sponsored-card-inner {
  width: 100%;
  height: 100%;
  background: white;
  border-radius: 8px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: transform 0.3s ease;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.sponsored-card-inner:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 12px rgba(0, 0, 0, 0.15);
}

.sponsored-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  flex-shrink: 0;
}

.sponsored-content {
  flex: 1;
  min-width: 0;
}

.sponsored-name {
  font-size: 12px;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sponsored-category {
  font-size: 10px;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   Hero 3D Card Animation
   ========================================================================== */

.hero-3d-container {
  position: relative;
  width: 300px;
  height: 200px;
  margin: 20px auto;
  perspective: 1000px;
}

.hero-3d-card {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  animation: flipCard 10s infinite;
}

.hero-3d-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.hero-3d-front {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.hero-3d-back {
  background: white;
  transform: rotateY(180deg);
  overflow: hidden;
}

.hero-3d-scroll {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
}

.hero-3d-scroll-content {
  display: flex;
  gap: 8px;
  animation: heroScrollHorizontal 8s linear infinite;
}

@keyframes flipCard {
  0%, 45% {
    transform: rotateY(0deg);
  }
  50%, 95% {
    transform: rotateY(180deg);
  }
  100% {
    transform: rotateY(360deg);
  }
}

@keyframes heroScrollHorizontal {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-50%);
  }
}

.hero-3d-saas-item {
  flex-shrink: 0;
  width: 60px;
  height: 60px;
  background: #f3f4f6;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

.hero-3d-saas-icon {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  margin-bottom: 2px;
}

.hero-3d-saas-name {
  font-size: 8px;
  text-align: center;
  color: #374151;
  line-height: 1;
}

/* ==========================================================================
   Sponsored Section Wrapper
   ========================================================================== */

.sponsored-section-wrapper {
  margin: 0 -16px;
  padding: 0 16px;
}

/* ==========================================================================
   Main Content Area
   ========================================================================== */

.main {
  width: 100%;
  margin: 0 auto;
  padding: 8px 0 40px;
}

/* ==========================================================================
   Hero Section - Enhanced Design
   ========================================================================== */

.hero {
  background: 
    radial-gradient(circle at 20% 50%, rgba(0, 0, 0, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 80% 50%, rgba(0, 0, 0, 0.03) 0%, transparent 50%),
    linear-gradient(135deg, #fafbfc 0%, #f1f5f9 50%, #e2e8f0 100%);
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  text-align: center;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  box-shadow: 
    0 1px 3px rgba(0, 0, 0, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  flex-shrink: 0;
  height: auto;
}

.hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    repeating-linear-gradient(45deg, transparent, transparent 15px, rgba(0, 0, 0, 0.02) 15px, rgba(0, 0, 0, 0.02) 30px),
    repeating-linear-gradient(-45deg, transparent, transparent 15px, rgba(0, 0, 0, 0.015) 15px, rgba(0, 0, 0, 0.015) 30px),
    repeating-linear-gradient(90deg, transparent, transparent 20px, rgba(0, 0, 0, 0.01) 20px, rgba(0, 0, 0, 0.01) 40px);
  pointer-events: none;
  z-index: 1;
  opacity: 0.8;
}

.hero::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: conic-gradient(from 0deg at 50% 50%, 
    transparent 0deg, 
    rgba(0, 0, 0, 0.01) 90deg, 
    transparent 180deg, 
    rgba(0, 0, 0, 0.01) 270deg, 
    transparent 360deg);
  pointer-events: none;
  z-index: 1;
  animation: rotate 60s linear infinite;
}

@keyframes rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.hero > * {
  position: relative;
  z-index: 2;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 800;
  line-height: 1.1;
  color: #000000;
  text-shadow: 
    0 2px 4px rgba(0, 0, 0, 0.1),
    0 4px 8px rgba(0, 0, 0, 0.05);
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #000000 0%, #1f2937 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  margin: 0;
  font-size: clamp(1rem, 2vw, 1.25rem);
  color: #4b5563;
  max-width: 600px;
  font-weight: 400;
  line-height: 1.6;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

.hero button,
.hero .add-saas-btn {
  align-self: center;
  padding: 14px 32px;
  font-size: 15px;
  background: linear-gradient(135deg, #000000 0%, #111827 100%);
  color: #ffffff;
  border: 2px solid #000000;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 600;
  box-shadow: 
    0 4px 6px rgba(0, 0, 0, 0.1),
    0 1px 3px rgba(0, 0, 0, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  position: relative;
  overflow: hidden;
}

.hero button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

.hero button:hover,
.hero .add-saas-btn:hover {
  background: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%);
  color: #000000;
  transform: translateY(-2px);
  box-shadow: 
    0 8px 12px rgba(0, 0, 0, 0.15),
    0 2px 4px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.hero button:hover::before,
.hero .add-saas-btn:hover::before {
  left: 100%;
}

.hero button:active,
.hero .add-saas-btn:active {
  transform: translateY(0);
  box-shadow: 
    0 2px 4px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* ==========================================================================
   Market Section - Scrollable
   ========================================================================== */

.market {
  padding: 20px 0;
}

.market-scrollable {
  padding-bottom: 20px;
}

/* ==========================================================================
   Search Form
   ========================================================================== */

.search-form {
  display: flex;
  justify-content: center;
  margin: 20px auto;
  max-width: 500px;
}

.search-input {
  width: 100%;
  max-width: 400px;
  padding: 10px 12px;
  border: 1px solid #000000;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease;
}

.search-input:focus {
  border-color: #000000;
}

.search-button {
  display: none;
}

/* ==========================================================================
   Logo Component
   ========================================================================== */

.logo {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  margin-bottom: 16px;
  display: block;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

/* Tablet Landscape */
@media (max-width: 1200px) {
  .layout {
    --side-width: 190px;
    --gutter: 20px;
    padding: 14px 14px;
  }
}

/* Tablet Portrait */
@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 170px minmax(0, 1fr) 170px;
    padding: 12px 12px;
  }
  
  .sidebar {
    padding: 16px;
    font-size: 13px;
  }
}

/* Small Tablet */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 150px minmax(0, 1fr) 150px;
    padding: 10px 10px;
  }
  
  .hero {
    padding: 24px;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .layout {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 12px;
  }
  
  .sidebar {
    display: none;
  }
  
  .main {
    max-width: none;
    padding: 8px 0 40px;
  }
  
  .saas-card {
    min-height: 144px;
    height: 144px !important;
    transition: none !important;
  }
  
  .grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
  }
  
  .hero {
    padding: 24px;
    text-align: center !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
    display: flex !important;
  }
  
  .hero h1,
  .hero p,
  .hero button,
  .hero .add-saas-btn {
    text-align: center !important;
    align-self: center !important;
  }
  
  .sponsored-mobile {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 12px 0;
    margin-bottom: 16px;
  }
  
  .sponsored-item {
    min-width: 150px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
  }
}

/* Small Mobile */
@media (max-width: 480px) {
  .layout {
    padding: 8px;
  }
  
  .hero {
    padding: 20px;
  }
  
  .saas-card {
    min-height: 144px;
    height: 144px !important;
    transition: none !important;
  }
  
  .grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .sponsored-item {
    min-width: 200px;
    padding: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #ffffff;
  }
  
  /* Prevent zoom on input focus */
  input[type="text"],
  input[type="search"],
  textarea {
    font-size: 16px !important;
    transform: scale(1) !important;
  }
}
