* { box-sizing: border-box; }

body {
  font-family: 'Sarabun', sans-serif;
  background-color: #f5f7fa;
  margin: 0;
  padding: 0;
  color: #2c3e50;
}

/* ===== NAVBAR ===== */
nav {
  background: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  min-height: 80px;
  display: flex;
  align-items: center;
  padding: 0 40px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 1000;
}

nav img {
  height: 50px;
  object-fit: contain;
}

nav a {
  font-size: 15px;
  font-weight: 600;
  height: 100%;
  display: flex;
  align-items: center;
  text-decoration: none;
  white-space: nowrap;
  color: #2c3e50;
  transition: color 0.25s;
}

nav a:hover {
  color: #0066cc;
}

nav .flex-nav {
  display: flex;
  gap: 28px;
  align-items: center;
  margin-left: auto;
  flex-wrap: wrap;
}

.auth-menu {
  display: flex;
  gap: 12px;
  align-items: center;
}

.auth-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: #f0f4f8;
  border-radius: 20px;
}

.auth-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #0066cc;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.btn-logout {
  background: #ef4444;
  color: white;
  padding: 8px 14px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.25s;
  font-family: 'Sarabun', sans-serif;
}

.btn-logout:hover {
  background: #dc2626;
}

.btn-login {
  background: #0066cc;
  color: white;
  padding: 8px 14px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  display: flex;
  align-items: center;
  font-family: 'Sarabun', sans-serif;
  transition: all 0.25s;
}

.btn-login:hover {
  background: #0052a3;
}

/* ===== PAGE HEADER ===== */
.page-header {
  background: linear-gradient(135deg, #0066cc, #0052a3);
  color: white;
  padding: 60px 20px;
  text-align: center;
}

.page-header h1 {
  font-size: 40px;
  margin: 0 0 12px 0;
  font-weight: 700;
}

.page-header p {
  font-size: 18px;
  margin: 0;
  opacity: 0.95;
}

/* ===== FILTER SECTION ===== */
.filter-section {
  max-width: 1200px;
  margin: -50px auto 50px;
  padding: 0 20px;
  position: relative;
  z-index: 10;
}

.filter-box {
  background: white;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  border: 1px solid #e8ecf1;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  text-align: left;
}

.filter-item {
  display: flex;
  flex-direction: column;
}

.filter-item label {
  font-weight: 600;
  margin-bottom: 8px;
  color: #2c3e50;
  font-size: 14px;
}

.filter-box select {
  width: 100%;
  padding: 10px 16px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-family: 'Sarabun', sans-serif;
  font-size: 14px;
  background: white;
  cursor: pointer;
  transition: all 0.25s;
}

.filter-box select:focus {
  outline: none;
  border-color: #0066cc;
  box-shadow: 0 0 0 3px rgba(0,102,204,0.1);
}

/* ===== MAIN CONTENT ===== */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px 60px;
}

main h2 {
  font-size: 32px;
  font-weight: 700;
  text-align: center;
  margin: 50px 0 40px;
  color: #2c3e50;
}

/* ===== TECHNICIAN LIST ===== */
#technicianList {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 28px;
}

.tech-card {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  border: 1px solid #e8ecf1;
  transition: all 0.3s;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.tech-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.12);
}

.tech-card img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
}

.tech-card .no-image {
  width: 100%;
  height: 200px;
  background: #e8ecf1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  font-size: 14px;
}

.tech-info {
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.tech-info h3 {
  margin: 0 0 8px 0;
  font-size: 18px;
  font-weight: 700;
  color: #2c3e50;
}

.tech-info p {
  margin: 6px 0;
  font-size: 14px;
  color: #666;
  line-height: 1.6;
}

.expertise-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 2.8em; /* Approximate height for 2 lines */
}

.tech-rating {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #f59e0b;
  font-weight: 600;
  margin: 8px 0;
  font-size: 14px;
}

