/* Template Manager V2 CSS - Aligned with Frontend Dashboard styles */
/* Root font size: 10px */

:root {
  /* Core colors aligned with frontend dashboard */
  --tm-v2-white: #ffffff;
  --tm-v2-black: #000000;
  --tm-v2-gray-100: #f7f7f7;
  --tm-v2-gray-200: #e5e5e5;
  --tm-v2-gray-300: #d4d4d4;
  --tm-v2-gray-400: #a3a3a3;
  --tm-v2-gray-500: #737373;
  --tm-v2-gray-600: #525252;
  --tm-v2-gray-700: #404040;
  --tm-v2-gray-800: #262626;
  --tm-v2-gray-900: #171717;
  
  /* Status colors */
  --tm-v2-success: #34c759;
  --tm-v2-error: #ff3b30;
  --tm-v2-warning: #ff9500;
  --tm-v2-info: #007aff;
  
  /* UI properties */
  --tm-v2-border-radius: 1.28rem; /* 12.8px */
  --tm-v2-box-shadow: 0 0.64rem 0.96rem rgba(0, 0, 0, 0.05), 0 0.16rem 0.48rem rgba(0, 0, 0, 0.1);
  --tm-v2-transition: all 0.2s ease;
}

/* Template manager wrapper aligned with frontend dashboard */
.frontend-dashboard.template-manager-v2 {
  width: 100%;
  min-height: 88vh;
  margin: 1.2rem auto;
  padding: 2.4rem;
  background-color: var(--tm-v2-white);
  border-radius: var(--tm-v2-border-radius);
  font-size: 1.6rem;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.frontend-dashboard.template-manager-v2::-webkit-scrollbar {
  display: none;
}

/* Tabs styling - Transparent with black outline */
.tm-v2-tabs {
  display: flex;
  gap: 0.8rem;
  margin-bottom: 2rem;
  margin-top: 2rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.tm-v2-tab {
  padding: 0.8rem 1.6rem;
  border-radius: 2rem;
  border: 1px solid var(--tm-v2-black);
  background: transparent;
  color: var(--tm-v2-black);
  font-size: 1.4rem;
  font-weight: 400;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--tm-v2-transition);
}

.tm-v2-tab:hover {
  background: var(--tm-v2-gray-100);
}

.tm-v2-tab.active {
  background: var(--tm-v2-black);
  color: var(--tm-v2-white);
  border-color: var(--tm-v2-black);
}

/* Grid container */
.tm-v2-grid-container {
  position: relative;
}

/* No templates message */
.tm-v2-no-templates-message {
  text-align: center;
  padding: 4.8rem 1.6rem;
  background-color: var(--tm-v2-gray-100);
  border-radius: var(--tm-v2-border-radius);
  border: 1px dashed var(--tm-v2-gray-300);
  color: var(--tm-v2-gray-600);
  font-size: 1.6rem;
  margin-bottom: 2rem;
}

/* Grid styling aligned with frontend dashboard */
.tm-v2-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(44.8rem, 1fr));
  gap: 2.4rem;
  overflow-y: auto;
  max-height: 65vh;
  padding-top: 0.5rem;
  padding-bottom: 5rem;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.tm-v2-grid::-webkit-scrollbar {
  display: none;
}

.tm-v2-grid.loading {
  opacity: 0.5;
  pointer-events: none;
}

/* Card styling aligned with frontend dashboard */
.tm-v2-card {
  position: relative;
  display: flex;
  flex-direction: row;
  background-color: var(--tm-v2-white);
  border: 1px solid var(--tm-v2-gray-300);
  border-radius: var(--tm-v2-border-radius);
  overflow: hidden;
  transition: var(--tm-v2-transition);
  min-height: 30rem;
}

.tm-v2-card:hover {
  transform: translateY(-0.32rem);
}

/* Card content - left side */
.tm-v2-card-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 2.4rem;
}

/* Card image - right side */
.tm-v2-card-image {
  width: 40%;
  height: auto;
  overflow-y: auto;
  display: flex;
  align-items: flex-start;
  background-color: var(--tm-v2-gray-100);
  border-left: 1px solid var(--tm-v2-gray-300);
}

.tm-v2-card-image img {
  width: 100%;
  height: auto;
  object-fit: cover;
  object-position: top;
}

.tm-v2-card-image .fd-placeholder-image {
  width: 100%;
  min-height: 24rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--tm-v2-gray-200);
}

/* Card details */
.tm-v2-card-details {
  margin-bottom: 1.6rem;
}

.tm-v2-card-details h3 {
  margin: 0 0 1.2rem 0;
  font-size: 1.9rem;
  font-weight: 600;
  color: var(--tm-v2-black);
}

.tm-v2-card-details p {
  margin: 0;
  font-size: 1.4rem;
  color: var(--tm-v2-gray-600);
  line-height: 1.5;
}

/* Card status */
.tm-v2-card-status {
  display: flex;
  /* align-items: center; */
  gap: 1.2rem;
  margin-bottom: 2rem;
}

.tm-v2-card-switch {
  position: relative;
  display: inline-block;
  width: 4.8rem;
  height: 2.4rem;
}

