/* ===========================================
   MemberPress User Save Content - Main Styles
   =========================================== */

/* Theme tokens */
:root {
  --brand: #26A0DA;
  --brand-dark: #1984B7;
  --accent: #188ece;
  --text: #333;
  --muted: #666;
  --muted-2: #999;
  --border: #ddd;
  --border-light: #eee;
  --bg: #fff;
  --bg-soft: #f8f9fa;
}

/* ===========================================
   Save Button (shortcode in articles)
   =========================================== */
.mpusc-save-button {
  display: inline-flex !important;
  align-items: center !important;
  background-color: white !important;
  color: #188ece !important;
  border: 1px solid #188ece !important;
  border-radius: 4px !important;
  padding: 10px 16px !important;
  cursor: pointer !important;
  transition: all 0.3s ease !important;
  font-weight: 500 !important;
  box-shadow: 0 2px 5px rgba(24, 142, 206, 0.15) !important;
  font-size: 16px !important;
  line-height: 1.4 !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
}

/* Unsaved state: Blue filled icon */
.mpusc-save-button .mpusc-icon-bookmark {
  margin-right: 8px !important;
  flex-shrink: 0 !important;
  display: inline-block !important;
  width: 16px !important;
  height: 16px !important;
  color: #188ece !important;
  fill: #188ece !important;
  transition: all 0.3s ease !important;
}

/* Hover state: White icon and text on blue background */
.mpusc-save-button:hover {
  background-color: #188ece !important;
  color: white !important;
  box-shadow: 0 4px 8px rgba(24, 142, 206, 0.3) !important;
}

.mpusc-save-button:hover .mpusc-icon-bookmark {
  color: white !important;
  fill: white !important;
}

/* Active/press state */
.mpusc-save-button:active {
  transform: translateY(1px) !important;
  box-shadow: 0 1px 3px rgba(24, 142, 206, 0.2) !important;
}

/* Saved state: White filled icon on blue background */
.mpusc-save-button.saved {
  background-color: #188ece !important;
  color: white !important;
}

.mpusc-save-button.saved .mpusc-icon-bookmark {
  color: white !important;
  fill: white !important;
}

/* Saved hover state: Darker blue */
.mpusc-save-button.saved:hover {
  background-color: #1680b9 !important;
}

/* Loading state */
.mpusc-save-button.loading {
  pointer-events: none !important;
  opacity: 0.7 !important;
}

.mpusc-save-button:disabled {
  opacity: 0.6 !important;
  cursor: not-allowed !important;
}

@media (max-width: 959px) {
    .mpusc-save-button {
        margin-top: 30px;
    }
}

/* ===========================================
   Save Post Dialog
   =========================================== */
.save-post-dialog {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}

.save-dialog-content {
  background: white;
  width: 480px;
  max-width: 90%;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.save-dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-soft);
  flex-shrink: 0;
}

.save-dialog-header h3 {
  margin: 0;
  font-family: 'Poppins', sans-serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.close-save-dialog {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--muted-2);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.close-save-dialog:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.05);
}

.save-dialog-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.save-post-preview {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-light);
}

.post-thumbnail-preview {
  width: 80px;
  height: 80px;
  background-color: #f5f5f5;
  border-radius: 8px;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  border: 1px solid #e0e0e0;
}

.post-info-preview {
  flex-grow: 1;
  overflow: hidden;
}