.skill-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.skill-gold { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.skill-silver { background: #f3f4f6; color: #374151; border: 1px solid #e5e7eb; }
.skill-bronze { background: #fff7ed; color: #9a3412; border: 1px solid #ffedd5; }

.tech-price-tag {
  font-size: 13px;
  color: #0066cc;
  font-weight: 700;
  margin-top: 4px;
}

.tech-buttons {
  display: flex;
  gap: 10px;
  margin-top: auto;
}

.tech-info button {
  flex: 1;
  background: #0066cc;
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Sarabun', sans-serif;
  font-size: 14px;
  transition: all 0.25s;
}

.tech-info button:hover {
  background: #0052a3;
  transform: translateY(-2px);
}

.btn-chat {
  background: #10b981 !important;
}

.btn-chat:hover {
  background: #059669 !important;
}

.no-data {
  text-align: center;
  color: #e74c3c;
  font-weight: 600;
  font-size: 16px;
  margin: 60px 0;
  grid-column: 1 / -1;
}

/* ===== MODAL ===== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 16px;
  width: 100%;
  max-width: 850px;
  max-height: 95vh;
  overflow-y: auto;
  padding: 0;
  position: relative;
  margin: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.modal-header-hero {
  padding: 40px;
  background: linear-gradient(to bottom, #f8fafc, white);
  border-bottom: 1px solid #f1f5f9;
}

.tech-profile-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 30px;
  padding: 30px 40px;
}

@media (max-width: 768px) {
  .tech-profile-grid { grid-template-columns: 1fr; padding: 20px; }
  .modal-header-hero { padding: 30px 20px; }
}

.info-section {
  margin-bottom: 30px;
}

.info-section h3 {
  font-size: 18px;
  font-weight: 700;
  color: #1e293b;
  margin: 0 0 15px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.info-section h3 i { color: #0066cc; }

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

.tag {
  background: #f1f5f9;
  color: #475569;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
}

.experience-list {
  border-left: 2px solid #e2e8f0;
  padding-left: 20px;
  margin-left: 10px;
}

.exp-item {
  position: relative;
  margin-bottom: 20px;
}

.exp-item::before {
  content: '';
  position: absolute;
  left: -26px;
  top: 6px;
  width: 10px;
  height: 10px;
  background: #0066cc;
  border-radius: 50%;
  border: 2px solid white;
}

.exp-item .title { font-weight: 700; font-size: 14px; color: #334155; }
.exp-item .desc { font-size: 13px; color: #64748b; margin-top: 4px; }

.tech-specs-card {
  background: #f8fafc;
  border-radius: 12px;
  padding: 20px;
  border: 1px solid #e2e8f0;
}

.spec-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #edf2f7;
  font-size: 14px;
}

.spec-row:last-child { border-bottom: none; }
.spec-row .label { color: #64748b; }
.spec-row .value { font-weight: 600; color: #334155; }

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

.portfolio-item {
  height: 100px;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: 0.2s;
}

.portfolio-item:hover { border-color: #0066cc; transform: scale(1.05); }
.portfolio-item img { width: 100%; height: 100%; object-fit: cover; }

.booking-form-wrap {
  background: #f1f5f9;
  padding: 40px;
  border-top: 1px solid #e2e8f0;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #999;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.25s;
  padding: 0;
}

.modal-close:hover {
  color: #333;
}

.modal-content h2 {
  margin: 0 0 12px 0;
  font-size: 26px;
  font-weight: 700;
  color: #2c3e50;
}

.tech-details {
  font-size: 14px;
  color: #666;
  margin-bottom: 20px;
  line-height: 1.6;
}

.slider-container {
  position: relative;
  width: 100%;
  margin-bottom: 24px;
  border-radius: 8px;
  overflow: hidden;
}

.main-image {
  width: 100%;
  height: 300px;
  object-fit: cover;
  display: block;
}

.slider-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s;
}

.slider-btn:hover {
  background: rgba(0,0,0,0.8);
}

.slider-prev { left: 10px; }
.slider-next { right: 10px; }

.thumbnail-container {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  margin-bottom: 20px;
  padding-bottom: 8px;
}

.thumbnail-container img {
  width: 90px;
  height: 70px;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0.6;
  transition: all 0.25s;
}

.thumbnail-container img:hover {
  opacity: 0.9;
}

.thumbnail-container img.active {
  opacity: 1;
  border: 3px solid #0066cc;
}

/* ===== FORM ===== */
.form-section {
  background: #f5f7fa;
  padding: 20px;
  border-radius: 8px;
  margin: 20px 0;
}

.form-section h3 {
  margin: 0 0 16px 0;
  font-size: 16px;
  font-weight: 700;
  color: #2c3e50;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  color: #2c3e50;
  font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-family: 'Sarabun', sans-serif;
  font-size: 14px;
  transition: all 0.25s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #0066cc;
  box-shadow: 0 0 0 3px rgba(0,102,204,0.1);
}

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

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

.form-row input {
  width: 100%;
}

/* ===== BUTTONS ===== */
.button-group {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.btn {
  flex: 1;
  min-width: 140px;
  padding: 12px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Sarabun', sans-serif;
  font-size: 14px;
  transition: all 0.25s;
}

.btn-confirm {
  background: #10b981;
  color: white;
}

.btn-confirm:hover {
  background: #059669;
  transform: translateY(-2px);
}

.btn-cancel {
  background: #ef4444;
  color: white;
}

.btn-cancel:hover {
  background: #dc2626;
  transform: translateY(-2px);
}

.btn-book {
  background: #0066cc;
  color: white;
  width: 100%;
}

.btn-book:hover {
  background: #0052a3;
}

/* ===== CHAT ===== */
#messagesContainer {
  height: 400px;
  overflow-y: auto;
  background: #f9fafb;
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
}

.message-item {
  margin-bottom: 12px;
  display: flex;
  word-wrap: break-word;
}

.message-item.own {
  justify-content: flex-end;
}

.message-bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
}

.message-bubble.own {
  background: #0066cc;
  color: white;
  border-bottom-right-radius: 2px;
}

.message-bubble.other {
  background: #e8ecf1;
  color: #2c3e50;
  border-bottom-left-radius: 2px;
}

.message-time {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 4px;
}

.chat-input-area {
  display: flex;
  gap: 10px;
}

.chat-input-area input[type="text"] {
  flex: 1;
  padding: 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-family: 'Sarabun', sans-serif;
  font-size: 14px;
}

.chat-input-area button {
  background: #0066cc;
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-family: 'Sarabun', sans-serif;
  transition: all 0.25s;
}

.chat-input-area button:hover {
  background: #0052a3;
}

.chat-input-area button.btn-image {
  background: #e8ecf1;
  color: #2c3e50;
  padding: 12px;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-input-area button.btn-image:hover {
  background: #d1d5db;
}

/* ===== FLOATING BUTTONS ===== */
.line-float {
  position: fixed;
  bottom: 90px;
  right: 20px;
  background: #06C755;
  color: white;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  text-decoration: none;
  box-shadow: 0 8px 20px rgba(0,0,0,0.3);
  z-index: 9999;
  animation: floatBtn 2s infinite;
  transition: all 0.3s;
}

.call-float {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #e53935;
  color: white;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  text-decoration: none;
  box-shadow: 0 8px 20px rgba(0,0,0,0.3);
  z-index: 9999;
  animation: floatBtn 2s infinite 0.3s;
  transition: all 0.3s;
}

.line-float:hover,
.call-float:hover {
  transform: scale(1.15);
  box-shadow: 0 12px 30px rgba(0,0,0,0.45);
}

@keyframes floatBtn {
  0% { transform: translateY(0); }
  25% { transform: translateY(-8px); }
  50% { transform: translateY(0); }
  75% { transform: translateY(-4px); }
  100% { transform: translateY(0); }
}

/* ===== AI CHAT WIDGET ===== */
#aiLauncher {
  position: fixed;
  bottom: 20px;
  left: 20px;
  background: linear-gradient(135deg, #0066cc, #0052a3);
  color: white;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  z-index: 9999;
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
  transition: all 0.3s;
  font-family: 'Sarabun', sans-serif;
}

#aiLauncher:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 30px rgba(0,0,0,0.25);
}

#aiChatWidget {
  position: fixed;
  bottom: 90px;
  left: 20px;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 550px;
  max-height: calc(100vh - 120px);
  z-index: 9999;
  display: none;
  font-family: 'Sarabun', sans-serif;
  animation: slideUp 0.3s ease-out;
}

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

#aiChatWidget .chat-container {
  width: 100%;
  height: 100%;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #e8ecf1;
}

