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

:root {
  --orange: #FF6B2C;
  --orange-light: #FF8F5E;
  --orange-dark: #E55A1B;
  --dark: #0A0A0F;
  --dark-card: #12121A;
  --dark-border: #1E1E2A;
  --dark-input: #16161F;
  --gray: #8B8B9E;
  --light: #E8E8ED;
  --white: #FFFFFF;
  --glow: rgba(255, 107, 44, 0.15);
  --green: #22C55E;
  --red: #EF4444;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--dark);
  color: var(--light);
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
}

h1, h2, h3, h4 { font-family: 'Space Grotesk', sans-serif; color: var(--white); }

a { color: var(--orange); text-decoration: none; }
a:hover { color: var(--orange-light); }

/* NAV */
nav {
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 100;
  padding: 16px 40px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  backdrop-filter: blur(20px);
  background: rgba(10, 10, 15, 0.9);
  border-bottom: 1px solid var(--dark-border);
}

.logo {
  grid-column: 2;
  justify-self: center;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--white);
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.logo-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.nav-links {
  grid-column: 3;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 16px;
}

/* PAYWALL */
.paywall-blur {
  filter: blur(8px) !important;
  pointer-events: none;
  user-select: none;
}

.paywall-wrapper {
  position: relative;
}

.paywall-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 15, 0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 14px;
  text-align: center;
  padding: 16px;
  z-index: 2;
}

.paywall-overlay p {
  color: var(--light);
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0;
}

.paywall-card-footer {
  background: linear-gradient(135deg, rgba(255,107,44,0.08), rgba(255,107,44,0.04));
  border-top: 1px solid rgba(255,107,44,0.2);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.paywall-card-footer p {
  font-size: 0.8rem;
  color: var(--gray);
  margin: 0;
}

.welder-avatar-paywall {
  position: relative;
  flex-shrink: 0;
}

.welder-avatar-paywall .welder-avatar {
  filter: blur(6px);
}

.welder-avatar-paywall .paywall-lock {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  background: rgba(10,10,15,0.5);
  border-radius: 14px;
}

.nav-links a {
  color: var(--gray);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s;
  white-space: nowrap;
}

.nav-links a:hover { color: var(--white); }

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 24px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--orange);
  color: var(--white);
}
.btn-primary:hover {
  background: var(--orange-light);
  color: var(--white);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--orange);
  border: 1px solid rgba(255, 107, 44, 0.4);
}
.btn-outline:hover {
  background: var(--glow);
  color: var(--orange-light);
}

.btn-ghost {
  background: transparent;
  color: var(--gray);
  border: 1px solid var(--dark-border);
}
.btn-ghost:hover {
  background: var(--dark-card);
  color: var(--white);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 14px 32px;
  font-size: 1rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* CONTAINER */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 100px 40px 60px;
}

.container-sm {
  max-width: 560px;
  margin: 0 auto;
  padding: 120px 40px 60px;
}

.container-md {
  max-width: 800px;
  margin: 0 auto;
  padding: 120px 40px 60px;
}

/* CARDS */
.card {
  background: var(--dark-card);
  border: 1px solid var(--dark-border);
  border-radius: 16px;
  padding: 32px;
}

.card-hover:hover {
  border-color: rgba(255, 107, 44, 0.3);
  transform: translateY(-2px);
  transition: all 0.3s;
}

/* FORMS */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--light);
  margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 12px 16px;
  background: var(--dark-input);
  border: 1px solid var(--dark-border);
  border-radius: 10px;
  color: var(--white);
  font-size: 0.95rem;
  font-family: 'DM Sans', sans-serif;
  transition: border-color 0.2s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--glow);
}

.form-input::placeholder, .form-textarea::placeholder {
  color: var(--gray);
}

