/* ========================================
   Sites List Page - Styles
   ======================================== */

/* ========================================
   Page Layout
   ======================================== */

.sites-page {
  background: var(--bg-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ========================================
   Header
   ======================================== */

.sites-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
}

.header-container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.btn-icon {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--border-radius-sm);
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  margin-left: 8px;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.user-menu:hover {
  background: var(--bg-hover);
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-purple) 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: white;
}

.user-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.user-menu .material-icons {
  font-size: 18px;
  color: var(--text-muted);
}

.user-menu {
  position: relative;
}

.user-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  min-width: 220px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s;
  z-index: 100;
}

.user-dropdown.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-header {
  padding: 12px 16px;
}

.dropdown-email {
  font-size: 13px;
  color: var(--text-muted);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 0;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.2s;
}

.dropdown-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.dropdown-item .material-icons {
  font-size: 18px;
}

.dropdown-item.text-danger {
  color: var(--accent-red);
}

.dropdown-item.text-danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* Loading State */
.loading-state {
  text-align: center;
  padding: 60px 20px;
}

.loading-state .loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

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

.loading-state p {
  color: var(--text-muted);
  font-size: 14px;
}

/* Role Tag */
.tag-role {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
  text-transform: capitalize;
}

/* ========================================
   Main Content
   ======================================== */

.sites-main {
  flex: 1;
  padding: 32px 24px;
}

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

/* ========================================
   Page Header
   ======================================== */

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

.page-title {
  display: flex;
  align-items: center;
  gap: 16px;
}

.page-title h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
}

.download-link {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--accent-blue);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s;
}

.download-link:hover {
  color: #60a5fa;
}

.download-link .material-icons {
  font-size: 18px;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 8px 12px;
  min-width: 250px;
}

.search-box .material-icons {
  color: var(--text-muted);
  font-size: 20px;
}

.search-box input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 14px;
  width: 100%;
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.btn-primary {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-blue);
  color: white;
  border: none;
  border-radius: var(--border-radius-sm);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:hover {
  background: #2563eb;
}

.btn-primary .material-icons {
  font-size: 18px;
}

.btn-secondary {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-hover);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--bg-secondary);
}

.btn-text {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  padding: 8px 12px;
  transition: color 0.2s;
}

.btn-text:hover:not(:disabled) {
  color: var(--text-primary);
}

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

/* ========================================
   Sites Table
   ======================================== */

.sites-table-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  overflow: hidden;
}

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

.sites-table th {
  text-align: left;
  padding: 16px 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card);
}

.sites-table td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

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

.sites-table tbody tr:hover {
  background: rgba(59, 130, 246, 0.05);
}

.col-status {
  width: 60px;
}

.col-name {
  width: 30%;
}

.col-owner {
  width: 20%;
}

.col-detail {
  width: 35%;
}

.col-action {
  width: 160px;
  text-align: right;
}

/* Site Status Icon */
.site-status {
  width: 40px;
  height: 40px;
  background: var(--bg-primary);
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.site-status .material-icons {
  font-size: 22px;
  color: var(--text-muted);
}

.site-status.online .material-icons {
  color: var(--accent-green);
}

.site-status.offline .material-icons {
  color: var(--text-muted);
}

.status-indicator {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--bg-secondary);
}

.status-indicator.online {
  background: var(--accent-green);
}

.status-indicator.offline {
  background: var(--text-muted);
}

/* Site Name */
.site-name-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.site-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--accent-blue);
  text-decoration: none;
  cursor: pointer;
  transition: color 0.2s;
}

.site-name:hover {
  color: #60a5fa;
  text-decoration: underline;
}

.site-description {
  font-size: 13px;
  color: var(--text-muted);
}

/* Owner */
.site-owner {
  font-size: 14px;
  color: var(--text-secondary);
}

/* Detail Tags */
.site-detail {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.detail-brand {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-block;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  text-transform: uppercase;
}

.tag-location {
  background: rgba(34, 197, 94, 0.15);
  color: var(--accent-green);
}

.tag-connection {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
}

.tag-mppt {
  background: rgba(168, 85, 247, 0.15);
  color: var(--accent-purple);
}

.tag-model {
  background: rgba(251, 191, 36, 0.15);
  color: var(--accent-yellow);
}

.tag-protocol {
  background: rgba(100, 116, 139, 0.15);
  color: var(--text-secondary);
}

.tag-beta {
  background: rgba(249, 115, 22, 0.15);
  color: var(--accent-orange);
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.btn-view,
.btn-edit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-view {
  color: var(--text-primary);
}

.btn-view:hover {
  background: var(--bg-hover);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

.btn-edit {
  color: var(--text-secondary);
}

.btn-edit:hover {
  background: var(--bg-hover);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

/* ========================================
   Pagination
   ======================================== */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  margin-top: 8px;
}

.pagination-info {
  font-size: 14px;
  color: var(--text-secondary);
}

.pagination-info strong {
  color: var(--text-primary);
}

.pagination-controls {
  display: flex;
  gap: 8px;
}

/* ========================================
   Modal
   ======================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(-20px);
  transition: transform 0.2s;
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-card);
}

/* ========================================
   Form Elements
   ======================================== */

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

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent-blue);
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.form-group select {
  cursor: pointer;
}

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

/* ========================================
   Empty State
   ======================================== */

.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-state .material-icons {
  font-size: 64px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 1024px) {
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .search-box {
    flex: 1;
    min-width: 200px;
  }
}

@media (max-width: 768px) {
  .sites-header {
    padding: 0 16px;
  }

  .user-name {
    display: none;
  }

  .sites-main {
    padding: 20px 16px;
  }

  .page-title {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .sites-table-container {
    overflow-x: auto;
  }

  .sites-table {
    min-width: 600px;
  }

  .col-owner {
    display: none;
  }

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

  .pagination {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }
}