.post-title-preview {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.save-options {
  margin-bottom: 20px;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 4px;
}

.save-options::-webkit-scrollbar {
  width: 6px;
}

.save-options::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.save-options::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

.save-options::-webkit-scrollbar-thumb:hover {
  background: #aaa;
}

.save-options p {
  margin-top: 0;
  margin-bottom: 16px;
  color: var(--text);
  font-weight: 500;
  font-size: 15px;
}

/* Button-style radio options */
.category-option {
  margin-bottom: 8px;
}

.category-option label {
  display: block;
  position: relative;
  cursor: pointer;
  padding: 12px 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  background: white;
  transition: all 0.2s ease;
  font-size: 14px;
  font-weight: 500;
  color: #555;
}

.category-option label:hover {
  border-color: var(--brand);
  background: #f8fcff;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(38, 160, 218, 0.1);
}

/* Hide the default radio button */
.category-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* Selected state styling */
.category-option input[type="radio"]:checked+span {
  color: white;
}

.category-option input[type="radio"]:checked~* {
  color: white;
}

.category-option label:has(input[type="radio"]:checked) {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  border-color: var(--brand);
  color: white;
  box-shadow: 0 4px 12px rgba(38, 160, 218, 0.3);
  transform: translateY(-1px);
}

/* Fallback for browsers that don't support :has() */
.category-option.selected label {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  border-color: var(--brand);
  color: white;
  box-shadow: 0 4px 12px rgba(38, 160, 218, 0.3);
  transform: translateY(-1px);
}

.category-option.selected label span {
  color: white;
}

/* Add icon for selected state */
.category-option label::after {
  content: '';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: white;
  transition: all 0.2s ease;
}

.category-option label:hover::after {
  border-color: var(--brand);
}

.category-option input[type="radio"]:checked+span::after,
.category-option label:has(input[type="radio"]:checked)::after,
.category-option.selected label::after {
  background: white;
  border-color: white;
}

.category-option input[type="radio"]:checked+span::before,
.category-option label:has(input[type="radio"]:checked)::before,
.category-option.selected label::before {
  content: '✓';
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--brand);
  font-weight: bold;
  font-size: 12px;
  z-index: 1;
}

/* Special styling for "Create new category" option */
.create-new-option label {
  border-style: dashed;
  border-color: var(--brand);
  color: var(--brand);
  background: #f8fcff;
}

.create-new-option label:hover {
  background: #e3f2fd;
  border-style: solid;
}

.create-new-option.selected label {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  border-style: solid;
  color: white;
}

/* New category input container */
.new-category-container {
  margin-top: 12px;
  margin-left: 0;
  padding: 0 16px;
}

#new-post-category-container input,
#new-save-post-category-name {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: white;
  transition: border-color 0.2s ease;
  box-sizing: border-box;
  margin-bottom: 6px;
}

#new-post-category-container input:focus,
#new-save-post-category-name:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(38, 160, 218, 0.1);
}

.save-dialog-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: var(--bg-soft);
  flex-shrink: 0;
}

.cancel-save-button,
.confirm-save-post-button {
  padding: 12px 24px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  border: 2px solid transparent;
}

.cancel-save-button {
  background: white;
  border-color: var(--border);
  color: var(--muted);
}

.cancel-save-button:hover {
  background: #f5f5f5;
  border-color: #bbb;
  color: var(--text);
}

.confirm-save-post-button {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

.confirm-save-post-button:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(38, 160, 218, 0.3);
}

.confirm-save-post-button:disabled {
  background: #ccc;
  border-color: #ccc;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ===========================================
   Notifications
   =========================================== */
.save-notification {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 999999;
  display: flex !important;
  align-items: center;
  max-width: 90%;
  padding: 12px 20px;
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.18);
  opacity: 0;
  transform: translate(-50%, -50%) translateY(30px);
  transition: transform 0.35s ease, opacity 0.35s ease;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translate(-50%, -50%) translateY(30px); }
  to   { opacity: 1; transform: translate(-50%, -50%) translateY(0); }
}

@keyframes fadeOutDown {
  from { opacity: 1; transform: translate(-50%, -50%) translateY(0); }
  to   { opacity: 0; transform: translate(-50%, -50%) translateY(30px); }
}

.save-notification.notice-show {
  animation: fadeInUp 0.35s forwards;
}

.save-notification.notice-hide {
  animation: fadeOutDown 0.35s forwards;
}

.notification-success {
  display: flex !important;
  border-left: 4px solid var(--accent);
}

.notification-error {
  border-left: 4px solid #f44336;
}

.notification-icon {
  margin-right: 12px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
}

.icon-success svg {
  fill: var(--accent);
  width: 18px;
  height: 18px;
  display: block;
}

.icon-error svg {
  fill: #f44336;
  width: 18px;
  height: 18px;
  display: block;
}

.notification-message {
  line-height: 1.4;
  padding-top: 1px;
}

/* ===========================================
   Responsive
   =========================================== */
@media (max-width: 520px) {
  .save-dialog-content {
    width: 95%;
    margin: 20px;
  }

  .save-dialog-header,
  .save-dialog-body,
  .save-dialog-footer {
    padding: 16px;
  }

  .save-dialog-header h3 {
    font-size: 16px;
  }

  .category-option label {
    padding: 10px 12px;
    font-size: 13px;
  }

  .save-dialog-footer {
    flex-direction: column;
  }

  .cancel-save-button,
  .confirm-save-post-button {
    width: 100%;
    order: 2;
  }

  .cancel-save-button {
    order: 1;
  }
}


