/* ==========================================================================
   Custom Login Shortcode v3
   Renders inside theme's header/footer via [csl_login_form]

   Strategy: Use JS to position wrapper as fixed-width overlay inside <main>,
   bypassing all nested theme containers. CSS provides fallback that adapts
   to any container width.
   ========================================================================== */

/* ==========================================================================
   BODY - Login Card
   ========================================================================== */

/* Remove white gaps from theme wrapper elements (The7 theme) */
body:has(.csl-login-wrapper) #main,
body:has(.csl-login-wrapper) .wf-wrap,
body:has(.csl-login-wrapper) .wf-container-main,
body:has(.csl-login-wrapper) #content,
body:has(.csl-login-wrapper) #content > * {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}

/* Hide page title if theme generates one */
body:has(.csl-login-wrapper) h1.entry-title {
  display: none !important;
}

.csl-login-wrapper {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 60px 20px !important;
  box-sizing: border-box !important;
  /* JS will set width/position to break out of container */
}

/* When JS has applied the breakout */
.csl-login-wrapper.csl-breakout {
  width: 100% !important;
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

.csl-login-card {
  display: flex;
  width: 100%;
  max-width: 860px;
  min-height: 480px;
  background: #ffffff;
  overflow: hidden;
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.05),
    0 10px 15px -3px rgba(0, 0, 0, 0.08);
}

/* --- Left: Image Panel --- */
.csl-image-panel {
  position: relative;
  width: 45%;
  min-height: 480px;
  overflow: hidden;
  flex-shrink: 0;
  background: #8a9a6a;
}

.csl-bg-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  position: absolute;
  inset: 0;
}

.csl-image-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
}

.csl-logo-overlay {
  width: 140px;
  height: 140px;
  object-fit: contain;
  opacity: 0.85;
  filter: brightness(1.1);
}