#aiChatWidget .chat-header {
  background: linear-gradient(135deg, #0066cc, #0052a3);
  color: white;
  padding: 15px;
  text-align: center;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15px;
}

#aiChatWidget .close-btn {
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  user-select: none;
  background: none;
  border: none;
  color: white;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#aiChatWidget .chat-messages {
  flex: 1;
  padding: 15px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f5f7fa;
}

#aiChatWidget .message-wrapper {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}

#aiChatWidget .message-wrapper.user {
  align-self: flex-end;
}

#aiChatWidget .message-wrapper.ai {
  align-self: flex-start;
}

#aiChatWidget .message {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

#aiChatWidget .message.user {
  background: #0066cc;
  color: white;
  border-bottom-right-radius: 2px;
}

#aiChatWidget .message.ai {
  background: #e8ecf1;
  color: #2c3e50;
  border-bottom-left-radius: 2px;
}

#aiChatWidget .loading {
  background: transparent;
  border: none;
  font-style: italic;
  color: #999;
  padding: 5px 0;
  align-self: flex-start;
  font-size: 13px;
}

#aiChatWidget .chat-input {
  display: flex;
  padding: 12px;
  border-top: 1px solid #d1d5db;
  gap: 8px;
}

#aiChatWidget .chat-input input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 20px;
  outline: none;
  font-size: 14px;
  font-family: 'Sarabun', sans-serif;
}

