/* ============================================
   Atlas MedInnovation - Admin Panel Styles
   ============================================ */

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

:root {
  --color-bg: #f5f5f3;
  --color-surface: #ffffff;
  --color-text: #1a1a1a;
  --color-text-muted: #6b6b6b;
  --color-border: #e0e0dc;
  --color-primary: #0a0a0a;
  --color-accent: #0077b6;
  --color-accent-light: #e8f4f8;
  --color-danger: #dc3545;
  --color-danger-light: #fee;
  --color-success: #28a745;
  --color-success-light: #e8f5e9;
  --color-warning: #ffc107;
  --color-sidebar: #0a1929;
  --color-sidebar-hover: #1a2a3a;
  --color-sidebar-active: #0077b6;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.5;
}

/* --- Login --- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0a1929 0%, #0d2818 100%);
}

.login-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo img {
  height: 56px;
  width: auto;
  max-width: 260px;
  object-fit: contain;
  display: inline-block;
  border-radius: 4px;
}

.login-card h2 {
  font-size: 1.25rem;
  margin-bottom: 8px;
  text-align: center;
}

.login-card .subtitle {
  text-align: center;
  color: var(--color-text-muted);
  margin-bottom: 32px;
  font-size: 0.875rem;
}

.login-error {
  background: var(--color-danger-light);
  color: var(--color-danger);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  margin-bottom: 16px;
  display: none;
}

.login-error.show { display: block; }

/* --- Admin Layout --- */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 240px;
  background: var(--color-sidebar);
  color: rgba(255,255,255,0.7);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo img {
  height: 36px;
  width: auto;
  max-width: 180px;
  object-fit: contain;
  display: block;
  border-radius: 4px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: rgba(255,255,255,0.6);
  font-size: 0.875rem;
  font-weight: 400;
  transition: all 0.2s;
  cursor: pointer;
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
  background: var(--color-sidebar-hover);
  color: #fff;
}

.sidebar-nav a.active {
  background: var(--color-sidebar-hover);
  color: #fff;
  border-left-color: var(--color-accent);
}

.sidebar-nav a svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-nav .badge {
  margin-left: auto;
  background: var(--color-danger);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 100px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255,255,255,0.5);
  font-size: 0.8125rem;
  transition: color 0.2s;
}

.sidebar-footer a:hover { color: #fff; }

/* Main Content */
.admin-main {
  flex: 1;
  margin-left: 240px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.admin-header {
  background: #fff;
  border-bottom: 1px solid var(--color-border);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.admin-header h1 {
  font-size: 1.25rem;
  font-weight: 600;
}

.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.header-actions a {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  transition: color 0.2s;
}

.header-actions a:hover { color: var(--color-text); }

.admin-content {
  padding: 32px;
  flex: 1;
}

/* --- Dashboard Cards --- */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 32px;
}

.dash-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.dash-card-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.dash-card-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-text);
}

.dash-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.dash-card-icon svg { width: 20px; height: 20px; }

.dash-card-icon.blue { background: #e3f2fd; }
.dash-card-icon.blue svg { color: #1976d2; }
.dash-card-icon.green { background: #e8f5e9; }
.dash-card-icon.green svg { color: #388e3c; }
.dash-card-icon.orange { background: #fff3e0; }
.dash-card-icon.orange svg { color: #f57c00; }
.dash-card-icon.purple { background: #f3e5f5; }
.dash-card-icon.purple svg { color: #7b1fa2; }

/* --- Content Panels --- */
.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 24px;
  overflow: hidden;
}

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

.panel-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.panel-body {
  padding: 24px;
}

/* --- Forms --- */
.admin-form-group {
  margin-bottom: 20px;
}

.admin-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.admin-form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 6px;
}

.admin-form-input,
.admin-form-textarea,
.admin-form-select {
  width: 100%;
  padding: 10px 14px;
  font-family: var(--font);
  font-size: 0.875rem;
  color: var(--color-text);
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s;
}

.admin-form-input:focus,
.admin-form-textarea:focus,
.admin-form-select:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-light);
}

.admin-form-textarea {
  min-height: 100px;
  resize: vertical;
}

.admin-form-help {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* --- Buttons --- */
.admin-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.admin-btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.admin-btn-primary:hover { background: #333; }

.admin-btn-outline {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.admin-btn-outline:hover { border-color: var(--color-text); }

.admin-btn-danger {
  background: transparent;
  color: var(--color-danger);
  border: 1px solid var(--color-danger);
}

.admin-btn-danger:hover { background: var(--color-danger); color: #fff; }

.admin-btn-sm {
  padding: 6px 12px;
  font-size: 0.75rem;
}

.admin-btn svg { width: 16px; height: 16px; }

/* --- Tables --- */
.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}

.admin-table td {
  padding: 14px 16px;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}

.admin-table tr:last-child td { border-bottom: none; }

.admin-table tr:hover { background: var(--color-bg); }

.row-actions {
  display: flex;
  gap: 8px;
}

.row-actions button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--color-text-muted);
  transition: color 0.2s;
}

.row-actions button:hover { color: var(--color-text); }
.row-actions button.delete:hover { color: var(--color-danger); }

/* --- Messages --- */
.message-item {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 12px;
  transition: box-shadow 0.2s;
}

.message-item:hover { box-shadow: var(--shadow-md); }

.message-item.unread {
  border-left: 3px solid var(--color-accent);
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.message-name {
  font-weight: 600;
  font-size: 0.9375rem;
}

.message-date {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.message-meta {
  display: flex;
  gap: 16px;
  margin-bottom: 8px;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.message-meta span { display: flex; align-items: center; gap: 4px; }

.message-body {
  font-size: 0.875rem;
  color: var(--color-text);
  line-height: 1.6;
  margin-bottom: 12px;
}

.message-actions {
  display: flex;
  gap: 8px;
}

.unread-badge {
  display: inline-block;
  background: var(--color-accent);
  color: #fff;
  font-size: 0.625rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--color-text-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  opacity: 0.3;
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--color-primary);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 9999;
}

.toast.show { transform: translateY(0); opacity: 1; }

.toast.success { background: var(--color-success); }
.toast.error { background: var(--color-danger); }

/* --- Section Visibility --- */
.admin-section {
  display: none;
}

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

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.modal-overlay.show { display: flex; }

.modal {
  background: #fff;
  border-radius: var(--radius);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

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

.modal-header h3 { font-size: 1.125rem; font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-text-muted);
  line-height: 1;
}

.modal-body { padding: 24px; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* --- Responsive --- */
@media (max-width: 968px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open { transform: translateX(0); }

  .admin-main { margin-left: 0; }

  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .admin-form-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .admin-content { padding: 16px; }

  .admin-header { padding: 12px 16px; }
}

/* --- Gallery Manager --- */
.gallery-item {
  width: 220px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--color-surface);
  cursor: grab;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.gallery-item:hover {
  border-color: var(--color-accent);
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.gallery-item.dragging {
  opacity: 0.5;
}

.gallery-item.drag-over {
  border-color: var(--color-accent);
  border-style: dashed;
}

.gallery-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #f0f0f0;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-placeholder {
  color: var(--color-text-muted);
  font-size: 0.75rem;
}

.gallery-caption-input,
.gallery-url-input {
  width: 100%;
  font-size: 0.75rem !important;
  padding: 6px 8px !important;
  margin-bottom: 6px;
}

.gallery-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

.gallery-actions .admin-btn {
  padding: 4px 8px;
}

.gallery-actions .admin-btn.delete {
  color: var(--color-danger);
}

.gallery-actions .admin-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
