:root {
  --bg-body: #0f172a;
  --bg-sidebar: #1e293b;
  --bg-card: #1e293b;
  --bg-hover: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #8b5cf6;
  --primary-hover: #7c3aed;
  --border: #334155;
  --glass: rgba(30, 41, 59, 0.7);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { text-decoration: none; color: inherit; transition: 0.2s; }

/* Layout - Mapped to index.php classes */
.app-container {
  display: flex;
  flex: 1;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  height: 100vh; /* Full height for sidebar */
  overflow: hidden;
  position: relative;
}

.sidebar {
  width: 260px;
  padding: 24px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg-sidebar);
  height: 100%;
  overflow-y: auto;
  
  /* Mobile default: Fixed and hidden */
  position: fixed;
  top: 0;
  left: -270px;
  bottom: 0;
  z-index: 1000;
  transition: left 0.3s ease;
  box-shadow: 4px 0 24px rgba(0,0,0,0.5);
}

.sidebar.open { left: 0; }

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 900;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.open { display: block; }

@media(min-width: 768px) {
  .sidebar {
    position: static;
    display: flex;
    box-shadow: none;
    border-right: 1px solid var(--border);
  }
  .sidebar-overlay { display: none !important; }
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-body);
  height: 100%;
  overflow: hidden;
}

/* Top Bar (Shared/Legacy) */
.top-bar, .topbar {
  background: var(--glass);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  width: 100%;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 12px;
}

.mobile-menu-btn {
  background: none;
  border: none;
  color: var(--text-main);
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
  display: block;
}
@media(min-width: 768px) { .mobile-menu-btn { display: none; } }

.brand-logo { height: 32px; width: 32px; margin-right: 8px; }

.topnav { display: flex; gap: 4px; }
.topnav a {
  padding: 8px 16px;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
}
.topnav a:hover, .topnav a.active { color: var(--text-main); background: var(--bg-hover); }

.compose-link {
  background: var(--primary) !important;
  color: white !important;
  margin-left: 12px;
}
.compose-link:hover { background: var(--primary-hover) !important; }

.user-area { display: flex; align-items: center; gap: 12px; }
.user-name { font-weight: 500; font-size: 0.9rem; display: none; }
@media(min-width: 768px) { .user-name { display: block; } }

.logout {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.logout:hover { background: var(--bg-hover); color: var(--text-main); }

.guest-nav { display: flex; gap: 12px; align-items: center; }
.btn-register {
  background: var(--primary);
  padding: 8px 16px;
  border-radius: 6px;
  color: white;
}

.content-area {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

/* Sidebar Components */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text-main);
  margin-bottom: 24px;
}
.brand .logo {
  width: 32px;
  height: 32px;
  background: var(--primary);
  color: white;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.compose-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--primary);
  color: white;
  padding: 12px;
  border-radius: 8px;
  font-weight: 600;
  transition: 0.2s;
  margin-bottom: 24px;
}
.compose-btn:hover { background: var(--primary-hover); transform: translateY(-1px); }

.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a {
  padding: 10px 16px;
  border-radius: 8px;
  color: var(--text-muted);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar nav a:hover, .sidebar nav a.active {
  background: var(--bg-hover);
  color: var(--text-main);
}

/* Search Bar */
.search-bar {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 8px;
  width: 100%;
  max-width: 400px;
  color: var(--text-muted);
}
.search-bar input {
  background: transparent;
  border: none;
  color: var(--text-main);
  margin-left: 8px;
  flex: 1;
  outline: none;
  font-size: 0.95rem;
}

/* Email List */
.email-list { display: flex; flex-direction: column; gap: 12px; }

.email-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.email-item:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.avatar-small {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1rem;
  flex-shrink: 0;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 3rem; margin-bottom: 16px; opacity: 0.5; }

/* Forms & Cards (Shared with other pages) */
.auth, .compose, .message {
  display: flex;
  justify-content: center;
  padding: 40px 20px;
}

.card {
  width: 100%;
  max-width: 600px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.card .header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
}
.card .header div { font-size: 1.5rem; font-weight: 700; }
.card .header a { color: var(--primary); font-weight: 500; }

.card form { display: flex; flex-direction: column; gap: 16px; }
.card label { font-size: 0.9rem; font-weight: 500; color: var(--text-muted); margin-bottom: -8px; }

.card input, .card textarea {
  background: var(--bg-body);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 12px;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  transition: 0.2s;
}
.card input:focus, .card textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.card button {
  background: var(--primary);
  color: white;
  border: none;
  padding: 12px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
}
.card button:hover { background: var(--primary-hover); transform: translateY(-1px); }

.error { background: rgba(239, 68, 68, 0.1); color: #ef4444; padding: 12px; border-radius: 8px; font-size: 0.9rem; }
.success { background: rgba(34, 197, 94, 0.1); color: #22c55e; padding: 12px; border-radius: 8px; font-size: 0.9rem; }

/* Message View */
.message .meta {
  background: var(--bg-body);
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 24px;
  color: var(--text-muted);
  font-size: 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.message .body { line-height: 1.6; font-size: 1.05rem; white-space: pre-wrap; }

/* Footer - kept minimal */
.footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  padding: 24px;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
}

/* Auth Split Layout */
.auth-split {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.auth-left {
  flex: 1;
  background-color: var(--primary);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: white;
  padding: 40px;
  position: relative;
  overflow: hidden;
}

.auth-left::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.6); /* Overlay */
  z-index: 1;
}

.auth-left-content {
  position: relative;
  z-index: 2;
  text-align: center;
  max-width: 400px;
}

.auth-left h1 {
  font-size: 3rem;
  font-weight: 800;
  margin-bottom: 20px;
  line-height: 1.1;
}

.auth-left p {
  font-size: 1.2rem;
  opacity: 0.9;
  line-height: 1.6;
}

.auth-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 40px;
  background: var(--bg-main);
  position: relative;
  z-index: 10;
}

.auth-card {
  width: 100%;
  max-width: 400px;
}

@media (max-width: 900px) {
  .auth-left { display: none; }
}

/* Slider Animation */
@keyframes slideShow {
  0% { opacity: 0; transform: scale(1.1); }
  5% { opacity: 1; transform: scale(1); }
  33% { opacity: 1; transform: scale(1); }
  38% { opacity: 0; transform: scale(1.1); }
  100% { opacity: 0; }
}

.slider-bg {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background-size: cover;
  background-position: center;
  opacity: 0;
  animation: slideShow 15s infinite;
  z-index: 0;
}

.slider-bg:nth-child(1) { animation-delay: 0s; background-image: url('https://images.unsplash.com/photo-1518770660439-4636190af475?auto=format&fit=crop&w=1600&q=80'); }
.slider-bg:nth-child(2) { animation-delay: 5s; background-image: url('https://images.unsplash.com/photo-1451187580459-43490279c0fa?auto=format&fit=crop&w=1600&q=80'); }
.slider-bg:nth-child(3) { animation-delay: 10s; background-image: url('https://images.unsplash.com/photo-1519389950473-47ba0277781c?auto=format&fit=crop&w=1600&q=80'); }
