@import url('../fonts/fonts.css');

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

body {
  font-family: 'Poppins', sans-serif;
  background: #fafafa;
  color: #191919;
  min-height: 100vh;
}

/* Auth Pages */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.auth-card {
  background: #fff;
  border-radius: 12px;
  padding: 3rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.auth-logo {
  display: block;
  font-weight: 700;
  font-size: 1rem;
  color: #191919;
  text-decoration: none;
  margin-bottom: 2rem;
}

.auth-card h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 400;
  color: #666;
  margin-bottom: 0.4rem;
}

.form-group input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.2s;
  outline: none;
}

.form-group input:focus {
  border-color: #191919;
}

.btn-primary {
  width: 100%;
  padding: 0.75rem;
  background: #191919;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 0.5rem;
}

.btn-primary:hover {
  background: #333;
}

.auth-link {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.85rem;
  color: #999;
}

.auth-link a {
  color: #191919;
  text-decoration: none;
  font-weight: 600;
}

.auth-link a:hover {
  text-decoration: underline;
}

.error-msg {
  background: #fef2f2;
  color: #b91c1c;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 1.25rem;
  border: 1px solid #fecaca;
}

/* Dashboard */
.dashboard {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid #eee;
  background: #fff;
}

.dash-header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dash-logo {
  font-weight: 700;
  font-size: 1rem;
  color: #191919;
  text-decoration: none;
}

.dash-sep {
  color: #ccc;
  font-weight: 300;
}

.dash-title {
  font-weight: 400;
  font-size: 1rem;
  color: #666;
}

.dash-header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.dash-nav-link {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: #666;
  text-decoration: none;
  padding: 0.35rem 0.7rem;
  border: 1px solid #eee;
  border-radius: 6px;
  transition: all 0.2s;
}

.dash-nav-link:hover {
  border-color: #ccc;
  color: #191919;
}

.dash-nav-link svg { flex-shrink: 0; }

.dash-user {
  font-size: 0.85rem;
  color: #999;
}

.btn-logout {
  background: none;
  border: 1px solid #ddd;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.8rem;
  color: #666;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover {
  border-color: #999;
  color: #191919;
}

.dash-main {
  flex: 1;
  padding: 3rem 2rem;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.dash-main h1 {
  font-size: 1.75rem;
  font-weight: 600;
}

.dash-main-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 2rem;
}

.dash-subtitle {
  color: #999;
  font-size: 0.95rem;
  margin-top: 0.3rem;
}

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

.app-card-wrap {
  position: relative;
}

.app-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
  padding-right: 2.5rem;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.app-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  border-color: #ddd;
}

.app-card-actions {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: flex;
  gap: 0.15rem;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 2;
}

.app-card-wrap:hover .app-card-actions { opacity: 1; }

.app-info-btn,
.app-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  color: #999;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-info-btn:hover { color: #191919; background: #f0f0f0; }
.app-delete-btn:hover { color: #b91c1c; background: #fef2f2; }

.app-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.app-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.app-desc {
  font-size: 0.8rem;
  color: #999;
  margin-top: 0.15rem;
}

.dash-footer {
  padding: 1.5rem 2rem;
  text-align: center;
  border-top: 1px solid #eee;
}

.dash-footer a {
  font-size: 0.85rem;
  color: #999;
  text-decoration: none;
}

.dash-footer a:hover {
  color: #191919;
}

/* Server Panel */
.srv-section-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  margin-top: 2rem;
}

.srv-section-title:first-child { margin-top: 0; }

.srv-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.srv-stat-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 10px;
}

