/**
 * SSSSP Mandal - Admin Dashboard Stylesheet
 * Modern, accessible, responsive admin panel
 */

:root {
  --admin-primary: #1e3a8a;
  --admin-primary-hover: #1e40af;
  --admin-accent: #0284c7;
  --admin-bg: #f8fafc;
  --admin-surface: #ffffff;
  --admin-sidebar-bg: #0f172a;
  --admin-sidebar-text: #94a3b8;
  --admin-sidebar-active: #38bdf8;
  --admin-border: #e2e8f0;
  --admin-text-main: #0f172a;
  --admin-text-muted: #64748b;
  --admin-success: #16a34a;
  --admin-danger: #dc2626;
  --admin-warning: #d97706;
  --admin-radius: 8px;
  --admin-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --admin-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body.admin-body {
  font-family: var(--font-family);
  background-color: var(--admin-bg);
  color: var(--admin-text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ========================================================================== */
/* LOGIN SCREEN                                                               */
/* ========================================================================== */
.admin-login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--admin-surface);
  border-radius: 12px;
  padding: 36px 32px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

.login-header {
  text-align: center;
  margin-bottom: 24px;
}

.login-logo {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #38bdf8;
  margin-bottom: 12px;
}

.login-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--admin-text-main);
  margin-bottom: 4px;
}

.login-header p {
  font-size: 13px;
  color: var(--admin-text-muted);
}

.login-form .form-group {
  margin-bottom: 18px;
}

.login-form label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
}

.login-form input[type="email"],
.login-form input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  font-size: 14px;
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  background-color: #f8fafc;
  outline: none;
  transition: all 0.2s ease;
}

.login-form input:focus {
  border-color: var(--admin-accent);
  background-color: #fff;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.password-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-input-wrapper input {
  padding-right: 42px;
}

.toggle-password {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--admin-text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 14px;
}

.login-footer {
  margin-top: 24px;
  text-align: center;
  border-top: 1px solid var(--admin-border);
  padding-top: 18px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--admin-accent);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

.back-link:hover {
  color: var(--admin-primary);
  text-decoration: underline;
}

.config-status-pill {
  display: inline-block;
  margin-top: 12px;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 20px;
  background: #f1f5f9;
  color: #64748b;
  font-weight: 500;
}