.form-input.input-error, .form-select.input-error {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}
.field-error {
  color: var(--red);
  font-size: 0.8rem;
  margin-top: 4px;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238B8B9E' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

.form-select option {
  background: var(--dark-card);
  color: var(--white);
}

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

.form-hint {
  font-size: 0.8rem;
  color: var(--gray);
  margin-top: 4px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

/* TABS / TOGGLE */
.tab-toggle {
  display: flex;
  background: var(--dark-input);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 24px;
  border: 1px solid var(--dark-border);
}

.tab-btn {
  flex: 1;
  padding: 10px 16px;
  text-align: center;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--gray);
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  background: transparent;
  font-family: 'DM Sans', sans-serif;
}

.tab-btn.active {
  background: var(--orange);
  color: var(--white);
}

/* TAGS */
.tag {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(255, 107, 44, 0.1);
  color: var(--orange-light);
  border: 1px solid rgba(255, 107, 44, 0.2);
  font-weight: 500;
}

.tag-green {
  background: rgba(34, 197, 94, 0.1);
  color: var(--green);
  border-color: rgba(34, 197, 94, 0.2);
}

/* PAGE HEADER */
.page-header {
  margin-bottom: 40px;
}

.page-header h1 {
  font-size: 2rem;
  margin-bottom: 8px;
}

.page-header p {
  color: var(--gray);
  font-size: 1.05rem;
}

/* GRID */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

/* PROJECT CARD */
.project-card {
  background: var(--dark-card);
  border: 1px solid var(--dark-border);
  border-radius: 16px;
  overflow: hidden;
  transition: border-color 0.3s, transform 0.3s;
  cursor: pointer;
}

.project-card:hover {
  border-color: rgba(255, 107, 44, 0.4);
  transform: translateY(-4px);
}

.card-img {
  width: 100%;
  height: 180px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  position: relative;
  overflow: hidden;
}

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

.card-img .sparks {
  position: absolute;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 60% 50%, rgba(255, 107, 44, 0.2) 0%, transparent 60%);
}

.card-body {
  padding: 20px;
}

.card-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--white);
  margin-bottom: 8px;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.card-specs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  font-size: 0.8rem;
}

.spec { color: var(--gray); }
.spec strong { color: var(--light); font-weight: 500; }

/* WELDER CARD */
.welder-card {
  background: var(--dark-card);
  border: 1px solid var(--dark-border);
  border-radius: 16px;
  padding: 24px;
  transition: border-color 0.3s, transform 0.3s;
  cursor: pointer;
  text-decoration: none;
  display: block;
  color: inherit;
}

.welder-card:hover {
  border-color: rgba(255, 107, 44, 0.4);
  transform: translateY(-2px);
  color: inherit;
}

.welder-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.welder-avatar {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--orange), var(--orange-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--white);
  font-family: 'Space Grotesk', sans-serif;
  flex-shrink: 0;
}

.welder-info h3 {
  font-size: 1.1rem;
  margin-bottom: 2px;
}

.welder-location {
  font-size: 0.85rem;
  color: var(--gray);
}

.welder-stats {
  display: flex;
  gap: 20px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--dark-border);
}

.welder-stat {
  font-size: 0.8rem;
  color: var(--gray);
}

.welder-stat strong {
  color: var(--orange);
  font-weight: 600;
}

/* ALERT / TOAST */
.alert {
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--red);
}

.alert-success {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: var(--green);
}

/* EMPTY STATE */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray);
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.empty-state h3 {
  color: var(--light);
  margin-bottom: 8px;
}

/* MESSAGE ITEM */
.message-item {
  padding: 20px;
  border-bottom: 1px solid var(--dark-border);
  cursor: pointer;
  transition: background 0.2s;
}

.message-item:hover {
  background: rgba(255, 255, 255, 0.02);
}

.message-item.unread {
  border-left: 3px solid var(--orange);
}

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

.message-sender {
  font-weight: 600;
  color: var(--white);
}

.message-date {
  font-size: 0.8rem;
  color: var(--gray);
}

.message-subject {
  font-size: 0.95rem;
  color: var(--light);
  margin-bottom: 4px;
}

