/* Admin Dashboard Styles - Scoped to .admin-layout */
.admin-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
  background-color: #f1f5f9; /* Light gray background */
  color: #1e293b; /* Dark text */
  font-family: 'Plus Jakarta Sans', sans-serif;
  overflow: hidden;
}

/* Sidebar */
.admin-sidebar {
  width: 260px;
  flex: 0 0 260px;
  background-color: #0b1120;
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 15px rgba(0, 0, 0, 0.05);
  z-index: 10;
}

.admin-sidebar-header {
  padding: 1.5rem;
  font-size: 1.4rem;
  font-weight: 800;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  gap: 0.8rem;
  color: #ffffff;
}

.admin-sidebar-header span {
  color: #38bdf8;
}

.admin-sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 1rem 0;
  gap: 0.3rem;
  flex: 1;
}

.admin-nav-item {
  padding: 0.9rem 1.5rem;
  margin: 0 1rem;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  color: #94a3b8;
  font-weight: 600;
  transition: all 0.2s ease;
}

.admin-nav-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: #f8fafc;
}

.admin-nav-item.active {
  background-color: #38bdf8;
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(56, 189, 248, 0.3);
}

.admin-nav-icon {
  font-size: 1.2rem;
}

/* Main Content Area */
.admin-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Topbar */
.admin-topbar {
  position: static;
  top: auto;
  left: auto;
  right: auto;
  height: 70px;
  flex: 0 0 70px;
  box-sizing: border-box;
  background-color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
  z-index: 5;
}

.admin-topbar-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f172a;
}

.admin-topbar-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.admin-btn-save {
  background-color: #38bdf8;
  color: white;
  border: none;
  padding: 0.6rem 1.5rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background-color 0.2s;
}

.admin-btn-save:hover {
  background-color: #0284c7;
}

.admin-btn-save:disabled {
  background-color: #cbd5e1;
  cursor: not-allowed;
}

/* Content View */
.admin-content {
  flex: 1;
  min-height: 0;
  padding: 2rem;
  overflow-y: auto;
}

.admin-section-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 1.5rem;
  margin-top: 0;
}

.admin-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  margin-bottom: 2rem;
}

.admin-form-group {
  margin-bottom: 1.5rem;
}

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

.admin-form-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 0.5rem;
}

.admin-form-input, .admin-form-textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background-color: #f8fafc;
  color: #0f172a;
  font-family: inherit;
  font-size: 0.95rem;
  transition: all 0.2s;
  box-sizing: border-box;
}

.admin-form-input:focus, .admin-form-textarea:focus {
  outline: none;
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
  background-color: #ffffff;
}

.admin-image-preview {
  margin-bottom: 1rem;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  padding: 0.5rem;
  background: #f8fafc;
  display: inline-block;
}

.admin-image-preview img {
  display: block;
  max-height: 150px;
  border-radius: 4px;
}

/* Inbox Layout */
.inbox-layout {
  display: flex;
  /* .admin-content is already the area below the topbar. */
  min-height: 100%;
  height: 100%;
  width: 100%;
  /* Keep the first list item clear of the top bar in the dashboard layout. */
  padding-top: 2rem;
  box-sizing: border-box;
  /* Do not use a negative margin here: it moves the first message beneath
     the fixed top bar, making it look as if only the next message exists. */
  margin: 0;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
}

.inbox-list-container {
  flex: 0 0 350px;
  min-width: 350px;
  border-right: 1px solid #e2e8f0;
  overflow-y: auto;
  background: #f8fafc;
}

.inbox-list {
  display: flex;
  flex-direction: column;
}

.inbox-item {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #e2e8f0;
  cursor: pointer;
  transition: background-color 0.2s;
}

.inbox-item:hover {
  background-color: #f1f5f9;
}

.inbox-item.selected {
  background-color: #e0f2fe;
  border-left: 4px solid #38bdf8;
  padding-left: calc(1.5rem - 4px);
}

