/* /css/style.css */
/* === (คงสไตล์เดิมทั้งหมด) === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px
}

.dashboard {
  max-width: 1200px;
  margin: 0 auto
}

h1 {
  text-align: center;
  color: white;
  margin-bottom: 30px;
  font-size: 2.5rem;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, .3)
}

.controls {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 30px
}

.search-container {
  background: rgba(255, 255, 255, .95);
  backdrop-filter: blur(10px);
  border-radius: 15px;
  padding: 20px;
  margin-bottom: 30px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .1);
  border: 1px solid rgba(255, 255, 255, .2);
  max-width: 650px;
  margin-left: auto;
  margin-right: auto
}

.search-form {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap
}

.search-input {
  flex: 1;
  min-width: 200px;
  padding: 12px 16px;
  border: 2px solid #ddd;
  border-radius: 25px;
  font-size: 16px;
  outline: none;
  transition: all .3s ease
}

.search-input:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, .1)
}

.search-engine-select {
  padding: 10px 16px;
  border: 2px solid #ddd;
  border-radius: 20px;
  font-size: 14px;
  background: white;
  outline: none;
  transition: all .3s ease;
  cursor: pointer
}

.search-engine-select:focus {
  border-color: #667eea
}

.search-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 25px;
  cursor: pointer;
  font-size: 16px;
  transition: all .3s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, .2);
  white-space: nowrap
}

.search-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .3)
}

.search-engines {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  justify-content: center
}

.engine-btn {
  background: rgba(255, 255, 255, .8);
  border: 1px solid #ddd;
  padding: 6px 12px;
  border-radius: 15px;
  cursor: pointer;
  font-size: 12px;
  transition: all .3s ease;
  display: flex;
  align-items: center;
  gap: 4px
}

.engine-btn:hover {
  background: #667eea;
  color: white;
  transform: translateY(-1px)
}

.engine-btn.active {
  background: #667eea;
  color: white;
  border-color: #667eea
}

.tabs {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 20px;
  background: rgba(255, 255, 255, .1);
  backdrop-filter: blur(10px);
  padding: 10px;
  border-radius: 15px
}

.tab {
  background: rgba(255, 255, 255, .7);
  border: none;
  padding: 10px 20px;
  border-radius: 25px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all .3s ease;
  color: #333;
  white-space: nowrap;
  position: relative
}

.tab:hover {
  background: rgba(255, 255, 255, .9);
  transform: translateY(-2px)
}

.tab.active {
  background: #667eea;
  color: white;
  box-shadow: 0 4px 15px rgba(102, 126, 234, .3)
}

.tab-delete {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #ff4757;
  color: white;
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  cursor: pointer;
  font-size: 10px;
  display: none;
  align-items: center;
  justify-content: center
}

.tab.custom:hover .tab-delete {
  display: flex
}

.menu-group {
  position: relative;
  display: inline-block
}

.menu-toggle {
  background: #9c88ff;
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 25px;
  cursor: pointer;
  font-size: 16px;
  transition: all .3s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, .2);
  white-space: nowrap
}

.menu-toggle:hover {
  background: #7c69ef;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .3)
}

.menu-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: white;
  border-radius: 15px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .2);
  border: 1px solid rgba(255, 255, 255, .2);
  min-width: 220px;
  z-index: 1000;
  overflow: hidden;
  margin-top: 5px
}

.menu-dropdown.show {
  display: block;
  animation: menuSlideIn .3s ease
}

@keyframes menuSlideIn {
  from {
    opacity: 0;
    transform: translateY(-10px)
  }

  to {
    opacity: 1;
    transform: translateY(0)
  }
}

.menu-item {
  display: block;
  width: 100%;
  padding: 12px 20px;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  transition: background .3s ease;
  color: #333
}

.menu-item:hover {
  background: #f5f5f5
}

.add-btn {
  background: #4CAF50;
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 25px;
  cursor: pointer;
  font-size: 16px;
  transition: all .3s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, .2);
  white-space: nowrap
}

.add-btn:hover {
  background: #45a049;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .3)
}

.danger-btn {
  background: #ff6b6b !important
}

.danger-btn:hover {
  background: #ff5252 !important
}

.links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 20px;
  margin-bottom: 30px
}

.link-card {
  background: rgba(255, 255, 255, .95);
  backdrop-filter: blur(10px);
  border-radius: 15px;
  padding: 20px;
  text-align: center;
  transition: all .3s ease;
  position: relative;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .1);
  border: 1px solid rgba(255, 255, 255, .2);
  cursor: grab;
  user-select: none
}

.link-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 40px rgba(0, 0, 0, .2)
}

.link-card.dragging {
  opacity: .5;
  transform: rotate(5deg) scale(1.05);
  cursor: grabbing;
  z-index: 1000
}

.link-card.drag-over {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .3);
  border: 2px solid #667eea
}

.link-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f0f0;
  font-size: 24px;
  overflow: hidden
}

.link-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px
}

.link-title {
  font-size: 12px;
  color: #333;
  margin-bottom: 5px;
  font-weight: 500
}

.link-url {
  font-size: 10px;
  color: #666;
  word-break: break-all
}

.delete-btn,
.edit-btn {
  position: absolute;
  top: -8px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
  color: #fff
}

.delete-btn {
  right: -8px;
  background: #ff4757
}

.delete-btn:hover {
  background: #ff3742;
  transform: scale(1.1)
}

.edit-btn {
  left: -8px;
  background: #3742fa
}

.edit-btn:hover {
  background: #2f3542;
  transform: scale(1.1)
}
.drag-handle{
  
}
.drag-handle:hover {
  background: rgba(0, 0, 0, .2) !important;
}

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, .5);
  backdrop-filter: blur(5px)
}

.modal-content {
  background: white;
  margin: 10% auto;
  padding: 30px;
  border-radius: 15px;
  width: 90%;
  max-width: 500px;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3)
}

.close {
  position: absolute;
  right: 20px;
  top: 15px;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  color: #aaa;
  transition: color .3s ease
}

.close:hover {
  color: #333
}

.form-group {
  margin-bottom: 20px
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: #333
}

input[type=text],
input[type=url],
input[type=password] {
  width: 100%;
  padding: 12px;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 16px;
  transition: border-color .3s ease
}

input[type=text]:focus,
input[type=url]:focus,
input[type=password]:focus {
  outline: none;
  border-color: #667eea
}

.submit-btn {
  background: #667eea;
  color: white;
  border: none;
  padding: 12px 30px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  transition: all .3s ease;
  width: 100%
}

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

.empty-state {
  text-align: center;
  color: rgba(255, 255, 255, .8);
  font-size: 18px;
  margin: 50px 0
}

@media (max-width:768px) {
  .links-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px
  }

  h1 {
    font-size: 2rem
  }
}

.chips-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
  justify-content: center
}

.chip {
  background: rgba(255, 255, 255, .9);
  border: 1px solid #ddd;
  border-radius: 16px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: all .2s ease;
  white-space: nowrap
}

.chip:hover {
  background: #667eea;
  color: white;
  border-color: #667eea;
  transform: translateY(-1px)
}

.history-toolbar {
  display: flex;
  justify-content: center;
  margin-top: 8px
}

.history-btn {
  background: #6c5ce7;
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: 18px;
  cursor: pointer;
  font-size: 12px;
  transition: all .2s ease
}

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

.history-list {
  max-height: 320px;
  overflow: auto;
  border: 1px solid #eee;
  border-radius: 8px;
  margin-top: 10px
}

.history-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid #f2f2f2
}

.history-row:last-child {
  border-bottom: none
}

.history-q {
  flex: 1;
  font-size: 14px;
  color: #333
}

.history-meta {
  font-size: 11px;
  color: #777;
  margin-left: 6px
}

.history-actions {
  display: flex;
  gap: 6px
}

.icon-btn {
  border: none;
  background: #f3f3f3;
  border-radius: 6px;
  padding: 6px 8px;
  cursor: pointer
}

.icon-btn:hover {
  background: #e9e9e9
}

/* ===== Header Row Layout ===== */
.authbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 10px 20px;
  margin-bottom: 25px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* title style (merge theme of h1) */