.message-preview {
  font-size: 0.85rem;
  color: var(--gray);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* PROFILE SECTION */
.profile-hero {
  display: flex;
  gap: 32px;
  align-items: flex-start;
  margin-bottom: 48px;
}

.profile-avatar-lg {
  width: 120px;
  height: 120px;
  border-radius: 24px;
  background: linear-gradient(135deg, var(--orange), var(--orange-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  font-weight: 700;
  color: var(--white);
  font-family: 'Space Grotesk', sans-serif;
  flex-shrink: 0;
}

.profile-details h1 {
  font-size: 2rem;
  margin-bottom: 4px;
}

.profile-location {
  color: var(--gray);
  font-size: 1rem;
  margin-bottom: 12px;
}

.profile-bio {
  color: var(--light);
  font-size: 0.95rem;
  line-height: 1.7;
  margin-bottom: 16px;
}

.profile-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.profile-stats {
  display: flex;
  gap: 32px;
  margin-bottom: 48px;
  padding: 24px;
  background: var(--dark-card);
  border: 1px solid var(--dark-border);
  border-radius: 16px;
}

.profile-stat {
  display: flex;
  flex-direction: column;
}

.profile-stat-num {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--orange);
}

.profile-stat-label {
  font-size: 0.8rem;
  color: var(--gray);
}

/* MODAL */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: var(--dark-card);
  border: 1px solid var(--dark-border);
  border-radius: 20px;
  padding: 32px;
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h2 {
  font-size: 1.3rem;
  margin-bottom: 20px;
}

/* FILTER BAR */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 32px;
  padding: 20px;
  background: var(--dark-card);
  border: 1px solid var(--dark-border);
  border-radius: 16px;
}

.filter-bar .form-input,
.filter-bar .form-select {
  flex: 1;
  min-width: 160px;
}

/* SECTION LABEL */
.section-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: var(--orange);
  margin-bottom: 8px;
  font-weight: 600;
}

/* DIVIDER */
.divider {
  height: 1px;
  background: var(--dark-border);
  margin: 32px 0;
}

/* BADGE */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--orange);
  color: var(--white);
  font-size: 0.7rem;
  font-weight: 700;
}

/* FOOTER */
footer {
  padding: 40px;
  text-align: center;
  border-top: 1px solid var(--dark-border);
  color: var(--gray);
  font-size: 0.85rem;
  margin-top: 60px;
}

footer a { color: var(--orange); text-decoration: none; }

/* LOADING */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--dark-border);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* BUTTON LOADING STATE */
.btn.btn-loading {
  pointer-events: none;
  opacity: 0.7;
  position: relative;
}
.btn.btn-loading .btn-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

/* HIDDEN */
.hidden { display: none !important; }

/* Prevent horizontal overflow globally */
html, body { overflow-x: hidden; max-width: 100%; }

/* All images should never exceed their container */
img { max-width: 100%; height: auto; }

/* Overflow-x scroll utility for wide tables/grids */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* RESPONSIVE */
@media (max-width: 768px) {
  nav { padding: 12px 16px; }
  .nav-links { gap: 8px; }
  .nav-links a { font-size: 0.8rem; }
  .container { padding: 80px 16px 40px; }
  .container-sm, .container-md { padding: 100px 16px 40px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .profile-hero { flex-direction: column; align-items: center; text-align: center; }
  .profile-stats { flex-wrap: wrap; gap: 16px; }
  .filter-bar { flex-direction: column; }
  .welder-stats { flex-wrap: wrap; }
  .page-header h1 { font-size: 1.5rem; }
  .modal { padding: 24px; margin: 16px; }

  /* Hide logo and text on mobile for logged-in users */
  body.logged-in .logo {
    display: none;
  }

  /* Project card specs — single column on mobile */
  .card-specs {
    grid-template-columns: 1fr;
  }

  /* Gallery in projekt detail — 2 columns on tablet, stack on phone */
  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr));
    gap: 10px;
  }
  .gallery img {
    height: 160px;
    width: 100%;
    object-fit: cover;
    max-width: 100%;
  }

  /* Spec grid in projekt detail — 2 col */
  .spec-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(160px, 100%), 1fr));
  }

  /* Project card image height on mobile */
  .card-img {
    height: 160px;
  }

  /* Ensure filter bar inputs don't cause horizontal scroll */
  .filter-bar .form-input,
  .filter-bar .form-select {
    min-width: 0;
    width: 100%;
  }

  /* Image upload previews — smaller on mobile */
  #image-preview > div,
  #existing-images-preview > div,
  #new-images-preview > div {
    width: 80px !important;
    height: 80px !important;
  }
}

@media (max-width: 480px) {
  .btn { padding: 8px 16px; font-size: 0.85rem; }
  .card { padding: 20px; }
  .profile-avatar-lg { width: 80px; height: 80px; font-size: 2rem; }

  /* Single-column gallery on very small screens */
  .gallery {
    grid-template-columns: 1fr 1fr;
  }
  .gallery img { height: 140px; }

  /* Spec grid single column on tiny screens */
  .spec-grid {
    grid-template-columns: 1fr 1fr;
  }
}