/* ===========================================
   Non-Logged-In Modal Popup Styles
   =========================================== */

/* Modal Backdrop */
.saved-content-modal-backdrop,
.mpusc-saved-content-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.85);
  z-index: 99999;
  display: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.saved-content-modal-backdrop.active,
.mpusc-saved-content-modal-backdrop.active {
  display: block;
  opacity: 1;
}

/* Modal Content Container */
.saved-content-modal-content,
.mpusc-saved-content-modal-content {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  z-index: 999999;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  max-width: 600px;
  width: 90%;
  padding: 30px;
  display: none;
  opacity: 0;
  transition: all 0.3s ease;
}

.saved-content-modal-content.active,
.mpusc-saved-content-modal-content.active {
  display: block;
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Modal Inner Content */
.mpusc-modal-content {
  padding: 1em;
  text-align: center;
}

/* Close Button */
.modal-close-x {
  position: absolute;
  top: 15px !important;
  right: 15px !important;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  text-decoration: none;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.modal-close-x:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #333;
  transform: rotate(90deg);
}

/* Modal Heading */
.mpusc-modal-content h3 {
  margin: 0 0 16px;
  font-size: 22px !important;
  font-weight: 600;
  color: #333;
  font-family: 'Poppins';
  line-height: 1.2;
}

/* Modal Text */
.mpusc-modal-content p {
  margin: 0 0 28px;
  font-size: 16px;
  line-height: 1.5;
  color: #666;
  font-family: 'Poppins', sans-serif;
}

/* Modal Buttons Container */
.mpusc-modal-buttons {
  display: flex;
  flex-direction: column !important;
  align-items: center;
  margin-top: 20px;
}

/* Join Now Button */
.mpusc-modal-join-button {
  display: inline-block !important;
  padding: 12px 24px;
  background-color: #188ece !important;
  color: #fff !important;
  text-decoration: none !important;
  font-size: 16px;
  font-weight: 500;
  border-radius: 4px;
  transition: background-color 0.3s ease !important;
  box-shadow: 0 2px 5px rgba(24, 142, 206, 0.15) !important;
  min-width: 200px;
  font-family: 'Poppins', sans-serif;
  border: none;
  cursor: pointer;
}

.mpusc-modal-join-button:hover {
  background-color: #1680b9;
  text-decoration: none;
  box-shadow: 0 4px 8px rgba(24, 142, 206, 0.3) !important;
  color: #fff !important;
}

/* Animation keyframes */
@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes modalFadeOut {
  from {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
  }
}

/* Apply animations */
.saved-content-modal-content.active,
.mpusc-saved-content-modal-content.active {
  animation: modalFadeIn 0.3s ease forwards;
}

.saved-content-modal-content:not(.active),
.mpusc-saved-content-modal-content:not(.active) {
  animation: modalFadeOut 0.3s ease forwards;
}

/* Responsive Design */
@media (max-width: 600px) {
  .saved-content-modal-content,
  .mpusc-saved-content-modal-content {
    max-width: 90%;
    width: calc(100% - 40px);
  }

  .mpusc-modal-content {
    padding: 30px 24px 24px;
  }

  .mpusc-modal-content h3 {
    font-size: 20px;
    margin-bottom: 12px;
  }

  .mpusc-modal-content p {
    font-size: 14px;
    margin-bottom: 20px;
  }

  .mpusc-modal-buttons {
    flex-direction: column;
    gap: 10px;
  }

  .mpusc-modal-join-button {
    width: 100%;
    padding: 12px 24px;
    font-size: 15px;
  }

  .modal-close-x {
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    font-size: 20px;
  }
}

/* Ensure modal appears above everything */
.saved-content-modal-backdrop,
.mpusc-saved-content-modal-backdrop,
.saved-content-modal-content,
.mpusc-saved-content-modal-content {
  z-index: 999999 !important;
}

/* Prevent body scroll when modal is open */
body.modal-open {
  overflow: hidden;
}

@keyframes gradientShift {
  0%, 100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

/* Focus states for accessibility */
.modal-close-x:focus,
.mpusc-modal-join-button:focus {
  outline: 2px solid #26A0DA;
  outline-offset: 2px;
}