/* ==========================================
   Admin Portal Styles
   ========================================== */

:root {
  --primary-color: #2c3e50;
  --secondary-color: #e74c3c;
  --accent-color: #3498db;
  --success-color: #27ae60;
  --warning-color: #f39c12;
  --error-color: #e74c3c;
  --bg-dark: #1a1a2e;
  --bg-light: #f8f9fa;
  --text-dark: #2c3e50;
  --text-light: #7f8c8d;
  --border-color: #dfe6e9;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

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

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

/* ==========================================
   Login Screen
   ========================================== */
.login-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
}

.login-container {
  background: white;
  border-radius: 16px;
  padding: 3rem;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-header h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  color: var(--primary-color);
}

.login-header h2 {
  font-size: 1.5rem;
  color: var(--text-light);
  font-weight: 400;
}

.login-form {
  margin-bottom: 2rem;
}

.login-footer {
  text-align: center;
  color: var(--text-light);
  font-size: 0.875rem;
}

/* ==========================================
   Form Elements
   ========================================== */
.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text-dark);
}

.form-group input {
  width: 100%;
  padding: 0.875rem;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.3s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent-color);
}

/* ==========================================
   Buttons
   ========================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  width: 100%;
}

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

.btn-primary:hover {
  background-color: #2980b9;
  transform: translateY(-1px);
}

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

.btn-secondary:hover {
  background-color: #5f6c7a;
}

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

/* ==========================================
   Alerts
   ========================================== */
.alert {
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.alert-success {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.alert-error {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.alert-info {
  background-color: #d1ecf1;
  color: #0c5460;
  border: 1px solid #bee5eb;
}

/* ==========================================
   Admin Dashboard Layout
   ========================================== */
.admin-dashboard {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ==========================================
   Main Content
   ========================================== */
.main-content {
  flex: 1;
  overflow-y: auto;
  background-color: var(--bg-light);
}

.view {
  display: none;
  padding: 2rem;
  margin: 0 auto;
}

.view.active {
  display: block;
}

.view-header {
  margin-bottom: 2rem;
}

/* ==========================================
   Sidebar Toggle & Collapsed State
   ========================================== */
#sidebarToggle {
  background: none;
  border: none;
  color: white;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 4px;
  transition: background 0.2s;
}

#sidebarToggle:hover {
  background: rgba(255, 255, 255, 0.1);
}

.sidebar-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: all 0.3s;
}

.sidebar.collapsed {
  width: 60px;
}

.sidebar.collapsed .sidebar-header {
  padding: 1rem 0.5rem;
  align-items: center;
}

.sidebar.collapsed .sidebar-header h1,
.sidebar.collapsed .sidebar-header p,
.sidebar.collapsed #userEmail {
  display: none;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 1rem 0;
}

.sidebar.collapsed .nav-item span:last-child {
  display: none;
}

.sidebar.collapsed .sidebar-footer button span:last-child {
  display: none;
}

.sidebar.collapsed .sidebar-footer {
  padding: 1rem 0.5rem;
  display: flex;
  justify-content: center;
}

.sidebar.collapsed .sidebar-footer .btn {
  padding: 0.5rem;
  width: auto;
}

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

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

.chat-modal-content {
  background: white;
  width: 90%;
  max-width: 600px;
  height: 80vh;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.modal-header {
  padding: 1rem;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-secondary);
  border-radius: 8px 8px 0 0;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  background: #f8f9fa;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-bubble {
  padding: 12px 18px;
  border-radius: 12px;
  max-width: 85%;
  line-height: 1.5;
  font-size: 0.95rem;
  position: relative;
}

.chat-bubble.user {
  background: #e2e8f0;
  color: #1a202c;
  align-self: flex-end;
  border-bottom-right-radius: 2px;
}

.chat-bubble.assistant {
  background: #fff;
  border: 1px solid #e2e8f0;
  color: #2d3748;
  align-self: flex-start;
  border-bottom-left-radius: 2px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

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

.close-btn:hover {
  color: #000;
}

.view-header h2 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  color: var(--primary-color);
}

.view-header p {
  color: var(--text-light);
  font-size: 1.125rem;
}

/* ==========================================
   Chat Interface
   ========================================== */
.chat-container {
  background: white;
  border-radius: 16px;
  box-shadow: var(--shadow);
  height: calc(100vh - 200px);
  display: flex;
  flex-direction: column;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
}

.message {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  animation: fadeInUp 0.3s;
}

.message-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.message.assistant .message-avatar {
  background-color: var(--accent-color);
}

.message.user .message-avatar {
  background-color: var(--success-color);
}

.message-content {
  flex: 1;
  background-color: var(--bg-light);
  padding: 1rem 1.25rem;
  border-radius: 12px;
}

.message.user .message-content {
  background-color: var(--accent-color);
  color: white;
}