.inbox-item-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.5rem;
}

.inbox-item-name {
  font-weight: 700;
  color: #0f172a;
  font-size: 1rem;
}

.inbox-item-date {
  font-size: 0.75rem;
  color: #64748b;
}

.inbox-item-snippet {
  font-size: 0.85rem;
  color: #475569;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inbox-viewer {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
  background: #ffffff;
}

.inbox-empty-state {
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 1.2rem;
  flex-direction: column;
  gap: 1rem;
}

.inbox-viewer-header {
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 1.5rem;
  margin-bottom: 1.5rem;
}

.inbox-viewer-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0.5rem;
  margin-top: 0;
}

.inbox-viewer-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.inbox-viewer-sender {
  font-size: 0.95rem;
  color: #475569;
}

.inbox-viewer-email {
  color: #38bdf8;
  text-decoration: none;
}

.inbox-viewer-date {
  font-size: 0.85rem;
  color: #64748b;
}

.inbox-viewer-body {
  font-size: 1rem;
  line-height: 1.6;
  color: #1e293b;
  white-space: pre-wrap;
}

.inbox-actions {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e2e8f0;
}

/* Responsive Design (Mobile & Tablets) */
@media (max-width: 768px) {
  .admin-layout {
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
  }

  .admin-hamburger {
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    margin-right: 15px;
  }
  .admin-hamburger .bar {
    width: 25px;
    height: 3px;
    background-color: #0f172a;
    transition: 0.3s;
  }
  .admin-hamburger.active .bar:nth-child(1) { transform: translateY(8px) rotate(45deg); }
  .admin-hamburger.active .bar:nth-child(2) { opacity: 0; }
  .admin-hamburger.active .bar:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

  .admin-topbar {
    justify-content: flex-start;
    padding: 0 1rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  }

  .admin-topbar-title {
    font-size: 1.1rem;
    flex: 1;
  }

  .admin-sidebar {
    position: fixed;
    top: 70px; /* Below topbar */
    left: -100%;
    width: 260px;
    height: calc(100vh - 70px);
    transition: 0.3s ease-in-out;
    z-index: 1000;
  }

  .admin-sidebar.active {
    left: 0;
  }

  .admin-sidebar-nav {
    flex-direction: column;
    flex-wrap: nowrap;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem 0;
    margin-left: 0;
    align-items: stretch;
  }

  .admin-nav-item {
    margin: 0 1rem;
    padding: 0.9rem 1.5rem;
  }

  /* Show text again, since it's vertical now */
  .admin-nav-item span:not(.admin-nav-icon) {
    display: inline;
  }
  
  .admin-nav-item span[style*="background: #ef4444"] {
    display: inline-block !important; /* Keep notification badge */
    position: static;
    margin-left: auto !important;
  }
  .admin-nav-item {
    position: relative;
  }

  .admin-content {
    padding: 1rem;
  }

  .admin-card {
    padding: 1rem;
  }

  .inbox-layout {
    flex-direction: column;
    height: auto;
    margin: -1rem;
  }

  .inbox-list-container {
    width: 100%;
    height: 300px;
    border-right: none;
    border-bottom: 1px solid #e2e8f0;
  }

  .inbox-viewer {
    padding: 1rem;
    height: 500px;
  }

  .inbox-viewer-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

}

/* WYSIWYG EDITOR */
.wysiwyg-toolbar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  background: #f1f5f9;
  padding: 0.5rem;
  border-radius: 8px 8px 0 0;
  border: 1px solid #cbd5e1;
  border-bottom: none;
}

.wysiwyg-btn {
  padding: 0.25rem 0.75rem;
  background: white;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
}

.wysiwyg-btn:hover {
  background: #e2e8f0;
}

.wysiwyg-editor {
  min-height: 300px;
  border-radius: 0 0 8px 8px;
  background: white;
  padding: 1rem;
  border: 1px solid #cbd5e1;
  overflow-y: auto;
}

.wysiwyg-editor:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