#aiChatWidget .chat-input input:focus {
  border-color: #0066cc;
  box-shadow: 0 0 0 3px rgba(0,102,204,0.1);
}

#aiChatWidget .chat-input button {
  background: #0066cc;
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  padding: 0;
  transition: all 0.25s;
}

#aiChatWidget .chat-input button:hover {
  background: #0052a3;
  transform: translateY(-2px);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  nav {
    flex-direction: column;
    align-items: flex-start;
    height: auto;
    padding: 12px 16px;
  }

  nav .flex-nav {
    width: 100%;
    margin-left: 0;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 8px;
  }

  nav a { font-size: 14px; }

  .page-header {
    padding: 40px 20px;
  }

  .page-header h1 {
    font-size: 28px;
  }

  #technicianList {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  #aiChatWidget {
    width: calc(100vw - 20px);
    height: 60vh;
    left: 10px;
    bottom: 80px;
  }
}

@media (max-width: 480px) {
  nav {
    padding: 10px 12px;
  }

  nav img { height: 42px; }
  nav a { font-size: 12px; }

  .page-header {
    padding: 30px 16px;
  }

  .page-header h1 {
    font-size: 24px;
  }

  #technicianList {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .tech-card img,
  .tech-card .no-image {
    height: 160px;
  }

  .modal-content {
    padding: 20px;
  }

  main {
    padding: 0 16px 40px;
  }

  #aiChatWidget {
    width: calc(100vw - 20px);
    height: 55vh;
    left: 10px;
  }
}