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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
  min-height: 100vh;
  color: #e0e0e0;
}

/* === Login Page === */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
}

.login-card h1 {
  text-align: center;
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-card p {
  text-align: center;
  color: #888;
  margin-bottom: 32px;
  font-size: 14px;
}

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

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #aaa;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  color: #fff;
  font-size: 15px;
  outline: none;
  transition: all 0.3s;
}

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

.btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

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

.btn-danger {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: #fff;
}

.error-msg {
  text-align: center;
  color: #ff6b6b;
  font-size: 14px;
  margin-top: 16px;
}

/* === Main Page === */
.main-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.header h1 {
  font-size: 24px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logout-btn {
  padding: 8px 20px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  color: #ccc;
  text-decoration: none;
  font-size: 14px;
  transition: all 0.3s;
}

.logout-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

/* Status Cards */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.status-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 20px;
  text-align: center;
}

.status-card .label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #888;
  margin-bottom: 8px;
}

.status-card .value {
  font-size: 18px;
  font-weight: 600;
  color: #fff;
}

.status-card .value.green { color: #2ecc71; }
.status-card .value.blue { color: #667eea; }
.status-card .value.purple { color: #9b59b6; }
.status-card .value.orange { color: #f39c12; }

/* Crawl Controls */
.control-panel {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 28px;
  margin-bottom: 28px;
}

.control-panel h2 {
  font-size: 18px;
  margin-bottom: 20px;
  color: #ddd;
}

.crawl-form {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.crawl-form input {
  flex: 1;
  min-width: 150px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  color: #fff;
  font-size: 15px;
  outline: none;
  transition: all 0.3s;
}

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

.crawl-form .btn-crawl {
  padding: 10px 28px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  white-space: nowrap;
}

.crawl-form .btn-crawl:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

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

.crawl-result {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  display: none;
}

.crawl-result.success {
  display: block;
  background: rgba(46, 204, 113, 0.15);
  border: 1px solid rgba(46, 204, 113, 0.3);
  color: #2ecc71;
}

.crawl-result.error {
  display: block;
  background: rgba(255, 107, 107, 0.15);
  border: 1px solid rgba(255, 107, 107, 0.3);
  color: #ff6b6b;
}

/* Links Table */
.links-section {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 28px;
  overflow: hidden;
}

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

.links-header h2 {
  font-size: 18px;
  color: #ddd;
}

.link-count {
  font-size: 13px;
  color: #888;
  background: rgba(255, 255, 255, 0.08);
  padding: 4px 12px;
  border-radius: 20px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #888;
  font-weight: 600;
}

td {
  font-size: 14px;
  color: #ccc;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.magnet-link {
  color: #667eea;
  text-decoration: none;
  word-break: break-all;
  font-size: 13px;
}

.magnet-link:hover {
  text-decoration: underline;
  color: #8b9cf7;
}

.copy-btn {
  padding: 4px 12px;
  background: rgba(102, 126, 234, 0.15);
  border: 1px solid rgba(102, 126, 234, 0.3);
  border-radius: 6px;
  color: #667eea;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.3s;
  white-space: nowrap;
}

.copy-btn:hover {
  background: rgba(102, 126, 234, 0.25);
}

.copy-btn.copied {
  background: rgba(46, 204, 113, 0.2);
  border-color: #2ecc71;
  color: #2ecc71;
}

.time-col {
  font-size: 13px;
  color: #777;
  white-space: nowrap;
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: #666;
}

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

/* Toast */
.toast {
  position: fixed;
  top: 24px;
  right: 24px;
  padding: 14px 24px;
  border-radius: 12px;
  font-size: 14px;
  color: #fff;
  z-index: 1000;
  transform: translateX(120%);
  transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.toast.show {
  transform: translateX(0);
}

.toast.success { background: #2ecc71; }
.toast.error { background: #e74c3c; }
.toast.info { background: #3498db; }

/* Responsive */
@media (max-width: 768px) {
  .header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }
  .crawl-form {
    flex-direction: column;
  }
  .crawl-form input {
    width: 100%;
  }
  .crawl-form .btn-crawl {
    width: 100%;
  }
  .status-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* === New Components === */

/* Nav button */
.nav-btn {
  padding: 8px 20px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  color: #ccc;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s;
}
.nav-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

/* Refresh button */
.refresh-btn {
  font-size: 18px;
  padding: 6px 12px;
  line-height: 1;
}
.refresh-icon {
  display: inline-block;
  font-size: 20px;
  transition: transform 0.3s;
}
.refresh-btn:active .refresh-icon {
  animation: spin 0.6s ease-in-out;
}
.refresh-btn.spinning .refresh-icon {
  animation: spin 1s linear infinite;
}
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Push button */
.push-btn {
  margin-left: 4px;
  font-size: 14px !important;
  padding: 4px 10px !important;
}

/* Hide confirm button */
.hide-confirm-btn {
  background: rgba(231, 76, 60, 0.2) !important;
  border-color: rgba(231, 76, 60, 0.4) !important;
  color: #e74c3c !important;
}

/* Hidden bar */
.hidden-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 13px;
  color: #888;
}
.hidden-bar .nav-btn {
  font-size: 12px;
  padding: 4px 12px;
}

/* Hidden list */
.hidden-list {
  margin-bottom: 16px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  overflow: hidden;
}

/* Checkbox in select mode */
.link-checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #667eea;
}

/* Form select */
.form-select {
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  color: #fff;
  font-size: 15px;
  outline: none;
  min-width: 120px;
}
.form-select:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}
.form-select option {
  background: #24243e;
  color: #e0e0e0;
}

/* Sort select */
.links-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sort-select {
  min-width: 140px;
  font-size: 13px;
  padding: 6px 12px;
}

/* Grouped links */
.link-group {
  margin-bottom: 24px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  overflow: hidden;
}
.link-group:last-child {
  margin-bottom: 0;
}

.group-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}
.group-header:hover {
  background: rgba(255, 255, 255, 0.06);
}

.collapse-icon {
  font-size: 12px;
  color: #888;
  transition: transform 0.2s;
  flex-shrink: 0;
  width: 16px;
  text-align: center;
}

.group-cover {
  width: 60px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.group-title-wrap {
  flex: 1;
}

.group-title {
  font-size: 18px;
  font-weight: 600;
  color: #eee;
  margin-bottom: 4px;
}

.group-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 2px;
}

.group-path {
  font-size: 12px;
  color: #666;
  font-family: monospace;
}

.group-count {
  font-size: 13px;
  color: #888;
}

/* Group recrawl button */
.group-recrawl-btn {
  font-size: 12px !important;
  padding: 4px 12px !important;
  flex-shrink: 0;
  margin-left: auto;
}

/* Group delete button */
.group-del-btn {
  font-size: 14px !important;
  padding: 4px 8px !important;
  flex-shrink: 0;
  margin-left: 4px;
  background: rgba(231, 76, 60, 0.15) !important;
  border-color: rgba(231, 76, 60, 0.3) !important;
}
.group-del-btn:hover {
  background: rgba(231, 76, 60, 0.3) !important;
}

.link-group .table-wrap {
  padding: 0;
}
.group-body {
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.link-group table {
  margin: 0;
}
.link-group th {
  padding: 10px 16px;
  font-size: 11px;
}
.link-group td {
  padding: 10px 16px;
}
.link-group tr:last-child td {
  border-bottom: none;
}

/* Settings panel */
.settings-panel {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 28px;
  margin-bottom: 28px;
}

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

.settings-header h2 {
  font-size: 18px;
  color: #ddd;
}

.settings-body {
  max-width: 500px;
}

.setting-group {
  margin-bottom: 18px;
}

.setting-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #aaa;
  margin-bottom: 6px;
}

.setting-group input {
  width: 100%;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  outline: none;
  transition: all 0.3s;
}

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

.input-with-btn {
  display: flex;
  gap: 8px;
  align-items: center;
}
.input-with-btn input {
  flex: 1;
}
.input-with-btn .btn-sm {
  padding: 10px 16px;
  white-space: nowrap;
  font-size: 13px;
}

.setting-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 24px;
}

.setting-actions .btn-crawl {
  padding: 10px 24px;
}

.settings-msg {
  font-size: 14px;
  color: #2ecc71;
}
