/* ============================================================
   DHEbook — Auth + Dashboard Styles
   ============================================================ */

body.auth-body {
  background: linear-gradient(135deg, #1A3C6E 0%, #24508a 100%);
  min-height: 100vh;
  padding: 40px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card {
  background: #fff;
  border-radius: 16px;
  padding: 42px 38px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  margin: 0 auto;
}
.auth-logo { text-align: center; margin-bottom: 18px; }
.auth-logo img { height: 54px; margin: 0 auto; }
.auth-card h1 { font-size: 24px; color: #1A3C6E; text-align: center; margin-bottom: 6px; }
.auth-sub { text-align: center; color: #888; font-size: 14px; margin-bottom: 26px; }

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 13px; font-weight: 600;
  color: #1A3C6E; margin-bottom: 6px;
}
.form-group input, .form-group select {
  width: 100%; padding: 12px 15px; border: 1px solid #dde5ef;
  border-radius: 10px; font-family: inherit; font-size: 14px;
  outline: none; transition: border 0.2s; box-sizing: border-box;
  background: #fff;
}
.form-group input:focus, .form-group select:focus { border-color: #1A3C6E; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .form-row-2 { grid-template-columns: 1fr; } }

.optin-row {
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 13px; color: #555; margin: 14px 0 20px;
  cursor: pointer; line-height: 1.5;
}
.optin-row input { margin-top: 2px; width: 16px; height: 16px; accent-color: #1A3C6E; }

.btn-auth-primary {
  width: 100%; padding: 14px; background: #1A3C6E; color: #fff;
  border: none; border-radius: 10px; font-size: 15px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: background 0.2s;
}
.btn-auth-primary:hover { background: #142e54; }

.auth-switch { text-align: center; margin-top: 22px; font-size: 14px; color: #666; }
.auth-switch a { color: #1A3C6E; font-weight: 600; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

.auth-error, .auth-success, .auth-info {
  padding: 12px 16px; border-radius: 10px; margin-bottom: 18px;
  font-size: 13px; line-height: 1.5;
}
.auth-error   { background: #fee; color: #c00; border-left: 3px solid #c00; }
.auth-error div + div { margin-top: 4px; }
.auth-success { background: #e7f9f0; color: #0c8055; border-left: 3px solid #10b981; }
.auth-info    { background: #fff4d6; color: #8a6d1a; border-left: 3px solid #F2A900; }

.auth-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; font-size: 13px; }
.remember { display: flex; gap: 6px; align-items: center; color: #666; cursor: pointer; }
.remember input { accent-color: #1A3C6E; }
.forgot-link { color: #1A3C6E; font-weight: 500; text-decoration: none; }
.forgot-link:hover { text-decoration: underline; }

/* ---------- DASHBOARD ---------- */
.dash-layout { display: flex; min-height: 100vh; background: #f3f5f9; }
body.auth-body { align-items: flex-start; padding: 0; background: #f3f5f9; }

.dash-sidebar {
  width: 240px; background: #0f2545; color: #c9d4e6;
  display: flex; flex-direction: column; padding: 22px 0;
  position: sticky; top: 0; height: 100vh;
}
.dash-brand { padding: 0 22px 20px; border-bottom: 1px solid rgba(255,255,255,0.08); margin-bottom: 16px; }
.dash-brand img { height: 38px; }
.dash-nav { display: flex; flex-direction: column; padding: 0 12px; flex: 1; }
.dash-nav a {
  display: block; padding: 11px 14px; border-radius: 8px;
  font-size: 14px; color: #c9d4e6; text-decoration: none;
  margin-bottom: 2px; transition: background 0.15s;
}
.dash-nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.dash-nav a.active { background: #F2A900; color: #fff; font-weight: 600; }
.dash-nav a.logout:hover { background: rgba(239,68,68,0.15); color: #ff8a8a; }
.dash-nav hr { border: none; border-top: 1px solid rgba(255,255,255,0.08); margin: 12px 0; }

.dash-main { flex: 1; padding: 30px 40px; }
@media (max-width: 768px) { .dash-main { padding: 20px; } }

.dash-topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 30px;
}
.dash-topbar h1 { font-size: 24px; color: #1A3C6E; font-weight: 600; }
.dash-avatar {
  width: 46px; height: 46px; border-radius: 50%; background: #F2A900;
  color: #fff; font-weight: 700; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  text-decoration: none;
}

.dash-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; margin-bottom: 26px; }
.dash-stat {
  background: #fff; border-radius: 12px; padding: 22px;
  display: flex; align-items: center; gap: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.dash-stat-icon { font-size: 32px; }
.dash-stat-value { font-size: 22px; font-weight: 700; color: #1A3C6E; line-height: 1.1; }
.dash-stat-label { font-size: 13px; color: #888; }

.dash-panel {
  background: #fff; border-radius: 12px; padding: 28px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04); margin-bottom: 22px;
}
.dash-panel h3 { font-size: 16px; color: #1A3C6E; margin-bottom: 18px; font-weight: 600; }

.dash-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.dash-action {
  display: block; background: #f7f9fc; padding: 16px 18px;
  border-radius: 10px; color: #1A3C6E; font-weight: 500;
  text-decoration: none; transition: background 0.2s;
}
.dash-action:hover { background: #eef3fa; }

.dash-empty { text-align: center; padding: 40px 20px; color: #888; }
.dash-empty a { margin-top: 16px; }

.dash-table { width: 100%; border-collapse: collapse; }
.dash-table th { text-align: left; padding: 12px; background: #f7f9fc; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: #1A3C6E; font-weight: 600; }
.dash-table td { padding: 14px 12px; border-bottom: 1px solid #eef2f7; font-size: 14px; }
.dash-table .badge { padding: 4px 11px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-green { background: #e7f9f0; color: #0c8055; }
.badge-orange { background: #fff4d6; color: #b8860b; }

.btn-sm { display: inline-block; padding: 8px 16px; font-size: 13px; border-radius: 6px; text-decoration: none; font-weight: 600; transition: background 0.2s; }
.btn-outline-dark { background: #f0f3f8; color: #1A3C6E; }
.btn-outline-dark:hover { background: #e2e8f1; }
.btn-buy { background: #1A3C6E; color: #fff; }
.btn-buy:hover { background: #142e54; }

/* Download cards */
.download-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.download-card {
  background: #fff; border-radius: 12px; overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.download-card.expired { opacity: 0.6; }
.download-cover {
  height: 160px; background: linear-gradient(135deg, #1A3C6E, #24508a);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; text-align: center; padding: 18px;
  font-size: 15px;
}
.download-cover img { width: 100%; height: 100%; object-fit: cover; }
.download-info { padding: 16px; }
.download-info h3 { font-size: 15px; color: #1A3C6E; margin-bottom: 8px; }
.dl-active { font-size: 12px; color: #0c8055; margin-bottom: 4px; }
.dl-expired { font-size: 12px; color: #c00; margin-bottom: 10px; }
.dl-meta { font-size: 12px; color: #888; margin-bottom: 12px; }

/* Mobile dashboard */
@media (max-width: 768px) {
  .dash-layout { flex-direction: column; }
  .dash-sidebar {
    width: 100%; height: auto; position: static;
    padding: 14px;
  }
  .dash-brand { padding: 0 8px 12px; }
  .dash-brand img { height: 32px; }
  .dash-nav { flex-direction: row; flex-wrap: wrap; padding: 0; gap: 6px; }
  .dash-nav a { padding: 8px 12px; font-size: 12px; margin: 0; }
  .dash-nav hr { display: none; }
}
/* ============================================================
   ✚ DASHBOARD + AVATAR — permanent fix
   Loaded via auth-header.php so it reaches every dashboard page.
   ============================================================ */

/* ---- Force the S badge / avatar into a proper circle ---- */
.dash-topbar {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 16px !important;
  flex-wrap: wrap;
  width: 100% !important;
}
.dash-topbar h1 {
  margin: 0 !important;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 26px;
  color: #0f2545;
  font-weight: 700;
}

.dash-avatar {
  width: 46px !important;
  height: 46px !important;
  min-width: 46px !important;
  min-height: 46px !important;
  max-width: 46px !important;
  max-height: 46px !important;
  border-radius: 50% !important;
  background: linear-gradient(135deg, #F2A900, #d99500) !important;
  color: #fff !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-weight: 700 !important;
  font-size: 18px !important;
  text-decoration: none !important;
  flex: 0 0 auto !important;
  overflow: hidden !important;
  padding: 0 !important;
  line-height: 1 !important;
  box-shadow: 0 4px 12px rgba(242,169,0,.35);
}
.dash-avatar img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  border-radius: 50% !important;
  display: block !important;
}
@media (max-width: 640px) {
  .dash-avatar {
    width: 40px !important; height: 40px !important;
    min-width: 40px !important; min-height: 40px !important;
    max-width: 40px !important; max-height: 40px !important;
    font-size: 15px !important;
  }
}

/* ---- Profile page: avatar uploader (circle preview) ---- */
.avatar-uploader {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.avatar-preview {
  width: 96px !important;
  height: 96px !important;
  min-width: 96px !important;
  min-height: 96px !important;
  max-width: 96px !important;
  max-height: 96px !important;
  border-radius: 50% !important;
  background: linear-gradient(135deg, #1A3C6E, #24508a);
  color: #fff;
  display: inline-flex !important;
  align-items: center; justify-content: center;
  font-size: 34px; font-weight: 700;
  overflow: hidden !important;
  flex: 0 0 auto !important;
  box-shadow: 0 6px 18px rgba(15,37,69,.15);
}
.avatar-preview img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  border-radius: 50% !important;
  display: block !important;
}
.avatar-uploader-info { flex: 1; min-width: 200px; }
.avatar-uploader-info p {
  margin: 0 0 10px;
  font-size: 13px;
  color: #6b7a90;
}
.btn-upload {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px;
  border-radius: 30px;
  background: #1A3C6E;
  color: #fff;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .2s;
}
.btn-upload:hover { background: #142e54; }

/* ---- Crop modal ---- */
.crop-modal {
  position: fixed; inset: 0;
  background: rgba(10, 20, 40, .75);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: cmFade .2s ease;
}
@keyframes cmFade { from { opacity: 0; } to { opacity: 1; } }
.crop-modal-inner {
  background: #fff;
  border-radius: 18px;
  padding: 22px;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
  text-align: center;
}
.crop-modal-inner h3 {
  margin: 0 0 4px;
  color: #0f2545;
  font-size: 18px;
}
.crop-hint {
  font-size: 12px;
  color: #8896ab;
  margin: 0 0 16px;
}
.crop-stage {
  position: relative;
  width: 360px;
  height: 360px;
  max-width: 100%;
  margin: 0 auto 16px;
  border-radius: 12px;
  overflow: hidden;
  background: #0f2545;
  cursor: grab;
}
.crop-stage:active { cursor: grabbing; }
.crop-stage canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}
.crop-overlay { position: absolute; inset: 0; pointer-events: none; }
.crop-ring {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 70%; height: 70%;
  border-radius: 50%;
  box-shadow: 0 0 0 9999px rgba(10, 20, 40, .55);
  border: 2px solid rgba(255,255,255,.8);
}
.crop-controls {
  margin: 8px 0 16px;
  display: flex; align-items: center; justify-content: center;
  gap: 12px;
  font-size: 13px; color: #4a5568;
}
.crop-controls input[type="range"] { width: 220px; accent-color: #1A3C6E; }
.crop-actions { display: flex; gap: 10px; justify-content: center; }
.crop-actions button {
  padding: 10px 24px;
  border-radius: 30px;
  font-size: 14px; font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: background .2s;
}
.btn-cancel { background: #eef2f8; color: #1A3C6E; }
.btn-cancel:hover { background: #dde5ef; }
.btn-save {
  background: linear-gradient(135deg, #F2A900, #d99500);
  color: #fff;
  box-shadow: 0 6px 16px rgba(242,169,0,.35);
}
.btn-save:hover { filter: brightness(1.05); }
.btn-save:disabled { opacity: .6; cursor: wait; }

@media (max-width: 500px) {
  .crop-stage { width: 100%; height: auto; aspect-ratio: 1/1; }
  .crop-controls input[type="range"] { width: 140px; }
}

/* ---- Dashboard full-width layout (do not remove) ---- */
.dash-layout {
  display: flex !important;
  align-items: stretch !important;
  width: 100% !important;
  max-width: 100% !important;
  min-height: calc(100vh - 60px);
  margin: 0 !important;
  padding: 0 !important;
  box-sizing: border-box;
}
.dash-sidebar {
  flex: 0 0 260px !important;
  width: 260px !important;
  max-width: 260px !important;
  box-sizing: border-box;
}
.dash-main {
  flex: 1 1 auto !important;
  width: auto !important;
  max-width: none !important;
  min-width: 0 !important;
  box-sizing: border-box;
  padding: 32px 40px !important;
  margin: 0 !important;
}
.dash-main > * { max-width: 100%; box-sizing: border-box; }
.dash-stats {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 16px !important;
  width: 100% !important;
}
.dash-stat { width: 100% !important; }
.dash-panel {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box;
}
.dash-actions {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)) !important;
  gap: 12px !important;
  width: 100% !important;
}
.download-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)) !important;
  gap: 16px !important;
  width: 100% !important;
}
.dash-table { width: 100% !important; }
.dash-panel .form-row-2 {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 16px !important;
}
@media (max-width: 900px) {
  .dash-layout { flex-direction: column !important; min-height: auto; }
  .dash-sidebar { flex: 1 1 auto !important; width: 100% !important; max-width: 100% !important; }
  .dash-main { padding: 22px 16px !important; }
  .dash-stats { grid-template-columns: 1fr !important; }
  .dash-panel .form-row-2 { grid-template-columns: 1fr !important; }
}
@media (max-width: 640px) {
  .dash-main { padding: 16px 12px !important; }
}