.app-title {
  color: white;
  font-size: 1.8rem;
  font-weight: 600;
  text-shadow: 2px 2px 6px rgba(0, 0, 0, 0.3);
  margin: 0;
}
/* shrink size a bit for better balance */
.auth-pill {
  background: rgba(255, 255, 255, 0.95);
  padding: 6px 10px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.muted {
  opacity: .75
}

/* === Auth User Dropdown (Glass theme) === */
.user-dropdown {
  position: relative;
  display: inline-block;
}

.user-btn {
  background: rgba(255, 255, 255, 0.9);
  color: #333;
  border: 1px solid rgba(255, 255, 255, 0.6);
  padding: 8px 16px;
  border-radius: 25px;
  cursor: pointer;
  font-weight: 500;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
  transition: all 0.25s ease;
}

.user-btn:hover {
  background: rgba(255, 255, 255, 1);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

/* dropdown glass menu */
.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(12px);
  overflow: hidden;
  animation: dropdownFade 0.25s ease;
  z-index: 999;
}

.dropdown-menu.show {
  display: block;
}

@keyframes dropdownFade {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: 12px 18px;
  border: none;
  background: transparent;
  text-align: left;
  font-size: 14px;
  color: #333;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dropdown-item:hover {
  background: rgba(102, 126, 234, 0.12);
  color: #333;
}

.dropdown-item.danger {
  color: #ff4757;
}

.dropdown-item.danger:hover {
  background: rgba(255, 71, 87, 0.1);
  color: #ff2f44;
}

.dropdown-item + hr {
  border: none;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  margin: 4px 0;
}

/* authmodal.css — Login/Register modal form */

.auth-form {
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(15px);
  border-radius: 20px;
  padding: 30px 40px;
  max-width: 400px;
  margin: 10% auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  animation: fadeInAuth 0.35s ease;
}

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

.auth-form h3 {
  text-align: center;
  color: #333;
  margin-bottom: 25px;
  font-size: 1.5rem;
  font-weight: 600;
}

.auth-form input {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 15px;
  border: 2px solid #ddd;
  border-radius: 10px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.3s ease;
}

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

.auth-form button {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.auth-form button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(0,0,0,0.3);
}

/* Center modal on screen */
#authModal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
}
