:root {
  --primary: #e31337;
  --secondary: #2c3e50;
  --success: #27ae60;
  --danger: #e74c3c;
  --warning: #f39c12;
  --light: #ecf0f1;
  --dark: #2c3e50;
  --gray: #95a5a6;
  --border: #dfe6e9;
  --shadow: rgba(0, 0, 0, 0.1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: #f5f6fa;
  color: var(--dark);
  line-height: 1.6;
}

/* Login Screen */
.screen {
  display: none;
}

.screen.active {
  display: block;
}

.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  padding: 2rem;
}

.login-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3rem;
  width: 100%;
  max-width: 500px;
}

.logo-section {
  text-align: center;
  animation: fadeInDown 0.6s ease-out;
}

.logo-image {
  width: 120px;
  height: 120px;
  object-fit: contain;
  margin-bottom: 1.5rem;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.2));
}

.brand-name {
  font-size: 3rem;
  color: white;
  margin-bottom: 0.5rem;
  font-weight: 700;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.tagline {
  color: rgba(255, 255, 255, 0.95);
  font-size: 1.2rem;
  font-weight: 300;
}

.login-card {
  background: white;
  padding: 3rem;
  border-radius: 1rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
  width: 100%;
  animation: fadeInUp 0.6s ease-out;
}

.login-card h2 {
  margin-bottom: 0.5rem;
  color: var(--dark);
  font-size: 1.8rem;
}

.subtitle {
  color: var(--gray);
  margin-bottom: 2rem;
  font-size: 1rem;
}

.btn-keychain {
  width: 100%;
  padding: 1rem 2rem;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-keychain:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(227, 19, 55, 0.3);
}

.btn-keychain .icon {
  font-size: 1.5rem;
}

.info {
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--gray);
}

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

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

/* Navbar */
.navbar {
  background: white;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 10px var(--shadow);
}

.nav-brand h2 {
  color: var(--primary);
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Language Switcher */
.language-switcher {
  display: flex;
  gap: 0.5rem;
  margin-right: 1rem;
}

.lang-btn {
  padding: 0.5rem 0.75rem;
  border: 2px solid var(--border);
  background: white;
  color: var(--dark);
  border-radius: 0.25rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  transition: all 0.3s;
}

.lang-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.lang-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Role Badge */
.role-badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-left: 0.5rem;
}

