/* ===================================
   CSS Variables for Theming
   =================================== */
:root {
  /* Light Theme Colors */
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-accent: #f0f4f8;
  --text-primary: #1a202c;
  --text-secondary: #4a5568;
  --text-muted: #718096;
  --border-color: #e2e8f0;
  --accent-primary: #2563eb;
  --accent-primary-hover: #1d4ed8;
  --accent-secondary: #10b981;
  --shadow: rgba(0, 0, 0, 0.1);
  --shadow-lg: rgba(0, 0, 0, 0.15);

  /* Badge Colors */
  --badge-skills: #3b82f6;
  --badge-services: #8b5cf6;
  --badge-goods: #f59e0b;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #1a202c;
    --bg-secondary: #2d3748;
    --bg-accent: #374151;
    --text-primary: #f7fafc;
    --text-secondary: #e2e8f0;
    --text-muted: #a0aec0;
    --border-color: #4a5568;
    --accent-primary: #3b82f6;
    --accent-primary-hover: #60a5fa;
    --accent-secondary: #34d399;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-lg: rgba(0, 0, 0, 0.5);

    --badge-skills: #60a5fa;
    --badge-services: #a78bfa;
    --badge-goods: #fbbf24;
  }
}

/* ===================================
   Reset & Base Styles
   =================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  font-size: 16px;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ===================================
   Typography
   =================================== */
h1,
h2,
h3,
h4,
h5,
h6 {
  line-height: 1.2;
  font-weight: 700;
  margin-bottom: 1rem;
}

h1 {
  font-size: 2.5rem;
}

h2 {
  font-size: 2rem;
}

h3 {
  font-size: 1.5rem;
}

p {
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

/* ===================================
   Layout
   =================================== */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ===================================
   Header & Navigation
   =================================== */
header {
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  padding: 10px 0;
  z-index: 1000;
  transition: background-color 0.3s ease;
}

nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  position: relative;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
}

.logo-icon {
  font-size: 1.75rem;
}

.logo-text {
  color: var(--accent-primary);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-left: auto;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-link {
  display: inline-flex;
  align-items: center;
}

.nav-link--cta {
  font-weight: 600;
}

.nav-user {
  position: relative;
}

.nav-user-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: none;
  border: none;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  transition: background-color 0.2s ease;
}

.nav-user-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.nav-user-toggle:hover,
.nav-user-toggle:focus-visible {
  background-color: var(--bg-secondary);
  outline: none;
}

.nav-user-icon {
  width: 0.5rem;
  height: 0.5rem;
  border: solid var(--text-secondary);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
}

.nav-user--open .nav-user-icon {
  transform: rotate(-135deg);
}

.nav-user-menu {
  position: absolute;
  top: calc(100% + 0.75rem);
  right: 0;
  min-width: 190px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  box-shadow: 0 16px 30px rgba(15, 23, 42, 0.12);
  padding: 0.75rem 0;
  display: none;
  z-index: 1001;
}

.nav-user--open .nav-user-menu {
  display: block;
}