.tm-v2-card-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.tm-v2-card-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--tm-v2-gray-300);
  transition: .4s;
  border-radius: 1.4rem;
}

.tm-v2-card-slider:before {
  position: absolute;
  content: "";
  height: 1.4rem;
  width: 1.4rem;
  left: 0.5rem;
  bottom: 0.5rem;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .tm-v2-card-slider {
  background-color: var(--tm-v2-success);
}

input:checked + .tm-v2-card-slider:before {
  transform: translateX(2.4rem);
}

.tm-v2-card-status-text {
  font-size: 1.5rem;
  font-weight: 500;
}

.tm-v2-card-status-text.active {
  color: var(--tm-v2-success);
}

.tm-v2-card-status-text.inactive {
  color: var(--tm-v2-gray-600);
}

/* Card actions */
.tm-v2-card-actions {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  margin-top: auto;
}

.tm-v2-card-actions .fd-button {
  width: 100%;
  padding: 1.2rem 1.6rem;
  text-align: center;
  justify-content: center;
}

/* Template modal specific styling */
.fd-template-container.tm-v2-modal {
max-width: 144rem; /* 1440px - make it bigger for template manager */
width: 90vw;
}

.tm-v2-modal-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr); /* Force 2 columns for modal */
  gap: 2.4rem;
}

/* Card styling improvements */
.tm-v2-card {
min-height: 30rem; /* Increase minimum height */
}

/* Better image container */
.tm-v2-card-image {
width: 50%;
min-width: 40%;
flex-shrink: 0; /* Prevent shrinking */
max-height: 45rem;
overflow-y: auto;
display: flex;
align-items: flex-start;
background-color: var(--tm-v2-gray-100);
border-left: 1px solid var(--tm-v2-gray-300);
overflow-x: hidden; /* Prevent horizontal overflow */
}

/* Image sizing improvements */
.tm-v2-card-image img {
width: 100%;
height: auto;
min-height: 100%;
object-fit: cover;
object-position: top center;
display: block; /* Remove inline spacing */
}

/* Improve content container to work with fixed image width */
.tm-v2-card-content {
flex: 1;
min-width: 0; /* Allow flex item to shrink */
display: flex;
flex-direction: column;
padding: 2.4rem;
}

/* Prevent button overflow 
.tm-v2-card-actions {
display: flex;
flex-wrap: wrap;
gap: 1.2rem;
margin-top: auto;
}

.tm-v2-card-actions .fd-button {
flex: 1 1 calc(50% - 0.6rem);
min-width: 0;
max-width: 100%;
padding: 1.2rem 1.6rem;
text-align: center;
white-space: normal;
}
*/

/* Responsive adjustments for modal */
@media screen and (max-width: 1200px) {
.tm-v2-modal-grid {
  grid-template-columns: 1fr; /* Single column on smaller screens */
}
}

/* Responsive adjustments */
@media screen and (max-width: 768px) {
  .tm-v2-grid {
      grid-template-columns: 1fr;
      gap: 1.6rem;
  }
  
  .tm-v2-card {
      flex-direction: column;
  }
  
  .tm-v2-card-image {
      width: 100%;
      height: 25.6rem;
      border-left: none;
      border-top: 1px solid var(--tm-v2-gray-300);
      order: -1; /* Move image to top on mobile */
  }
  
  .tm-v2-card-actions .fd-button {
      flex: 1 1 100%;
  }
  
  .fd-header {
      flex-direction: column;
      gap: 1.5rem;
      align-items: stretch;
  }
  
  .fd-button {
      width: 100%;
      justify-content: center;
  }
}

@media screen and (max-width: 480px) {
  .tm-v2-grid {
      grid-template-columns: 1fr;
  }
}

/* Prevent body scrolling when modal is open */
body.tm-v2-modal-open {
  overflow: hidden;
}

/* Notification styling */
.tm-v2-notification {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 12px 24px;
  border-radius: 8px;
  background-color: var(--tm-v2-info);
  color: white;
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.tm-v2-notification.show {
  opacity: 1;
  transform: translateY(0);
}

.tm-v2-notification-success {
  background-color: var(--tm-v2-success);
}

.tm-v2-notification-error {
  background-color: var(--tm-v2-error);
}

.tm-v2-notification-warning {
  background-color: var(--tm-v2-warning);
}

/* Loading states for buttons */
.fd-button.loading {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Ensure edit button is clickable */
.fd-button-edit {
  cursor: pointer;
  display: inline-block;
}

/* Fix for modal overlay */
.fd-template-overlay {
  cursor: default; /* Prevent pointer cursor on the entire overlay */
}

.fd-template-overlay .fd-template-container {
  cursor: auto; /* Reset cursor inside the container */
}

/* Ensure buttons are visible in their correct states */
.tm-v2-card-actions .fd-button {
  display: inline-block;
}

/* Ensure edit button doesn't get blocked */
.fd-button-edit {
  position: relative;
  z-index: 10;
}

/* Prevent card click interference */
.tm-v2-card-actions {
  position: relative;
  z-index: 10;
}

/* Fix button transition issues */
.tm-v2-activate-template,
.tm-v2-deactivate-template {
  transition: all 0.2s ease;
}