/* --- Right: Form Panel --- */
.csl-form-wrapper {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.csl-border-wrapper {
  display: flex;
  flex-direction: row;
}

.csl-border-1 {
  width: 70%;
  height: 8px;
  background-color: #9a9e5e;
}

.csl-border-2 {
  width: 30%;
  height: 8px;
  background-color: #c9cba7;
}

.csl-form-panel {
  flex: 1;
  min-width: 0;
  padding: 48px 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.csl-form-title {
  font-size: 28px !important;
  font-weight: 600 !important;
  color: #1a1a1a;
  margin: 0 0 28px 0 !important;
  padding: 0 !important;
  font-family: "Sarabun", sans-serif !important;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

/* --- Notices (error / success) --- */
.csl-notice {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-family: "Sarabun", sans-serif;
  margin-bottom: 20px;
}

.csl-notice--error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.csl-notice--success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

/* --- Form Fields --- */
.csl-login-form {
  margin: 0;
  padding: 0;
}

.csl-field {
  margin-bottom: 20px;
}

.csl-field label {
  font-size: 15px;
  font-weight: 500;
  color: #374151;
  font-family: "Sarabun", sans-serif;
  margin-bottom: 6px;
  display: block;
}

.csl-field input[type="text"],
.csl-field input[type="email"],
.csl-field input[type="password"] {
  width: 100% !important;
  height: 48px !important;
  padding: 0 16px !important;
  font-size: 15px !important;
  font-family: "Sarabun", sans-serif !important;
  color: #1a1a1a !important;
  background: #ffffff !important;
  border: 1.5px solid #d1d5db !important;
  border-radius: 10px !important;
  box-shadow: none !important;
  outline: none !important;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
  box-sizing: border-box !important;
}

.csl-field input[type="text"]:focus,
.csl-field input[type="password"]:focus {
  border-color: #7c8c3c !important;
  box-shadow: 0 0 0 3px rgba(124, 140, 60, 0.12) !important;
}

.csl-field input::placeholder {
  color: #9ca3af;
  font-family: "Sarabun", sans-serif;
}

/* --- Password Input Wrapper --- */
.csl-input-wrapper {
  position: relative;
}

.csl-input-wrapper input {
  padding-right: 48px !important;
}

.csl-toggle-password {
  margin-top: -5px;
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: #9ca3af;
  padding: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
}

.csl-toggle-password:hover {
  color: #6b7280;
}

/* --- Forgot Password --- */
.csl-forgot-password {
  text-align: right;
  margin: 4px 0 24px;
}

.csl-forgot-password a {
  font-size: 14px;
  font-weight: 500;
  color: #7c8c3c;
  text-decoration: none;
  font-family: "Sarabun", sans-serif;
  transition: color 0.2s ease;
}

.csl-forgot-password a:hover {
  color: #5c6a2a;
  text-decoration: underline;
}

/* --- Submit Button --- */
.csl-submit-btn {
  width: 100%;
  height: 50px;
  background: #7c8c3c;
  border: none;
  border-radius: 10px;
  color: #ffffff;
  font-size: 16px;
  font-weight: 600;
  font-family: "Sarabun", sans-serif;
  cursor: pointer;
  transition:
    background 0.2s ease,
    transform 0.1s ease;
  letter-spacing: 0.02em;
}

.csl-submit-btn:hover {
  background: #6b7a30;
}

.csl-submit-btn:active {
  transform: scale(0.985);
}

/* --- Divider --- */
.csl-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 24px 0;
}

.csl-divider::before,
.csl-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #e5e7eb;
}

.csl-divider span {
  font-size: 14px;
  color: #9ca3af;
  font-family: "Sarabun", sans-serif;
  white-space: nowrap;
}

/* --- Register Button --- */
.csl-register-btn {
  display: block;
  width: 100%;
  height: 50px;
  line-height: 48px;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  font-family: "Sarabun", sans-serif;
  color: #374151;
  background: #ffffff;
  border: 1.5px solid #d1d5db;
  border-radius: 10px;
  text-decoration: none;
  transition:
    background 0.2s ease,
    border-color 0.2s ease;
  box-sizing: border-box;
}

.csl-register-btn:hover {
  background: #f9fafb;
  border-color: #9ca3af;
  color: #1a1a1a;
  text-decoration: none;
}

/* ==========================================================================
   Responsive — stack when card can't fit 2 columns
   ========================================================================== */

/* Container query fallback: if card is narrow, stack */
@container (max-width: 600px) {
  .csl-login-card {
    flex-direction: column;
  }
  .csl-image-panel {
    width: 100%;
    min-height: 200px;
    max-height: 220px;
  }
}

@media (max-width: 860px) {
  .csl-login-card {
    flex-direction: column;
    max-width: 480px;
    min-height: auto;
  }

  .csl-image-panel {
    width: 100%;
    min-height: 200px;
    max-height: 220px;
  }

  .csl-logo-overlay {
    width: 80px;
    height: 80px;
  }

  .csl-form-panel {
    padding: 32px 24px;
  }

  .csl-form-title {
    font-size: 24px !important;
    margin-bottom: 24px !important;
  }
}

@media (max-width: 480px) {
  .csl-login-wrapper {
    padding: 24px 12px !important;
  }

  .csl-form-panel {
    padding: 24px 20px;
  }

  .csl-image-panel {
    min-height: 160px;
    max-height: 180px;
  }
}

/* ==========================================================================
   ALERT MODAL
   ========================================================================== */

.csl-alert-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: cslOverlayIn 0.2s ease;
}
.csl-alert-overlay--out {
  animation: cslOverlayOut 0.2s ease forwards;
}
@keyframes cslOverlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes cslOverlayOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

.csl-alert-modal {
  background: #fff;
  border-radius: 20px;
  padding: 40px 32px 32px;
  max-width: 380px;
  width: calc(100vw - 40px);
  text-align: center;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
  animation: cslModalIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.csl-alert-overlay--out .csl-alert-modal {
  animation: cslModalOut 0.2s ease forwards;
}
@keyframes cslModalIn {
  from { transform: translateY(24px) scale(0.95); opacity: 0; }
  to   { transform: translateY(0)     scale(1);    opacity: 1; }
}
@keyframes cslModalOut {
  from { transform: translateY(0)    scale(1);    opacity: 1; }
  to   { transform: translateY(12px) scale(0.96); opacity: 0; }
}

.csl-alert-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #fee2e2;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  color: #ef4444;
}

.csl-alert-title {
  font-size: 18px !important;
  font-weight: 700 !important;
  color: #1f2937 !important;
  margin: 0 0 8px !important;
  line-height: 1.4 !important;
}

.csl-alert-message {
  font-size: 14px !important;
  color: #6b7280 !important;
  margin: 0 0 28px !important;
  line-height: 1.6 !important;
}

.csl-alert-btn {
  display: block;
  width: 100%;
  background: #8a8f3c;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 13px 32px;
  font-size: 15px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  letter-spacing: 0.3px;
}
.csl-alert-btn:hover {
  background: #6f7330;
  transform: translateY(-1px);
}
.csl-alert-btn:active {
  transform: translateY(0);
}