/* ========================================================================== */
/* DASHBOARD LAYOUT                                                           */
/* ========================================================================== */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.admin-sidebar {
  width: 260px;
  background-color: var(--admin-sidebar-bg);
  color: var(--admin-sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.3s ease;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand img {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
}

.brand-text h3 {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
}

.brand-text span {
  font-size: 11px;
  color: #38bdf8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-nav {
  flex: 1;
  padding: 20px 12px;
  overflow-y: auto;
}

.sidebar-nav ul {
  list-style: none;
}

.sidebar-nav li {
  margin-bottom: 4px;
}

.nav-tab {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: none;
  border: none;
  border-radius: var(--admin-radius);
  color: var(--admin-sidebar-text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
}

.nav-tab i {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.nav-tab:hover {
  background-color: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.nav-tab.active {
  background-color: rgba(56, 189, 248, 0.12);
  color: var(--admin-sidebar-active);
  font-weight: 600;
}

.nav-tab .badge {
  margin-left: auto;
  background-color: #ef4444;
  color: #ffffff;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 700;
}

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

.admin-user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #94a3b8;
  margin-bottom: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-user-info i {
  color: #38bdf8;
}

.btn-logout {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 13px;
  background-color: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--admin-radius);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-logout:hover {
  background-color: #dc2626;
  color: #ffffff;
}

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

.admin-topbar {
  height: 64px;
  background-color: var(--admin-surface);
  border-bottom: 1px solid var(--admin-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-left h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--admin-text-main);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.admin-tab-content {
  display: none;
}

.admin-tab-content.active {
  display: block;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--admin-radius);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

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

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

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

.btn-outline:hover {
  background-color: #f1f5f9;
}

.btn-outline-sm {
  background-color: transparent;
  border: 1px solid var(--admin-border);
  color: var(--admin-text-main);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-outline-sm:hover {
  background-color: #f1f5f9;
  border-color: #cbd5e1;
}

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

.btn-danger:hover {
  background-color: #b91c1c;
}

.btn-icon {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--admin-text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
}

.btn-icon:hover {
  background-color: #f1f5f9;
  color: var(--admin-text-main);
}

.btn-block {
  width: 100%;
}

/* Stat Cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.stat-card {
  background-color: var(--admin-surface);
  border-radius: var(--admin-radius);
  padding: 20px;
  border: 1px solid var(--admin-border);
  box-shadow: var(--admin-shadow);
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.icon-blue { background-color: #e0f2fe; color: #0284c7; }
.icon-purple { background-color: #f3e8ff; color: #9333ea; }
.icon-green { background-color: #dcfce7; color: #16a34a; }
.icon-amber { background-color: #fef3c7; color: #d97706; }
.icon-red { background-color: #fee2e2; color: #dc2626; }

.stat-info .stat-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--admin-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-info .stat-val {
  font-size: 24px;
  font-weight: 700;
  color: var(--admin-text-main);
  margin-top: 4px;
}

/* Dashboard Columns */
.dashboard-columns {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.flex-1 {
  flex: 1;
  min-width: 320px;
}

.card {
  background-color: var(--admin-surface);
  border-radius: var(--admin-radius);
  border: 1px solid var(--admin-border);
  box-shadow: var(--admin-shadow);
  overflow: hidden;
}

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

.card-header h3 {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--admin-text-main);
}

.card-body {
  padding: 20px;
}

.action-buttons-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 18px 12px;
  background-color: #f8fafc;
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--admin-text-main);
  font-size: 13px;
  font-weight: 600;
}

.action-btn i {
  font-size: 22px;
  color: var(--admin-primary);
}

.action-btn:hover {
  background-color: #e0f2fe;
  border-color: #38bdf8;
  transform: translateY(-2px);
}

/* Section Toolbar */
.section-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box i {
  position: absolute;
  left: 12px;
  color: var(--admin-text-muted);
  font-size: 14px;
}

.search-box input {
  padding: 8px 14px 8px 36px;
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  font-size: 13px;
  min-width: 240px;
  outline: none;
}

.search-box input:focus {
  border-color: var(--admin-accent);
}

.select-control {
  padding: 8px 12px;
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  font-size: 13px;
  background-color: #fff;
  outline: none;
  cursor: pointer;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.data-table th {
  background-color: #f8fafc;
  padding: 12px 16px;
  font-weight: 600;
  color: #475569;
  border-bottom: 1px solid var(--admin-border);
  white-space: nowrap;
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--admin-border);
  vertical-align: middle;
}

.data-table tr:hover {
  background-color: #f8fafc;
}

/* Status Badges */
.badge-status {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-new { background-color: #fee2e2; color: #dc2626; }
.badge-in_progress { background-color: #fef3c7; color: #b45309; }
.badge-resolved { background-color: #dcfce7; color: #15803d; }
.badge-published { background-color: #dcfce7; color: #15803d; }
.badge-draft { background-color: #f1f5f9; color: #64748b; }

/* Admin Media Grid */
.admin-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.admin-media-card {
  background-color: var(--admin-surface);
  border-radius: var(--admin-radius);
  border: 1px solid var(--admin-border);
  overflow: hidden;
  box-shadow: var(--admin-shadow);
  display: flex;
  flex-direction: column;
}

.media-card-preview {
  position: relative;
  height: 160px;
  background-color: #0f172a;
}

.media-card-preview img,
.media-card-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-type-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.media-card-content {
  padding: 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.media-card-content h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--admin-text-main);
}

.media-card-content p {
  font-size: 12px;
  color: var(--admin-text-muted);
  margin-bottom: 8px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.media-card-meta {
  font-size: 11px;
  color: #64748b;
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid #f1f5f9;
}

.media-card-actions {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  background-color: #f8fafc;
  border-top: 1px solid var(--admin-border);
}

.media-card-actions button {
  flex: 1;
  padding: 6px;
  font-size: 12px;
  border-radius: 4px;
  border: 1px solid var(--admin-border);
  background-color: #fff;
  cursor: pointer;
  transition: all 0.2s;
}

.media-card-actions button:hover {
  background-color: #e2e8f0;
}

.media-card-actions button.btn-card-delete {
  color: #dc2626;
  border-color: #fecaca;
}

.media-card-actions button.btn-card-delete:hover {
  background-color: #fee2e2;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-card {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  background-color: var(--admin-surface);
  border-radius: 12px;
  box-shadow: var(--admin-shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
}

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

.modal-form,
.modal-body {
  padding: 24px;
  overflow-y: auto;
}

.modal-form .form-group {
  margin-bottom: 16px;
}

.modal-form label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
}

.modal-form input[type="text"],
.modal-form input[type="date"],
.modal-form select,
.modal-form textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 13px;
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  background-color: #f8fafc;
  outline: none;
  font-family: inherit;
}

.modal-form input:focus,
.modal-form select:focus,
.modal-form textarea:focus {
  border-color: var(--admin-accent);
  background-color: #fff;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.form-hint {
  display: block;
  font-size: 11px;
  color: #64748b;
  margin-top: 4px;
}

.form-row {
  display: flex;
  gap: 14px;
}

.form-group-checkbox {
  margin: 16px 0;
}

.form-group-checkbox label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--admin-border);
  background-color: #f8fafc;
}

.media-upload-preview {
  margin-top: 10px;
  max-height: 180px;
  overflow: hidden;
  border-radius: var(--admin-radius);
  border: 1px dashed var(--admin-border);
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.media-upload-preview img,
.media-upload-preview video {
  max-width: 100%;
  max-height: 180px;
  object-fit: contain;
}

/* Status list in Settings */
.status-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.status-item {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
}

.status-label {
  font-weight: 500;
  color: #475569;
}

.status-value {
  font-weight: 600;
  color: var(--admin-text-main);
}

.font-mono {
  font-family: monospace;
  font-size: 12px;
}

.info-alert {
  background-color: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--admin-radius);
  padding: 16px;
  font-size: 13px;
}

.info-alert h4 {
  color: #1e40af;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.info-alert ol {
  padding-left: 20px;
  margin-top: 8px;
  color: #334155;
  line-height: 1.6;
}

.info-alert code {
  background-color: #dbeafe;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  color: #1e3a8a;
}

/* Alert Banners */
.alert-box {
  padding: 12px 14px;
  border-radius: var(--admin-radius);
  font-size: 13px;
  margin-bottom: 16px;
}

.alert-error {
  background-color: #fee2e2;
  border: 1px solid #fca5a5;
  color: #b91c1c;
}

.alert-success {
  background-color: #dcfce7;
  border: 1px solid #86efac;
  color: #15803d;
}

.admin-alert {
  padding: 12px 24px;
  background-color: #eff6ff;
  border-bottom: 1px solid #bfdbfe;
  color: #1e40af;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    transform: translateX(-100%);
  }

  .admin-sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.4);
  }

  .section-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-left,
  .toolbar-right {
    width: 100%;
  }

  .search-box input {
    width: 100%;
  }
}