.role-badge.role-owner {
  background: linear-gradient(135deg, #ffd700, #ffaa00);
  color: #5c4a00;
  box-shadow: 0 2px 8px rgba(255, 170, 0, 0.4);
}

.role-badge.role-admin {
  background: linear-gradient(135deg, var(--primary), #b8102d);
  color: white;
  box-shadow: 0 2px 8px rgba(227, 19, 55, 0.4);
}

.role-badge.role-mod {
  background: linear-gradient(135deg, #28a745, #1e7b34);
  color: white;
  box-shadow: 0 2px 8px rgba(40, 167, 69, 0.4);
}

.role-badge.role-member {
  background: linear-gradient(135deg, #17a2b8, #117a8b);
  color: white;
  box-shadow: 0 2px 8px rgba(23, 162, 184, 0.4);
}

.role-badge.role-guest {
  background: var(--light);
  color: var(--gray);
  border: 1px solid var(--border);
}

.role-badge.role-none {
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffc107;
}

/* Language Switcher in Login */
.language-switcher-login {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.lang-btn-login {
  padding: 0.6rem 1.2rem;
  border: 2px solid var(--border);
  background: white;
  color: var(--dark);
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: all 0.3s;
  min-width: 100px;
}

.lang-btn-login:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(227, 19, 55, 0.05);
  transform: translateY(-1px);
}

.lang-btn-login.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(227, 19, 55, 0.3);
}

/* Container */
.container {
  display: flex;
  min-height: calc(100vh - 70px);
}

/* Sidebar */
.sidebar {
  width: 250px;
  background: white;
  padding: 2rem 0;
  box-shadow: 2px 0 10px var(--shadow);
}

.menu {
  list-style: none;
}

.menu-item {
  display: block;
  padding: 1rem 2rem;
  color: var(--dark);
  text-decoration: none;
  transition: all 0.3s;
}

.menu-item:hover,
.menu-item.active {
  background: var(--light);
  border-left: 4px solid var(--primary);
  color: var(--primary);
}

/* Content */
.content {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: white;
  padding: 2rem;
  border-radius: 0.5rem;
  box-shadow: 0 2px 10px var(--shadow);
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.stat-card h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Info Tooltip */
.info-tooltip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  font-size: 0.85rem;
  opacity: 0.7;
  transition: opacity 0.2s;
  position: relative;
}

.info-tooltip:hover {
  opacity: 1;
}

.stat-icon {
  font-size: 3rem;
}

.stat-info h3 {
  font-size: 2rem;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.stat-info p {
  color: var(--gray);
}

/* Community Info */
.community-info {
  background: white;
  padding: 2rem;
  border-radius: 0.5rem;
  box-shadow: 0 2px 10px var(--shadow);
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.info-item {
  padding: 1rem;
  background: var(--light);
  border-radius: 0.5rem;
}

.info-item strong {
  color: var(--dark);
  display: block;
  margin-bottom: 0.5rem;
}

/* Table */
.search-bar {
  margin-bottom: 1rem;
}

.search-bar input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  font-size: 1rem;
}

.table-container {
  background: white;
  border-radius: 0.5rem;
  box-shadow: 0 2px 10px var(--shadow);
  overflow: hidden;
}

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

thead {
  background: var(--dark);
  color: white;
}

th, td {
  padding: 1rem;
  text-align: left;
}

tbody tr {
  border-bottom: 1px solid var(--border);
}

tbody tr:hover {
  background: var(--light);
}

.loading {
  text-align: center;
  padding: 2rem;
  color: var(--gray);
}

/* Roles */
.roles-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.role-section {
  background: white;
  padding: 1.5rem;
  border-radius: 0.5rem;
  box-shadow: 0 2px 10px var(--shadow);
}

.role-section h3 {
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
}

.role-list {
  list-style: none;
}

.role-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.role-list li:last-child {
  border-bottom: none;
}

.role-actions {
  background: white;
  padding: 2rem;
  border-radius: 0.5rem;
  box-shadow: 0 2px 10px var(--shadow);
}

/* Posts */
.posts-grid {
  display: grid;
  gap: 1.5rem;
}

.post-card {
  background: white;
  padding: 1.5rem;
  border-radius: 0.5rem;
  box-shadow: 0 2px 10px var(--shadow);
}

.post-meta {
  color: var(--gray);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.post-title {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
  color: var(--dark);
}

.post-excerpt {
  color: var(--gray);
  margin-bottom: 1rem;
}

/* Moderation */
.moderation-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.action-card {
  background: white;
  padding: 2rem;
  border-radius: 0.5rem;
  box-shadow: 0 2px 10px var(--shadow);
}

.action-card h3 {
  margin-bottom: 1rem;
}

/* Form */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

input[type="text"],
input[type="password"],
select,
textarea {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  font-size: 1rem;
  font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
}

/* Buttons */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

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

.btn-secondary {
  background: var(--secondary);
  color: white;
}

.btn-secondary:hover {
  background: #1e2d3d;
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #229954;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #c0392b;
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

.icon {
  font-size: 1.2rem;
}

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

.modal.active {
  display: flex;
}

.modal-content {
  background: white;
  padding: 2rem;
  border-radius: 0.5rem;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 10px 40px var(--shadow);
}

.modal-large {
  max-width: 900px;
  max-height: 90vh;
  overflow-y: auto;
}

.close {
  float: right;
  font-size: 2rem;
  cursor: pointer;
  color: var(--gray);
}

.close:hover {
  color: var(--dark);
}

#modal-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
  justify-content: flex-end;
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
  }

  .login-content {
    gap: 2rem;
  }

  .logo-image {
    width: 80px;
    height: 80px;
  }

  .brand-name {
    font-size: 2.5rem;
  }

  .tagline {
    font-size: 1rem;
  }

  .login-card {
    padding: 2rem 1.5rem;
    width: 100%;
  }

  .login-card h2 {
    font-size: 1.5rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* Data Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px var(--shadow);
  margin-top: 1rem;
}

.data-table thead {
  background: var(--light);
}

.data-table th {
  padding: 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--secondary);
  border-bottom: 2px solid var(--border);
}

.data-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

.data-table tbody tr:hover {
  background: #f8f9fa;
}

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

/* Post Detail Modal */
.post-detail-header {
  border-bottom: 2px solid var(--border);
  padding-bottom: 1rem;
  margin-bottom: 1rem;
}

.post-detail-title {
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
  color: var(--dark);
}

.post-detail-meta {
  color: var(--gray);
  font-size: 0.9rem;
}

.post-detail-body {
  line-height: 1.8;
  margin: 1.5rem 0;
  color: var(--secondary);
}

.post-detail-body img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 1rem 0;
}

.post-detail-stats {
  display: flex;
  gap: 2rem;
  padding: 1rem;
  background: var(--light);
  border-radius: 8px;
  margin: 1rem 0;
}

.post-replies {
  margin-top: 2rem;
  border-top: 2px solid var(--border);
  padding-top: 1rem;
}

.post-replies h3 {
  margin-bottom: 1rem;
  color: var(--secondary);
}

.reply-item {
  background: #f8f9fa;
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  border-left: 3px solid var(--primary);
}

.reply-author {
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

/* Avatar Styles */
.avatar {
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.avatar-small {
  width: 28px;
  height: 28px;
}

.avatar-medium {
  width: 40px;
  height: 40px;
}

.avatar-large {
  width: 56px;
  height: 56px;
}

.avatar-with-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.avatar-with-name .username {
  font-weight: 600;
  color: var(--primary);
}

/* Post Card with Avatar */
.post-card {
  background: white;
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 8px var(--shadow);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.post-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px var(--shadow);
}

.post-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.post-author-info {
  display: flex;
  flex-direction: column;
}

.post-author {
  font-weight: 600;
  color: var(--primary);
  font-size: 0.95rem;
}

.post-timestamp {
  font-size: 0.8rem;
  color: var(--gray);
}

.post-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 0.5rem;
}

.post-excerpt {
  color: var(--gray);
  font-size: 0.9rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-footer {
  display: flex;
  gap: 1.5rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--gray);
}

.post-stat {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Reply with Avatar */
.reply-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.reply-author-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.reply-author-info .username {
  font-weight: 600;
  color: var(--primary);
}

.reply-timestamp {
  font-size: 0.75rem;
  color: var(--gray);
}

.reply-date {
  color: var(--gray);
  font-size: 0.85rem;
}

.reply-body {
  margin-top: 0.5rem;
  line-height: 1.6;
  color: var(--secondary);
}

.post-card {
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.post-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--shadow);
}

/* Hub Selector Screen */
.hub-selector-container {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--secondary) 0%, #1a252f 100%);
  padding: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hub-selector-content {
  width: 100%;
  max-width: 900px;
}

.hub-selector-header {
  margin-bottom: 2rem;
  color: white;
}

.hub-selector-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.hub-selector-titles {
  text-align: left;
}

.hub-selector-header h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.hub-selector-header .subtitle {
  color: rgba(255, 255, 255, 0.7);
  font-size: 1.1rem;
  margin-bottom: 0;
}

.hub-selector-header-top .btn {
  white-space: nowrap;
}

.logged-in-as {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.9rem;
}

.logged-in-as strong {
  color: white;
}

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

.hub-card {
  background: white;
  border-radius: 1rem;
  padding: 1.5rem;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.hub-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.hub-card-header {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.hub-card-header .avatar {
  width: 50px;
  height: 50px;
}

.hub-card-info h3 {
  font-size: 1.1rem;
  color: var(--dark);
  margin-bottom: 0.25rem;
}

.hub-card-info .location {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--gray);
  font-size: 0.85rem;
}

.hub-card-description {
  color: var(--gray);
  font-size: 0.9rem;
  line-height: 1.5;
  flex-grow: 1;
}

.hub-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.hub-card-owner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--gray);
}

.hub-card-owner .avatar {
  width: 24px;
  height: 24px;
}

.hub-card-language {
  background: var(--light);
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--secondary);
}

.hub-card-stats {
  display: flex;
  gap: 1rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
}

.hub-card-stat {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--gray);
}

.hub-card-stat .stat-icon {
  font-size: 1rem;
}

.hub-card-stat .stat-value {
  font-weight: 600;
  color: var(--secondary);
}

/* Back to hubs button */
#back-to-hubs {
  margin-right: 0.75rem;
}

.nav-brand {
  display: flex;
  align-items: center;
}

/* Registration Modal */
.modal-medium {
  max-width: 500px;
}

.register-hub-content h2 {
  margin-bottom: 0.5rem;
  color: var(--secondary);
}

.register-hub-content .subtitle {
  color: var(--gray);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

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

#register-hub-form label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--secondary);
}

#register-hub-form input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#register-hub-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(246, 186, 0, 0.2);
}

.form-hint {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--gray);
}

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

.form-error {
  background: #fee2e2;
  border: 1px solid #fecaca;
  color: #dc2626;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.form-success {
  background: #d1fae5;
  border: 1px solid #a7f3d0;
  color: #059669;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.form-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

#register-submit {
  min-width: 160px;
}

#register-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