.nav-user-item {
  display: block;
  width: 100%;
  padding: 0.65rem 1rem;
  background: none;
  border: none;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.nav-user-item:hover,
.nav-user-item:focus-visible {
  background-color: var(--bg-secondary);
  color: var(--accent-primary);
  outline: none;
}

.nav-logout {
  color: #c0392b;
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  margin-left: auto;
}

.nav-toggle:focus-visible {
  outline: 3px solid var(--accent-primary);
  outline-offset: 2px;
}

.nav-toggle-bar {
  display: block;
  width: 1.5rem;
  height: 2px;
  background-color: var(--text-primary);
  margin: 0.25rem 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-toggle.nav-toggle--open .nav-toggle-bar:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.nav-toggle.nav-toggle--open .nav-toggle-bar:nth-child(2) {
  opacity: 0;
}

.nav-toggle.nav-toggle--open .nav-toggle-bar:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* ===================================
   Admin Dashboard
   =================================== */
.admin-dashboard {
    padding: 3rem 0;
    background-color: var(--bg-primary);
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.admin-dashboard h1 {
    margin-bottom: 0.5rem;
}

.admin-subtitle {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.admin-subnav {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
}

.admin-subnav__link {
    flex: 1 1 260px;
    min-width: 240px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.admin-subnav__link:hover,
.admin-subnav__link:focus-visible {
    border-color: var(--accent-primary);
    box-shadow: 0 8px 22px rgba(37, 99, 235, 0.15);
    transform: translateY(-2px);
    outline: none;
}

.admin-subnav__link.is-active {
    border-color: var(--accent-primary);
    box-shadow: 0 8px 22px rgba(37, 99, 235, 0.2);
}

.admin-subnav__title {
    font-weight: 700;
    color: var(--text-primary);
}

.admin-subnav__desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.admin-alert {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
  background-color: var(--bg-secondary);
  font-weight: 600;
}

.admin-alert--success {
  border-color: rgba(46, 204, 113, 0.4);
  color: #1e824c;
}

.admin-alert--error {
  border-color: rgba(231, 76, 60, 0.4);
  color: #c0392b;
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 2rem;
}

.admin-grid--two {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.admin-card {
    background-color: white;
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.admin-card--action {
    display: flex;
    flex-direction: column;
}

.admin-card__header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.admin-card__header p {
    margin: 0.35rem 0 0;
    color: var(--text-secondary);
}

.admin-card__body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.admin-card__list {
    margin: 0;
    padding-left: 1.1rem;
    color: var(--text-secondary);
    display: grid;
    gap: 0.5rem;
    font-size: 0.95rem;
}

.admin-card__cta {
    align-self: flex-start;
}

.admin-table-wrapper {
    overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.admin-table th,
.admin-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
  vertical-align: middle;
}

.admin-table th {
  background-color: var(--bg-secondary);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.admin-table tbody tr:nth-child(even) {
  background-color: rgba(15, 23, 42, 0.02);
}

.admin-inline-form {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.admin-inline-form--listing {
  flex-wrap: wrap;
}

.admin-select {
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border-color);
  font-family: inherit;
}

.admin-select:focus {
  outline: 3px solid var(--accent-primary);
  outline-offset: 2px;
}

.admin-action-button {
  padding: 0.5rem 0.75rem;
}

.admin-pill {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
}

.admin-pill--primary {
  background-color: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
}

/* ===================================
   Buttons
   =================================== */
.btn {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-primary {
  background-color: var(--accent-primary);
  color: white;
}

.btn-primary:hover {
  background-color: var(--accent-primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--shadow-lg);
}

.btn-primary:active {
  transform: translateY(0);
}

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

.btn-secondary {
  background-color: transparent;
  color: var(--accent-primary);
  border: 2px solid var(--accent-primary);
}

.btn-secondary:hover {
  background-color: var(--accent-primary);
  color: white;
  transform: translateY(-2px);
}

.btn-text {
  background-color: transparent;
  color: var(--text-primary);
  padding: 0.75rem 1rem;
}

.btn-text:hover {
  background-color: var(--bg-secondary);
}

.btn-large {
  padding: 1rem 2.5rem;
  font-size: 1.125rem;
}

/* ===================================
   Hero/Search Section
   =================================== */
.hero-search {
  padding: 4rem 0 3rem;
  text-align: center;
  background-color: var(--bg-secondary);
}

.hero-search h1 {
  font-size: 3rem;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.hero-subtitle {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin-bottom: 2.5rem;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.search-box {
  max-width: 700px;
  margin: 0 auto;
  display: flex;
  gap: 0.75rem;
  background-color: var(--bg-primary);
  padding: 0.5rem;
  border-radius: 0.75rem;
  box-shadow: 0 4px 16px var(--shadow);
}

.search-box input {
  flex: 1;
  padding: 0.875rem 1.25rem;
  font-size: 1rem;
  border: none;
  background-color: transparent;
  color: var(--text-primary);
  font-family: inherit;
}

.search-box input:focus {
  outline: none;
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.btn-search {
  padding: 0.875rem 2rem;
  background-color: var(--accent-primary);
  color: white;
  border: none;
  border-radius: 0.5rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

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

/* ===================================
   Category Tabs
   =================================== */
.categories-section {
  padding: 2rem 0 1rem;
  background-color: var(--bg-primary);
}

.category-tabs {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.category-tab {
  padding: 0.75rem 1.5rem;
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  border: 2px solid transparent;
  border-radius: 0.5rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 1rem;
  transition: all 0.2s ease;
  font-family: inherit;
}

.category-tab:hover {
  background-color: var(--bg-accent);
  color: var(--text-primary);
}

.category-tab.active {
  background-color: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
}

/* ===================================
   Listings Section
   =================================== */
.listings-section {
  padding: 2rem 0 4rem;
  background-color: var(--bg-primary);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.section-header h2 {
  margin-bottom: 0;
}

.view-all {
  color: var(--accent-primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
  transition: color 0.2s ease;
}

.view-all:hover {
  color: var(--accent-primary-hover);
}

.listings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.listing-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 1rem;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

.listing-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px var(--shadow-lg);
}

.listing-badge {
  position: absolute;
  top: 1rem;
  right: 1rem;
  padding: 0.375rem 0.875rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: white;
  z-index: 10;
}

.listing-badge.skills {
  background-color: var(--badge-skills);
}

.listing-badge.services {
  background-color: var(--badge-services);
}

.listing-badge.goods {
  background-color: var(--badge-goods);
}

.listing-image {
  background-color: var(--bg-accent);
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.placeholder-image {
  font-size: 4rem;
}

.listing-content {
  padding: 1.5rem;
}

.listing-content h3 {
  margin-bottom: 0.5rem;
  color: var(--text-primary);
  font-size: 1.25rem;
}

.listing-description {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 1rem;
  line-height: 1.5;
}

.listing-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.listing-user {
  color: var(--text-primary);
  font-weight: 600;
}

.listing-location {
  color: var(--text-muted);
}

.listing-seeking {
  background-color: var(--bg-accent);
  padding: 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.listing-seeking strong {
  color: var(--text-primary);
}

/* ===================================
   How It Works Section
   =================================== */
.how-section {
  padding: 5rem 0;
  background-color: var(--bg-secondary);
}

.how-section h2 {
  text-align: center;
  margin-bottom: 3rem;
  color: var(--text-primary);
}

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  max-width: 1000px;
  margin: 0 auto;
}

.step {
  text-align: center;
  padding: 2rem;
}

.step-number {
  width: 60px;
  height: 60px;
  background-color: var(--accent-primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 auto 1.5rem;
}

.step h3 {
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.step p {
  color: var(--text-secondary);
}

/* ===================================
   CTA Section
   =================================== */
.cta-section {
  padding: 5rem 0;
  background-color: var(--bg-primary);
  text-align: center;
}

.cta-section h2 {
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.cta-text {
  font-size: 1.125rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto 2.5rem;
}

.cta-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ===================================
   Footer
   =================================== */
footer {
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 4rem 0 2rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
  margin-bottom: 3rem;
}

.footer-col h3 {
  color: var(--text-primary);
  font-size: 1rem;
  margin-bottom: 1rem;
}

.footer-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.footer-description {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.footer-links {
  list-style: none;
}

.footer-links li {
  margin-bottom: 0.5rem;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.95rem;
  transition: color 0.2s ease;
}

.footer-links a:hover {
  color: var(--accent-primary);
}

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-bottom p {
  color: var(--text-muted);
  margin: 0;
  font-size: 0.9rem;
}

.footer-legal {
  display: flex;
  gap: 1.5rem;
}

.footer-legal a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s ease;
}

.footer-legal a:hover {
  color: var(--accent-primary);
}

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

/* ===================================
   Responsive Design
   =================================== */
@media (max-width: 768px) {
  nav {
    align-items: center;
  }

  .nav-toggle {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
  }

  .nav-actions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    display: none;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    background-color: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    box-shadow: 0 8px 24px var(--shadow-lg);
    z-index: 1000;
    animation: fadeIn 0.2s ease;
  }

  .nav-actions.is-open {
    display: flex;
  }

  .nav-actions .btn {
    width: 100%;
    text-align: left;
  }

  .nav-user-menu {
    position: static;
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.5rem 0;
    border-radius: 0.5rem;
    box-shadow: none;
  }

  .nav-links {
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    gap: 0.5rem;
  }

  .nav-links .btn {
    width: 100%;
  }

  .nav-user {
    width: 100%;
  }

  .nav-user-toggle {
    width: 100%;
    justify-content: space-between;
    padding: 0.75rem 0;
  }

  .nav-user-item {
    width: 100%;
  }

    .nav-logout {
        width: 100%;
    }

    .admin-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .admin-subnav {
        flex-direction: column;
        gap: 0.75rem;
    }

    .admin-subnav__link {
        width: 100%;
    }

    .admin-card__body {
        gap: 0.75rem;
    }

    .hero-search h1 {
        font-size: 2rem;
    }

  .hero-subtitle {
    font-size: 1.125rem;
  }

  .hero-search {
    padding: 3rem 0 2rem;
  }

  .search-box {
    flex-direction: column;
    gap: 0.5rem;
  }

  .btn-search {
    width: 100%;
  }

  .btn {
    padding: 0.625rem 1rem;
    font-size: 0.95rem;
  }

  .how-section,
  .cta-section {
    padding: 3rem 0;
  }

  .listings-grid {
    grid-template-columns: 1fr;
  }

  .cta-buttons {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-large {
    width: 100%;
  }

  h1 {
    font-size: 2rem;
  }

  h2 {
    font-size: 1.75rem;
  }

  h3 {
    font-size: 1.25rem;
  }

  .steps {
    grid-template-columns: 1fr;
  }

  .footer-grid {
    grid-template-columns: 1fr;
  }

  .footer-bottom {
    flex-direction: column;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 1rem;
  }

  .hero-search h1 {
    font-size: 1.75rem;
  }

  .category-tabs {
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 0.5rem;
  }

  .category-tab {
    flex-shrink: 0;
  }
}

/* ===================================
   Accessibility
   =================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Focus styles for keyboard navigation */
button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid var(--accent-primary);
  outline-offset: 2px;
}