.srv-stat-icon { font-size: 1.5rem; }
.srv-stat-label { font-size: 0.75rem; color: #999; text-transform: uppercase; letter-spacing: 0.03em; }
.srv-stat-value { font-size: 0.9rem; font-weight: 600; margin-top: 0.1rem; }

.srv-table-wrap {
  background: #fff;
  border: 1px solid #eee;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

.srv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.srv-table th {
  text-align: left;
  padding: 0.7rem 1rem;
  font-weight: 600;
  font-size: 0.75rem;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid #eee;
  background: #fafafa;
}

.srv-table td {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid #f5f5f5;
}

.srv-table tbody tr:last-child td { border-bottom: none; }

.srv-mono { font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace; font-size: 0.8rem; color: #666; }

.srv-state {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.srv-state-running { background: #dcfce7; color: #166534; }
.srv-state-stopped { background: #fef2f2; color: #991b1b; }

.srv-row-dir { cursor: pointer; }
.srv-row-dir:hover td { background: #f8f8f8; }

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

.srv-files-actions { display: flex; gap: 0.5rem; }

.srv-btn {
  padding: 0.4rem 0.9rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  font-family: inherit;
  font-size: 0.8rem;
  color: #333;
  cursor: pointer;
  transition: all 0.2s;
}

.srv-btn:hover { border-color: #999; }

.srv-btn-primary {
  background: #191919;
  color: #fff;
  border-color: #191919;
  cursor: pointer;
}

.srv-btn-primary:hover { background: #333; border-color: #333; }

.srv-breadcrumb {
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.srv-breadcrumb a {
  color: #191919;
  text-decoration: none;
  font-weight: 500;
}

.srv-breadcrumb a:hover { text-decoration: underline; }
.srv-crumb-sep { color: #ccc; }

.srv-actions-cell {
  text-align: right;
  white-space: nowrap;
}

.srv-action {
  display: inline-block;
  padding: 0.2rem 0.4rem;
  text-decoration: none;
  font-size: 1rem;
  border-radius: 4px;
  transition: background 0.2s;
}

.srv-action:hover { background: #f0f0f0; }

.srv-action-del {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  transition: background 0.2s;
}

.srv-action-del:hover { background: #fef2f2; }

.srv-drop-zone { position: relative; }
.srv-drop-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(25,25,25,0.85);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 600;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border-radius: 10px;
  z-index: 10;
}

.srv-drop-overlay.active { display: flex; }

/* Connection Info */
.srv-conn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.srv-conn-item {
  background: #fff;
  border: 1px solid #eee;
  border-radius: 10px;
  padding: 0.9rem 1.1rem;
}

.srv-conn-label {
  font-size: 0.75rem;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.4rem;
}

.srv-conn-value {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
  margin: -0.3rem -0.5rem;
  transition: background 0.2s;
}

.srv-conn-value:hover { background: #f5f5f5; }

.srv-conn-value code {
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
  font-size: 0.82rem;
  color: #333;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.srv-conn-copy { color: #999; flex-shrink: 0; }
.srv-conn-value:hover .srv-conn-copy { color: #333; }

.srv-conn-check {
  display: none;
  color: #166534;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.srv-conn-value.copied .srv-conn-copy { display: none; }
.srv-conn-value.copied .srv-conn-check { display: inline; }

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-card {
  background: #fff;
  border-radius: 12px;
  padding: 2rem;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.12);
}

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

.modal-header h2 {
  font-size: 1.2rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #999;
  padding: 0;
  line-height: 1;
}

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

.form-row {
  display: flex;
  gap: 1rem;
}

.info-hint {
  font-size: 0.85rem;
  color: #999;
  margin-bottom: 0.75rem;
}

.info-box {
  background: #f5f5f5;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 1rem;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  color: #333;
}

@media (max-width: 600px) {
  .dash-header {
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
  }
  .dash-main {
    padding: 2rem 1rem;
  }
  .auth-card {
    padding: 2rem;
  }
  .srv-stats { grid-template-columns: 1fr 1fr; }
  .srv-files-header { flex-direction: column; gap: 0.75rem; align-items: flex-start; }
  .dash-main-header { flex-direction: column; gap: 1rem; }
  .app-card-actions { opacity: 1; }
}

/* Icon Select Dropdown */
.icon-select-wrap {
  position: relative;
}

.icon-select-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  transition: border-color 0.2s;
}

.icon-select-btn:hover,
.icon-select-btn:focus {
  border-color: #191919;
  outline: none;
}

#icon-preview,
#edit-icon-preview {
  display: flex;
  align-items: center;
  flex: 1;
}

.icon-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  z-index: 110;
  max-height: 220px;
  overflow-y: auto;
  padding: 0.25rem;
}

.icon-dropdown.open {
  display: block;
}

.icon-option {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.5rem 0.7rem;
  border: none;
  background: none;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  color: #333;
  transition: background 0.15s;
}

.icon-option:hover {
  background: #f5f5f5;
}

.icon-option-svg {
  display: flex;
  align-items: center;
  color: #555;
}

.icon-option-label {
  color: #333;
}

/* Color Swatches */
.color-swatches {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  padding: 0.5rem 0;
}

.color-swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  padding: 0;
  outline: none;
}

.color-swatch:hover {
  transform: scale(1.15);
}

.color-swatch.active {
  border-color: #191919;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #191919;
}

/* Edit button */
.app-edit-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  color: #999;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-edit-btn:hover { color: #1565c0; background: #e3f2fd; }

/* Public badge */
.app-public-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 0.4rem;
  color: #2e7d32;
  vertical-align: middle;
}

/* Toggle switch */
.toggle-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #ccc;
  border-radius: 24px;
  transition: background 0.3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
  background: #2e7d32;
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

.form-hint {
  font-size: 0.75rem;
  color: #999;
  margin-top: 0.3rem;
}

/* User Management */
.usr-role-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.usr-role-admin {
  background: #191919;
  color: #fff;
}
.usr-role-user {
  background: #f0f0f0;
  color: #666;
}
.form-select {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  background: #fff;
  outline: none;
  transition: border-color 0.2s;
  cursor: pointer;
}
.form-select:focus {
  border-color: #191919;
}

/* Project assignment checklist */
.usr-checklist {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 8px;
}
.usr-check-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid #f5f5f5;
  cursor: pointer;
  transition: background 0.15s;
}
.usr-check-item:last-child {
  border-bottom: none;
}
.usr-check-item:hover {
  background: #fafafa;
}
.usr-check-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: #191919;
}
.usr-check-name {
  font-weight: 500;
  font-size: 0.95rem;
}
.usr-check-desc {
  font-size: 0.8rem;
  color: #999;
  margin-left: auto;
}
.srv-action-link {
  background: none;
  border: none;
  color: #1565c0;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: text-decoration-color 0.15s;
}
.srv-action-link:hover {
  text-decoration-color: #1565c0;
}
