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

:root {
  --primary: #4F46E5;
  --primary-dark: #4338CA;
  --secondary: #10B981;
  --danger: #EF4444;
  --warning: #F59E0B;
  --bg: #F9FAFB;
  --card-bg: #FFFFFF;
  --text: #1F2937;
  --text-light: #6B7280;
  --border: #E5E7EB;
  --shadow: rgba(0, 0, 0, 0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* Pages */
.page {
  display: none;
}

.page.active {
  display: block;
}

/* Auth Page */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  padding: 20px;
}

.auth-card {
  background: var(--card-bg);
  padding: 40px;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 420px;
  animation: slideUp 0.5s ease;
}

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

.logo {
  font-size: 2.5rem;
  text-align: center;
  margin-bottom: 10px;
  color: var(--primary);
}

.tagline {
  text-align: center;
  color: var(--text-light);
  margin-bottom: 30px;
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
}

.auth-form h2 {
  margin-bottom: 20px;
  color: var(--text);
}

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

.form-group input {
  width: 100%;
  padding: 14px 18px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  transition: all 0.3s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.switch-form {
  text-align: center;
  margin-top: 20px;
  color: var(--text-light);
}

.switch-form a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

/* Navbar */
.navbar {
  background: var(--card-bg);
  box-shadow: 0 2px 10px var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-brand {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.nav-menu {
  display: flex;
  gap: 10px;
}

.nav-item {
  padding: 10px 20px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  transition: all 0.3s;
  position: relative;
}

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

.nav-item.active {
  background: var(--primary);
  color: white;
}

.badge {
  position: absolute;
  top: 5px;
  right: 10px;
  background: var(--danger);
  color: white;
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.permission-badge {
  background: var(--secondary);
  color: white;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
}

/* Content Sections */
.content-section {
  display: none;
  padding: 20px;
}

.content-section.active {
  display: block;
}

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

/* Create Post */
.create-post-card {
  background: var(--card-bg);
  padding: 20px;
  border-radius: 15px;
  box-shadow: 0 2px 10px var(--shadow);
  margin-bottom: 20px;
}

.create-post-card h3 {
  margin-bottom: 15px;
}

.create-post-card textarea {
  width: 100%;
  min-height: 100px;
  padding: 15px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 15px;
}

.create-post-card textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.post-actions {
  display: flex;
  justify-content: flex-end;
}

/* Posts */
.posts-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.post-card {
  background: var(--card-bg);
  padding: 20px;
  border-radius: 15px;
  box-shadow: 0 2px 10px var(--shadow);
  transition: all 0.3s;
}

.post-card:hover {
  box-shadow: 0 4px 20px var(--shadow);
}

.post-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 15px;
}

.post-avatar {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
}

.post-user-info h4 {
  margin-bottom: 2px;
}

.post-time {
  font-size: 13px;
  color: var(--text-light);
}

.post-content {
  margin-bottom: 15px;
  line-height: 1.6;
}

.post-footer {
  display: flex;
  gap: 15px;
  padding-top: 15px;
  border-top: 1px solid var(--border);
}

.post-action {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  transition: all 0.3s;
}

.post-action:hover {
  background: var(--bg);
}

.post-action.liked {
  color: var(--danger);
}

.post-action.delete-btn {
  color: var(--danger);
  margin-left: auto;
}

/* Messages */
.messages-layout {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 20px;
  height: calc(100vh - 120px);
}

.conversations-list {
  background: var(--card-bg);
  border-radius: 15px;
  padding: 20px;
  overflow-y: auto;
}

.conversations-list h3 {
  margin-bottom: 15px;
}

.search-users {
  position: relative;
  margin-bottom: 20px;
}

.search-users input {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 10px;
}

.search-results {
  position: absolute;
  width: 100%;
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  margin-top: 5px;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 4px 12px var(--shadow);
  z-index: 10;
}

.search-result-item {
  padding: 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}

.search-result-item:hover {
  background: var(--bg);
}

.conversation-item {
  padding: 15px;
  border-radius: 10px;
  cursor: pointer;
  margin-bottom: 10px;
  transition: all 0.3s;
  border: 2px solid transparent;
}

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

.conversation-item.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.conversation-name {
  font-weight: 600;
  margin-bottom: 5px;
}

.conversation-preview {
  font-size: 14px;
  color: var(--text-light);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-item.active .conversation-preview {
  color: rgba(255, 255, 255, 0.8);
}

.chat-window {
  background: var(--card-bg);
  border-radius: 15px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  padding: 20px;
  border-bottom: 2px solid var(--border);
}

.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column-reverse;
}

.no-chat-selected {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-light);
}

.no-chat-selected i {
  font-size: 4rem;
  margin-bottom: 20px;
}

.message {
  margin-bottom: 15px;
  display: flex;
  flex-direction: column;
}

.message.sent {
  align-items: flex-end;
}

.message.received {
  align-items: flex-start;
}

.message-bubble {
  max-width: 70%;
  padding: 12px 16px;
  border-radius: 15px;
  word-wrap: break-word;
}

.message.sent .message-bubble {
  background: var(--primary);
  color: white;
}

.message.received .message-bubble {
  background: var(--bg);
  color: var(--text);
}

.message-time {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 5px;
}

.chat-input {
  padding: 20px;
  border-top: 2px solid var(--border);
  display: flex;
  gap: 10px;
}

.chat-input input {
  flex: 1;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
}

/* Admin */
.admin-panel {
  background: var(--card-bg);
  padding: 20px;
  border-radius: 15px;
  box-shadow: 0 2px 10px var(--shadow);
}

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

.user-item:last-child {
  border-bottom: none;
}

.user-details h4 {
  margin-bottom: 5px;
}

.user-email {
  color: var(--text-light);
  font-size: 14px;
}

.permission-controls {
  display: flex;
  gap: 10px;
  align-items: center;
}

.permission-controls select {
  padding: 8px 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 14px;
}

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

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--card-bg);
  padding: 30px;
  border-radius: 15px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.close {
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  color: var(--text-light);
}

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

.comment-item {
  padding: 15px;
  border-bottom: 1px solid var(--border);
}

.comment-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.comment-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--secondary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}

.add-comment {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.add-comment input {
  flex: 1;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 10px;
}

/* Responsive */
@media (max-width: 768px) {
  .messages-layout {
    grid-template-columns: 1fr;
  }
  
  .conversations-list {
    display: none;
  }
  
  .conversations-list.mobile-show {
    display: block;
  }
  
  .nav-menu {
    flex-wrap: wrap;
  }
}