.message-content p {
  margin-bottom: 0.5rem;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content ul {
  margin-left: 1.5rem;
  margin-top: 0.5rem;
}

.message-content li {
  margin-bottom: 0.25rem;
}

.message-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.message-actions button {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.chat-input-container {
  display: flex;
  gap: 1rem;
  padding: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.chat-input {
  flex: 1;
  padding: 0.875rem;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
}

.chat-input:focus {
  outline: none;
  border-color: var(--accent-color);
}

.chat-input-container .btn {
  width: auto;
  min-width: 100px;
}

/* ==========================================
   Content Editor
   ========================================== */
.content-editor {
  background: white;
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 2rem;
}

.editor-toolbar {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.editor-toolbar .btn {
  width: auto;
}

.code-editor {
  width: 100%;
  min-height: 500px;
  padding: 1rem;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
  font-size: 0.875rem;
  line-height: 1.6;
  resize: vertical;
}

.code-editor:focus {
  outline: none;
  border-color: var(--accent-color);
}

/* ==========================================
   Loading Spinner
   ========================================== */
.loading {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.6s linear infinite;
}

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

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================
   Magazine Upload Styles
   ========================================== */
.magazine-review-card {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 1.5rem;
  margin-top: 1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  animation: fadeInUp 0.3s ease-out;
}

.magazine-review-card input:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.magazine-review-card img {
  transition: transform 0.3s;
}

.magazine-review-card img:hover {
  transform: scale(1.02);
}

#uploadedBtn {
  transition: all 0.2s;
}

#uploadBtn:hover {
  background-color: #e0e0e0;
  transform: translateY(-1px);
}

#uploadBtn:active {
  transform: translateY(0);
}

@media (max-width: 768px) {
  .admin-dashboard {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
  }

  .sidebar-nav {
    display: flex;
    overflow-x: auto;
  }

  .nav-item {
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.75rem;
    text-align: center;
    font-size: 0.75rem;
  }

  .chat-container {
    height: calc(100vh - 300px);
  }
}

/* ==========================================
   Contacts View Styles
   ========================================== */
.contacts-container {
  padding: 2rem;
  max-width: 100%;
  margin: 0 auto;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 2px solid #e0e0e0;
}

.page-header h1 {
  margin: 0;
  color: #2c3e50;
}

.stats-bar {
  display: flex;
  gap: 20px;
  margin-bottom: 30px;
  flex-wrap: wrap;
}

.stat-card {
  flex: 1;
  min-width: 200px;
  padding: 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.stat-card.new {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.stat-card.read {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.stat-label {
  font-size: 14px;
  opacity: 0.9;
  margin-bottom: 5px;
}

.stat-value {
  font-size: 32px;
  font-weight: bold;
}

.filters {
  display: flex;
  gap: 15px;
  margin-bottom: 30px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 10px 20px;
  border: 2px solid #ddd;
  background: white;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s;
  font-size: 14px;
}

.filter-btn:hover {
  border-color: #667eea;
  color: #667eea;
}

.filter-btn.active {
  background: #667eea;
  color: white;
  border-color: #667eea;
}

.search-box {
  flex: 1;
  min-width: 300px;
  padding: 10px 15px;
  border: 2px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
}

.search-box:focus {
  outline: none;
  border-color: #667eea;
}

.contacts-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.contact-card {
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  padding: 25px;
  transition: all 0.3s;
  position: relative;
}

.contact-card.unread {
  border-left: 5px solid #f5576c;
  background: #fff9fa;
}

.contact-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.contact-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 15px;
  gap: 20px;
}

.contact-info h3 {
  margin: 0 0 5px 0;
  color: #2c3e50;
  font-size: 20px;
}

.contact-email {
  color: #667eea;
  text-decoration: none;
  font-size: 14px;
}

.contact-email:hover {
  text-decoration: underline;
}

.contact-phone {
  color: #666;
  font-size: 14px;
  margin-top: 3px;
}

.contact-meta {
  text-align: right;
  font-size: 13px;
  color: #999;
}

.contact-status {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 5px;
}

.contact-status.new {
  background: #ffe0e6;
  color: #d63031;
}

.contact-status.read {
  background: #d5f4e6;
  color: #27ae60;
}

.contact-message {
  margin: 15px 0;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 6px;
  line-height: 1.6;
  color: #333;
  white-space: pre-wrap;
}

.contact-actions {
  display: flex;
  gap: 10px;
  margin-top: 15px;
  flex-wrap: wrap;
}

.action-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.3s;
  font-weight: 500;
}

.action-btn.primary {
  background: #667eea;
  color: white;
}

.action-btn.primary:hover {
  background: #5568d3;
}

.action-btn.secondary {
  background: #e0e0e0;
  color: #333;
}

.action-btn.secondary:hover {
  background: #d0d0d0;
}

.action-btn.danger {
  background: #ff4757;
  color: white;
}

.action-btn.danger:hover {
  background: #e84142;
}

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

.empty-state svg {
  width: 80px;
  height: 80px;
  margin-bottom: 20px;
  opacity: 0.3;
}

.empty-state h3 {
  margin-bottom: 10px;
}

.loading-spinner {
  border: 3px solid #f3f3f3;
  border-top: 3px solid #667eea;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 0 auto 15px;
}

/* ==========================================
   Analytics Dashboard Content
   ========================================== */
.analytics-dashboard-content {
  padding: 0;
}

.analytics-dashboard-content .dashboard-header {
  margin: 0 0 20px 0;
}

/* Override some analytics styles for SPA integration */
#analyticsView {
  padding: 2rem;
}

#analyticsView .dashboard-header {
  border-radius: 12px;
}

/* ==========================================
   Streaming & Typing Indicators
   ========================================== */

/* Typing Indicator Animation */
.typing-indicator {
  opacity: 1;
  animation: fadeIn 0.3s ease-in;
}

.typing-dots {
  display: flex;
  gap: 6px;
  padding: 10px;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  background: #666;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {

  0%,
  60%,
  100% {
    transform: translateY(0);
  }

  30% {
    transform: translateY(-10px);
  }
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Streaming text cursor effect */
.message-content.streaming::after {
  content: '▋';
  animation: blink 1s infinite;
  margin-left: 2px;
}

@keyframes blink {

  0%,
  50% {
    opacity: 1;
  }

  51%,
  100% {
    opacity: 0;
  }
}

/* Smooth message appearance */
.message {
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}