/* SFMC Design System Variables */
:root {
    /* Brand colors and theme variables */
    --sfmc-brand-blue: #0070d2;
    --sfmc-text-color: #16325c;
    --sfmc-border-color: #d8dde6;
    --sfmc-background: #f4f6f9;
    --sfmc-error-color: #c23934;
    --sfmc-success-color: #04844b;
    --sfmc-warning-color: #ffb75d;
}

/* Base styles */
body {
    font-family: "Salesforce Sans", Arial, sans-serif;
    color: var(--sfmc-text-color);
    font-size: 13px;
    line-height: 20px;
    background: var(--sfmc-background);
    margin: 0;
    padding: 0;
}

/* Main container layout */
.container {
    display: flex;
    height: 100vh;
    gap: 0.5rem;
    padding: 0.25rem;
    box-sizing: border-box;
    overflow: hidden; /* Prevents container level scrolling */
}

/* Panel base styles */
.panel {
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

/* Left panel - Main content area */
.panel.left {
    flex: 3;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 2.5rem); /* Use height instead of max-height for better scroll control */
    overflow: hidden;
}

/* Right panel - Preview area */
.panel.right {
    flex: 2;
    padding: 1px;
    display: flex; /* Added for proper iframe sizing */
}

/* Template Selection Area */
#selectTemplateSection {
    flex: 1;
    overflow-y: auto;
    /* Custom scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: var(--sfmc-border-color) transparent;
}

#selectTemplateSection::-webkit-scrollbar {
  width: 6px;
}

#selectTemplateSection::-webkit-scrollbar-track {
  background: transparent;
}

#selectTemplateSection::-webkit-scrollbar-thumb {
  background-color: var(--sfmc-border-color);
  border-radius: 3px;
}

#validationErrors {
    flex-shrink: 0; /* Keeps error messages always visible */
}

/* Welcome Screen Component */
#scm-cta-container {
    flex-shrink: 0;
    text-align: center;
    padding: 1rem 0;
}

#scm-cta-hero {
    text-align: center;
    width: 100%;
    margin-bottom: 1.5rem;
    box-sizing: border-box;
    display: block;
    unicode-bidi: isolate;
}

#scm-cta-hero svg {
    max-width: 100%;
    height: auto;
}

#scm-cta-caption_lg {
    text-align: center;
    font-size: 1.25rem;
    line-height: 1.25;
    margin-bottom: 0.25rem;
    box-sizing: border-box;
    display: block;
    unicode-bidi: isolate;
}

#scm-cta-caption_sm {
    text-align: center;
    margin-bottom: 1rem;
    box-sizing: border-box;
    font-size: 0.8125rem;
}

/* Fixed elements outside scroll area */
.radio-group {
    margin-bottom: 1rem;
}

/* Form Elements */
.radio-group {
  flex-shrink: 0; /* Prevents shrinking when content grows */
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding: 1rem;
  background: #fff;
  border: 1px solid var(--sfmc-border-color);
  border-radius: 4px;
}

.radio-group label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.radio-group label:hover {
  background: var(--sfmc-background);
}

select,
input[type="text"] {
  height: 28px;
  border: 1px solid var(--sfmc-border-color);
  border-radius: 4px;
  padding: 0 8px;
  width: 100%;
  box-sizing: border-box;
  color: var(--sfmc-text-color);
  background-color: #fff;
}

select:focus,
input[type="text"]:focus {
  border-color: var(--sfmc-brand-blue);
  box-shadow: 0 0 3px var(--sfmc-brand-blue);
  outline: none;
}

/* Buttons */
button {
  height: 28px;
  padding: 0 12px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: normal;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid var(--sfmc-border-color);
}

button#verifyButton {
  background: var(--sfmc-brand-blue);
  color: white;
  border: none;
}

button#verifyButton:hover {
  background: #005fb2;
}

button#saveButton {
  background: var(--sfmc-success-color);
  color: white;
  border: none;
}

button#saveButton:hover {
  background: #037d46;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Messages */
#validationErrors {
  margin-bottom: 0.5rem;
}

.message-error {
  color: var(--sfmc-error-color);
  background: #fef1ec;
  border: 1px solid var(--sfmc-error-color);
  padding: 0.5rem;
  border-radius: 4px;
  margin-bottom: 0.25rem;
}

.message-warning {
  color: #514f4d;
  background: #fff4e1;
  border: 1px solid var(--sfmc-warning-color);
  padding: 0.5rem;
  border-radius: 4px;
  margin-bottom: 0.25rem;
}

/* Template Sections */
#selectTemplateSection,
#newTemplateSection {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid var(--sfmc-border-color);
    border-radius: 4px;
    padding: 1rem;
    margin-top: 0.5rem;
    /* Height removed for selectTemplateSection */
}

/* New Template Section specific styles */
#newTemplateSection {
    height: calc(100% - 120px); /* Accounts for radio group and validation errors */
    overflow: hidden; /* Prevents section overflow */
}

/* Fixed header area styles */
.template-header {
    flex-shrink: 0;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--sfmc-border-color);
}

