/* home.css */

:root {
  --home-sidebar-width: 280px;
  --home-header-height: 64px;
  --home-transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --card-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  --card-shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.12);
  --border-radius-card: 16px;
  --border-radius-element: 10px;
  --container-max-width: 1400px;
}

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

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'LabGrotesque', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow-x: hidden;
  overflow-y: auto;
}

.app-layout {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

.container {
  max-width: var(--container-max-width);
  margin: 0 auto;
  width: 100%;
  padding: 0 24px;
  display: flex;
  gap: 32px;
}

.home-sidebar {
  width: var(--home-sidebar-width);
  flex-shrink: 0;
  position: sticky;
  top: 92px;
  height: fit-content;
}

.user-profile-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-card);
  padding: 24px;
  text-align: center;
  transition: var(--home-transition);
}

.user-profile-card:hover {
  border-color: var(--accent-primary);
  box-shadow: var(--card-shadow-hover);
}

.user-profile-avatar {
  width: 80px;
  height: 80px;
  margin: 0 auto 16px;
  border-radius: 40px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 32px;
  background-size: cover;
  background-position: center;
}

.user-profile-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.user-profile-role {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.user-profile-stats {
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.user-stat {
  display: flex;
  flex-direction: column;
}

.user-stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent-primary);
}

.user-stat-label {
  font-size: 12px;
  color: var(--text-muted);
}

.section-content {
  flex: 1;
  min-width: 0;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--home-transition);
  white-space: nowrap;
  position: relative;
}

.nav-tab:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-tab.active {
  background: rgba(var(--accent-primary-rgb), 0.12);
  color: var(--accent-primary);
}

.nav-tab-icon {
  font-size: 18px;
}

.nav-badge {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  padding: 2px 6px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 4px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

#spacesFilter {
  width: 15%;
}

.app-main {
  flex: 1;
  background: var(--bg-primary);
  padding: 28px 0;
}

.section {
  display: none;
  animation: fadeIn 0.3s ease;
}

.section.active {
  display: block;
}

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

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

.section-header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
}

.section-controls {
  display: flex;
  gap: 12px;
  flex-wrap: nowrap;
  width: 100%;
  flex-direction: row;
}

.space-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
}

.space-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-card);
  overflow: hidden;
  cursor: pointer;
  transition: var(--home-transition);
  position: relative;
  display: flex;
  flex-direction: column;
}

.space-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--card-shadow-hover);
  border-color: var(--accent-primary);
}

.space-banner {
  height: 120px;
  background-size: cover;
  background-position: center;
  background-color: var(--bg-secondary);
  position: relative;
}

.space-header {
  display: flex;
  gap: 15px;
  margin-top: -32px;
  padding: 0 20px;
}

.space-icon {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 3px solid var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  box-shadow: var(--card-shadow);
  background-size: cover;
  background-position: center;
  z-index: 1;
}

.space-text {
  flex: 1;
  padding-top: 20px;
}

.space-name {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.space-description {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}



.space-card-actions {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 10;
}

.space-card:hover .space-card-actions {
  opacity: 1;
}

.space-card-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: var(--card-shadow);
}

.space-card-btn:hover {
  transform: scale(1.1);
}

.space-card-btn.edit:hover {
  background: var(--accent-primary);
  color: #fff;
  border-color: var(--accent-primary);
}

.space-card-btn.delete:hover {
  background: var(--error);
  color: #fff;
  border-color: var(--error);
}

.space-content {
  padding: 20px 20px 20px;
  flex: 1;
}

.space-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  margin-top: 12px;
}

.space-role {
  background: var(--bg-tertiary);
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: 500;
}

.space-status-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: 500;
}

.space-status-badge.idea {
  background: #fef3c7;
  color: #92400e;
}

.space-status-badge.discussing {
  background: #dbeafe;
  color: #1e40af;
}

.space-status-badge.in_progress {
  background: #d1fae5;
  color: #065f46;
}

.space-status-badge.implemented {
  background: #e0e7ff;
  color: #3730a3;
}

.space-status-badge.archived {
  background: #f3f4f6;
  color: #6b7280;
}

.users-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.user-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: var(--home-transition);
}

.user-card:hover {
  border-color: var(--accent-primary);
  box-shadow: var(--card-shadow);
}

.user-info-compact {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-avatar-small {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 20px;
  background-size: cover;
  background-position: center;
}

.user-details-compact {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.user-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.badge-warning {
  background: #fef3c7;
  color: #92400e;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
}

.user-actions {
  display: flex;
  gap: 10px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.audit-filters {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.audit-logs {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-element);
  overflow: hidden;
}

.audit-log-item {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: start;
  transition: background 0.2s;
}

.audit-log-item:hover {
  background: var(--bg-hover);
}

.audit-log-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.audit-log-content {
  flex: 1;
}

.audit-log-action {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  font-size: 14px;
}

.audit-log-details {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.audit-log-time {
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
  font-family: monospace;
}

.audit-pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
  padding: 16px 0;
}

.audit-page-btn {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.audit-page-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
}

.audit-page-btn.active {
  background: var(--accent-primary);
  color: #fff;
  border-color: var(--accent-primary);
}

.audit-page-dots {
  padding: 8px 4px;
  color: var(--text-muted);
}

.settings-content {
  max-width: 800px;
}

.settings-group {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-card);
  padding: 24px;
  margin-bottom: 24px;
}

.settings-group-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 20px 0;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.themes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 16px;
}

.theme-card {
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.theme-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-primary);
  box-shadow: var(--card-shadow);
}

