/* Admin Panel Responsive Styles */
:root {
  --admin-sidebar-width: 260px;
}

/* Base Admin Layout */
.admin-layout {
  display: grid;
  grid-template-columns: var(--admin-sidebar-width) 1fr;
  min-height: 100vh;
  background: var(--bg);
}

.admin-sidebar {
  background: var(--surface);
  border-right: 1px solid #2b3042;
  padding: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.admin-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid #2b3042;
  overflow: visible;
}

.admin-logo img {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.admin-logo span {
  font-weight: 700;
  font-size: 18px;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  white-space: nowrap;
  overflow: visible;
  flex-shrink: 0;
}

.admin-nav {
  list-style: none;
  padding: 0;
  margin: 0;
}

.admin-nav li {
  margin-bottom: 6px;
}

.admin-nav a {
  display: block;
  padding: 10px 14px;
  border-radius: 10px;
  color: #d8dbeb;
  transition: background .2s ease;
  font-size: 14px;
}

.admin-nav a:hover,
.admin-nav a.active {
  background: #1b2030;
}

.admin-nav a.active {
  color: #fff;
  background: linear-gradient(135deg, #8b5cf6, #06b6d4);
}

.admin-main {
  padding: 24px;
  overflow-x: auto;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid #2b3042;
  flex-wrap: wrap;
  gap: 16px;
}

.admin-header h1 {
  margin: 0;
  font-size: clamp(22px, 4vw, 28px);
}

.admin-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-user span {
  color: var(--muted);
  font-size: 14px;
}

/* Mobile menu toggle */
.admin-menu-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 1000;
  background: var(--surface);
  border: 1px solid #2b3042;
  border-radius: 10px;
  padding: 10px 14px;
  color: #e6e8ee;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  min-width: 90px;
  text-align: center;
  transition: opacity .3s ease, visibility .3s ease;
}

.admin-menu-toggle:hover {
  background: #1b2030;
  border-color: #3a3f55;
}

/* Hide toggle button when sidebar is open */
.admin-menu-toggle.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid #2b3042;
  border-radius: 14px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.stat-card h3 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-card .value {
  font-size: clamp(28px, 5vw, 36px);
  font-weight: 700;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Quick Actions */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.action-btn {
  display: block;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid #2b3042;
  border-radius: 12px;
  color: #d8dbeb;
  text-align: center;
  transition: transform .2s ease, border-color .2s ease;
}

.action-btn:hover {
  transform: translateY(-2px);
  border-color: #3a3f55;
}

/* Tables */
.page-table,
.file-table,
.message-table {
  width: 100%;
  background: var(--surface);
  border: 1px solid #2b3042;
  border-radius: 14px;
  overflow: hidden;
}

.page-table th,
.file-table th,
.message-table th {
  background: #1a1f2e;
  padding: 14px 16px;
  text-align: left;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  border-bottom: 1px solid #2b3042;
}

.page-table td,
.file-table td,
.message-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #2b3042;
  color: #d7dbed;
}

.page-table tr:last-child td,
.file-table tr:last-child td,
.message-table tr:last-child td {
  border-bottom: none;
}

.page-table tr:hover,
.file-table tr:hover,
.message-table tr:hover {
  background: #1a1f2e;
}

/* Message Cards */
.message-list {
  display: grid;
  gap: 16px;
}

.message-card {
  background: var(--surface);
  border: 1px solid #2b3042;
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 12px;
}

.message-meta {
  font-size: 13px;
  color: var(--muted);
}

.message-body {
  color: #d7dbed;
  line-height: 1.6;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #2b3042;
  word-wrap: break-word;
}

/* Status Badges */
.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.status-active {
  background: #064e3b;
  color: #c7f9cc;
}

.status-draft {
  background: #3f1d1d;
  color: #fecaca;
}

.linklike {
  background: transparent;
  border: none;
  color: #8b5cf6;
  cursor: pointer;
  font-size: 13px;
  padding: 0;
}

.linklike:hover {
  text-decoration: underline;
}

/* Responsive Tablet (iPad, smaller laptops) */
@media (max-width: 1024px) {
  :root {
    --admin-sidebar-width: 220px;
  }
  
  .admin-sidebar {
    padding: 20px;
  }
  
  .admin-main {
    padding: 20px;
  }
  
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
  }
  
  .stat-card {
    padding: 18px;
  }
  
  .quick-actions {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }
}

/* Responsive Mobile */
@media (max-width: 768px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }
  
  .admin-sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    width: 280px;
    max-width: 85vw;
    height: 100vh;
    z-index: 999;
    transition: left .3s ease;
    box-shadow: 0 0 20px rgba(0,0,0,.5);
    overflow-y: auto;
    padding: 24px;
    background: var(--surface);
    border-right: 1px solid #2b3042;
  }
  
  .admin-sidebar.open {
    left: 0;
  }
  
  /* Ensure logo is fully visible and not cut off */
  .admin-logo {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid #2b3042;
    width: 100%;
    overflow: visible;
  }
  
  /* Hide Admin text by default on mobile, show when sidebar is open */
  .admin-logo span {
    display: none !important;
  }
  
  .admin-sidebar.open .admin-logo span {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    white-space: nowrap;
    overflow: visible;
  }
  
  .admin-menu-toggle {
    display: block;
  }
  
  .admin-main {
    padding: 70px 16px 16px;
  }
  
  .admin-header {
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 24px;
  }
  
  .admin-header h1 {
    font-size: 24px;
  }
  
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
  }
  
  .stat-card {
    padding: 16px;
  }
  
  .stat-card .value {
    font-size: 28px;
  }
  
  .quick-actions {
    grid-template-columns: 1fr;
  }
  
  /* Make tables scrollable on mobile */
  .page-table,
  .file-table,
  .message-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
  
  .page-table th,
  .file-table th,
  .message-table th,
  .page-table td,
  .file-table td,
  .message-table td {
    padding: 12px;
    font-size: 13px;
  }
  
  /* Hide less important columns on mobile */
  .hide-mobile {
    display: none;
  }
}

/* Small mobile */
@media (max-width: 480px) {
  .admin-main {
    padding: 70px 12px 12px;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .message-card {
    padding: 16px;
  }
  
  .stat-card h3 {
    font-size: 12px;
  }
}

/* Overlay for mobile menu */
.admin-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(2px);
  z-index: 998;
  opacity: 0;
  transition: opacity .3s ease;
}

.admin-overlay.active {
  display: block;
  opacity: 1;
}

/* Print styles */
@media print {
  .admin-sidebar,
  .admin-menu-toggle,
  .admin-header .btn {
    display: none;
  }
  
  .admin-layout {
    grid-template-columns: 1fr;
  }
  
  .admin-main {
    padding: 0;
  }
}