/* Dynamic content areas with scroll */
#placeholders,
#placeholderContainer {
    overflow-y: auto;
    flex: 1;
    min-height: 0; /* Enables proper flex item overflow */
    scrollbar-width: thin;
    scrollbar-color: var(--sfmc-border-color) transparent;
}

/* Scrollbar styling for all containers */
#mobileContainer::-webkit-scrollbar,
#placeholders::-webkit-scrollbar,
#placeholderContainer::-webkit-scrollbar {
    width: 6px;
}

/* Scrollbar track style */
#mobileContainer::-webkit-scrollbar-track,
#placeholders::-webkit-scrollbar-track,
#placeholderContainer::-webkit-scrollbar-track {
    background: transparent;
}

/* Scrollbar thumb style */
#mobileContainer::-webkit-scrollbar-thumb,
#placeholders::-webkit-scrollbar-thumb,
#placeholderContainer::-webkit-scrollbar-thumb {
    background-color: var(--sfmc-border-color);
    border-radius: 3px;
}

/* Required field indicator */
.required-field::after {
  content: " *";
  color: var(--sfmc-error-color);
  font-weight: bold;
}

/* Preview Frame */
#previewIframe {
  width: 100%;
  height: 100%; /* Adjusted height calculation */
  border: 1px solid var(--sfmc-border-color);
  border-radius: 4px;
  flex: 1; /* Added for proper sizing */
}

/* Placeholder Info */
.placeholder-info {
  color: var(--sfmc-brand-blue);
  font-size: 14px;
  margin-left: 0.25rem;
  cursor: help;
}

/* Form Layout */
.form-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.form-row label {
  flex: 0 0 150px;
  color: var(--sfmc-text-color);
}

.form-row select,
.form-row input {
  flex: 1;
}

/* verifyResult 스타일 수정 */
#verifyResult {
    flex: 1;
    overflow-y: auto;
    padding-right: 0.5rem;
    margin-top: 0.5rem;
    padding-bottom: 1rem;
    /* Height removed in favor of flex */
}

/* Verify Result Scrollbar Styles */
#verifyResult::-webkit-scrollbar {
    width: 6px;
}

#verifyResult::-webkit-scrollbar-track {
    background: transparent;
}

#verifyResult::-webkit-scrollbar-thumb {
    background-color: var(--sfmc-border-color);
    border-radius: 3px;
}

/* Array Section Styling */
#verifyResult fieldset {
  border: 1px dashed var(--sfmc-border-color);
  border-radius: 4px;
  padding: 1rem;
  margin-bottom: 1rem;
}

#verifyResult legend {
  padding: 0 0.5rem;
  color: var(--sfmc-text-color);
  font-weight: 500;
}

#verifyResult h4 {
  margin: 0 0 0.5rem 0;
  color: var(--sfmc-text-color);
}

/* Common Scrollbar Styles */
#selectTemplateSection,
#newTemplateSection,
#placeholders,
#placeholderContainer,
#verifyResult,
#mobileContainer {
  /* Firefox Scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--sfmc-border-color) transparent;
}

/* Webkit Scrollbar Styles (Chrome, Safari, Edge) */
#selectTemplateSection::-webkit-scrollbar,
#newTemplateSection::-webkit-scrollbar,
#placeholders::-webkit-scrollbar,
#placeholderContainer::-webkit-scrollbar,
#verifyResult::-webkit-scrollbar,
#mobileContainer::-webkit-scrollbar {
  width: 6px;
}

#selectTemplateSection::-webkit-scrollbar-track,
#newTemplateSection::-webkit-scrollbar-track,
#placeholders::-webkit-scrollbar-track,
#placeholderContainer::-webkit-scrollbar-track,
#verifyResult::-webkit-scrollbar-track,
#mobileContainer::-webkit-scrollbar-track {
  background: transparent;
}

#selectTemplateSection::-webkit-scrollbar-thumb,
#newTemplateSection::-webkit-scrollbar-thumb,
#placeholders::-webkit-scrollbar-thumb,
#placeholderContainer::-webkit-scrollbar-thumb,
#verifyResult::-webkit-scrollbar-thumb,
#mobileContainer::-webkit-scrollbar-thumb {
  background-color: var(--sfmc-border-color);
  border-radius: 3px;
}

/* SFMC Spinner Styles */
.slds-spinner_container {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 9050;
    background-color: rgba(255, 255, 255, 0.75);
    visibility: visible;
    opacity: 1;
    transition: opacity 0.2s ease, visibility 0s;
    transition-delay: 0s, 0.3s;
}

.slds-assistive-text {
  position: absolute !important;
  margin: -1px !important;
  border: 0 !important;
  padding: 0 !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  text-transform: none !important;
  white-space: nowrap !important;
}

.slds-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 9051;
  transform: translate(-50%, -50%) rotate(90deg);
  will-change: transform;
}

.slds-spinner_medium {
  width: 3rem; /* Increased from 2rem */
  height: 3rem; /* Increased from 2rem */
}