.theme-card.active {
  border-color: var(--accent-primary);
  background: rgba(var(--accent-primary-rgb), 0.08);
}

.theme-preview {
  width: 60px;
  height: 60px;
  margin: 0 auto 12px;
  border-radius: 12px;
  overflow: hidden;
}

.light-preview {
  background: linear-gradient(135deg, #ffffff, #f3f4f6);
  box-shadow: inset 0 0 0 1px #e5e7eb;
}

.dark-preview {
  background: linear-gradient(135deg, #1f2937, #111827);
}

.cappuccino-preview {
  background: linear-gradient(135deg, #f5e6d3, #d4b896);
}

.spotify-preview {
  background: linear-gradient(135deg, #1DB954, #191414);
}

.steam-preview {
  background: linear-gradient(135deg, #171a21, #2a475e);
}

.discord-preview {
  background: linear-gradient(135deg, #5865F2, #404EED);
}

.theme-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.theme-icon {
  font-size: 24px;
  margin-top: 8px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}

.info-row:last-child {
  border-bottom: none;
}

.info-row span:first-child {
  color: var(--text-muted);
}

.info-row span:last-child {
  font-weight: 500;
  color: var(--text-primary);
}

.version-value {
  font-family: monospace;
  font-weight: 600;
}

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

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

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

.form-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(var(--accent-primary-rgb), 0.2);
}

.form-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
}

.input-with-unit {
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-with-unit .form-input {
  flex: 1;
  max-width: 150px;
}

.input-with-unit .unit {
  color: var(--text-muted);
  font-size: 14px;
}

.form-hint {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}

.btn {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.btn-primary {
  background: var(--accent-primary);
  color: #fff;
}

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

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

.btn-danger {
  background: var(--error);
  color: #fff;
}

.btn-danger:hover {
  opacity: 0.9;
}

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

.backups-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.backup-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-element);
  transition: all 0.2s;
}

.backup-item:hover {
  border-color: var(--accent-primary);
}

.backup-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.backup-filename {
  font-weight: 500;
  color: var(--text-primary);
  font-family: monospace;
  font-size: 14px;
}

.backup-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.backup-actions {
  display: flex;
  gap: 8px;
}

.backup-btn {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.backup-btn:hover {
  transform: scale(1.02);
}

.backup-btn.restore:hover {
  background: #ff9800;
  color: #fff;
  border-color: #ff9800;
}

.backup-btn.delete:hover {
  background: var(--error);
  color: #fff;
  border-color: var(--error);
}

.update-success {
  padding: 12px;
  background: #d1fae5;
  border-radius: 8px;
  color: #065f46;
  text-align: center;
}

.update-error {
  padding: 12px;
  background: #fee2e2;
  border-radius: 8px;
  color: #991b1b;
  text-align: center;
}

.update-warning {
  padding: 12px;
  background: #fef3c7;
  border-radius: 8px;
  color: #92400e;
  text-align: center;
}

.update-highlight {
  color: #ef4444;
  font-weight: 600;
}

.warning-box {
  background: #fef3c7;
  border-radius: 8px;
  color: #92400e;
}

.change-item {
  padding: 4px 0;
  font-size: 12px;
  font-family: monospace;
}

.change-type {
  color: #6b7280;
  font-size: 11px;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state.error {
  color: var(--error);
}

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--border-radius-card);
  width: 90%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--card-shadow-hover);
}

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

.modal-title {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal form {
  padding: 24px;
}

.confirm-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 1001;
}

.confirm-modal.active {
  display: flex;
}

.confirm-modal-content {
  background: var(--bg-card);
  border-radius: var(--border-radius-card);
  padding: 28px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: var(--card-shadow-hover);
  border: 1px solid var(--border-color);
}

.confirm-modal-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.confirm-modal-message {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.5;
}

.confirm-modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.toggle-group {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
}

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

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-tertiary);
  transition: 0.3s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--accent-primary);
}

input:checked + .slider:before {
  transform: translateX(24px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

.toggle-label {
  font-size: 14px;
  color: var(--text-primary);
}

.secure-form-group {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

@media (max-width: 1024px) {
  .container {
    flex-direction: column;
  }
  
  .home-sidebar {
    width: 100%;
    position: static;
    margin-bottom: 24px;
  }
  
  .user-profile-card {
    display: flex;
    align-items: center;
    text-align: left;
    gap: 20px;
    flex-wrap: wrap;
  }
  
  .user-profile-avatar {
    margin: 0;
  }
  
  .user-profile-stats {
    margin-left: auto;
    padding-top: 0;
    border-top: none;
  }
}

@media (max-width: 768px) {
  .space-grid {
    grid-template-columns: 1fr;
  }
  
  .container {
    padding: 0 16px;
  }
  
  .audit-log-item {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  
  .audit-log-time {
    text-align: left;
  }
  
  .section-controls {
    flex-direction: column;
  }
  
  .section-controls .form-input,
  .section-controls .form-select,
  .section-controls .btn {
    width: 100%;
  }
  
  .user-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  
  .user-actions {
    width: 100%;
    justify-content: flex-end;
  }
  
  .themes-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }
  
  .settings-content {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 12px;
  }
  
  .user-profile-card {
    flex-direction: column;
    text-align: center;
  }
  
  .user-profile-stats {
    margin-left: 0;
    width: 100%;
  }
  
  .backup-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .backup-actions {
    width: 100%;
    justify-content: flex-end;
  }
}