.slds-spinner_brand.slds-spinner:before,
.slds-spinner_brand.slds-spinner:after,
.slds-spinner_brand .slds-spinner__dot-a:before,
.slds-spinner_brand .slds-spinner__dot-a:after,
.slds-spinner_brand .slds-spinner__dot-b:before,
.slds-spinner_brand .slds-spinner__dot-b:after {
  background-color: var(--sfmc-brand-blue);
}

.slds-spinner__dot-a,
.slds-spinner__dot-b {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  transform-origin: 50% 50%;
  will-change: transform;
}

.slds-spinner__dot-a {
  transform: rotate(60deg);
}

.slds-spinner__dot-b {
  transform: rotate(120deg);
}

.slds-spinner:before,
.slds-spinner:after,
.slds-spinner__dot-a:before,
.slds-spinner__dot-a:after,
.slds-spinner__dot-b:before,
.slds-spinner__dot-b:after {
  content: "";
  position: absolute;
  width: 0.75rem; /* Increased from 0.5rem */
  height: 0.75rem; /* Increased from 0.5rem */
  border-radius: 50%;
  background-color: var(--sfmc-brand-blue);
  transform: translate3d(0, 0, 0);
  animation-duration: 1s;
  animation-iteration-count: infinite;
}

/* Animation delays */
.slds-spinner:before {
  animation-delay: -0.083s;
}

.slds-spinner__dot-a:before {
  animation-delay: 0.083s;
}

.slds-spinner__dot-b:before {
  animation-delay: 0.25s;
}

.slds-spinner:after {
  animation-delay: 0.416s;
}

.slds-spinner__dot-a:after {
  animation-delay: 0.583s;
}

.slds-spinner__dot-b:after {
  animation-delay: 0.75s;
}

/* Spinner positioning */
.slds-spinner_medium .slds-spinner__dot-a:before,
.slds-spinner_medium .slds-spinner__dot-b:before,
.slds-spinner_medium.slds-spinner:before {
  top: -0.375rem; /* Adjusted from -0.25rem */
  left: -0.375rem; /* Adjusted from -0.25rem */
  animation-name: dotsBounceBefore-medium;
}

.slds-spinner_medium .slds-spinner__dot-a:after,
.slds-spinner_medium .slds-spinner__dot-b:after,
.slds-spinner_medium.slds-spinner:after {
  top: -0.375rem; /* Adjusted from -0.25rem */
  right: -0.375rem; /* Adjusted from -0.25rem */
  animation-name: dotsBounceAfter-medium;
}

/* Animation keyframes */
@keyframes dotsBounceBefore-medium {
  60% {
    transform: translateX(0);
    animation-timing-function: cubic-bezier(0.275, 0.0425, 0.34, 0.265);
  }
  80% {
    animation-timing-function: cubic-bezier(0, 0.555, 0.35, 0.715);
    transform: translateX(-0.75rem);
  }
  100% {
    transform: translateX(0);
  }
}

@keyframes dotsBounceAfter-medium {
  60% {
    animation-timing-function: cubic-bezier(0.275, 0.0425, 0.34, 0.265);
    transform: translateX(0);
  }
  80% {
    animation-timing-function: cubic-bezier(0, 0.555, 0.35, 0.715);
    transform: translateX(0.75rem);
  }
  100% {
    transform: translateX(0);
  }
}

/* Toast Container */
#toast-container {
    position: fixed;
    top: 20px;
    left: 20px; /* Changed from right to left */
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

/* Toast Animation - Update for left side appearance */
@keyframes slideIn {
    from {
        transform: translateX(-100%); /* Changed from 100% to -100% */
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(-100%); /* Changed from 100% to -100% */
        opacity: 0;
    }
}

/* Toast Message */
.toast-message {
    background: white;
    border-radius: 4px;
    padding: 12px 24px 12px 16px;
    min-width: 300px;
    max-width: 500px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: flex-start;
    gap: 8px;
    animation: slideIn 0.3s ease-out;
    position: relative;
}

/* Toast Types */
.toast-error {
    border-left: 4px solid var(--sfmc-error-color);
    background-color: #fee8e7;
    color: #721c24;
}

.toast-warning {
    border-left: 4px solid var(--sfmc-warning-color);
    background-color: #fff3cd;
    color: #856404;
}

.toast-success {
    border-left: 4px solid var(--sfmc-success-color);
    background-color: #d4edda;
    color: #155724;
    position: relative;
    display: flex;
    align-items: center;
    min-width: 300px;
    max-width: 500px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    animation: slideIn 0.3s ease-out;
}

/* Close Button */
.toast-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #666;
    padding: 4px;
    line-height: 1;
}

.toast-close:hover {
    color: #333;
}

/* Animations */
@keyframes slideIn {
    from {
        transform: translateX(-100%); /* Changed from 100% to -100% */
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(-100%); /* Changed from 100% to -100% */
        opacity: 0;
    }
}

.toast-removing {
    animation: slideOut 0.3s ease-in forwards;
}