/* Base styling */
:root {
  --primary-color: #4285f4;
  --primary-hover: #3367d6;
  --success-color: #0f9d58;
  --danger-color: #db4437;
  --warning-color: #f4b400;
  --light-bg: #f8f9fa;
  --dark-text: #202124;
  --medium-text: #5f6368;
  --light-text: #ffffff;
  --border-color: #dadce0;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --transition: all 0.3s ease;
}

body {
  font-family: 'Public Sans', 'Open Sans', sans-serif;
  color: var(--dark-text);
  line-height: 1.5;
  margin: 0;
  padding: 0;
  background-color: var(--light-bg);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  margin-top: 0;
  font-weight: 600;
  color: var(--dark-text);
}

h3 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  margin-top: 0.5rem;
}

/* Primary button styling */
.editor-button {
  background-color: var(--primary-color);
  color: var(--light-text);
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  margin: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.editor-button:hover {
  background-color: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.editor-button:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

/* Standard button styling */
button {
  background-color: #fff;
  color: var(--dark-text);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  margin-right: 4px;
  margin-bottom: 4px;
}

button:hover {
  background-color: var(--light-bg);
  border-color: var(--medium-text);
}

button:active {
  transform: translateY(1px);
}

/* Action buttons */
.submitChangesBtn {
  background-color: var(--primary-color);
  color: var(--light-text);
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.submitChangesBtn:hover {
  background-color: var(--primary-hover);
  box-shadow: var(--shadow-md);
}

#clearCanvas, #remove_transformer, #rmRectangle, #clearAutotext {
  background-color: var(--danger-color);
  color: var(--light-text);
  border: none;
}


#addText, #addautotext, #restoreRectangle {
  background-color: var(--success-color);
  color: var(--light-text);
  border: none;
}

/* Form elements styling - consistent sizing */
input, select, textarea {
  height: 32px;
  padding: 0 6px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: #fff;
  color: var(--dark-text);
  font-size: 0.875rem;
  transition: var(--transition);
  margin-right: 4px;
  box-sizing: border-box;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary-color);
  outline: none;
  box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.2);
}

/* Input field sizes */
input[type="text"] {
  width: 180px;
}

input[type="number"] {
  width: 60px;
}

input[type="color"] {
  width: 40px;
  height: 36px;
  padding: 2px;
  cursor: pointer;
}

select {
  width: 150px;
  cursor: pointer;
  padding-right: 24px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235f6368' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* Consistent form element layout */
#textCustomization, #autotextCustomization, #mediaCustomization {
  display: none;
  background-color: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px;
  margin-top: 8px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
}

#edit-text-content, #autotext-edit-text-content,
#text-control, #autotext-text-control,
#rectangle-control, #autotext-rectangle-control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

/* Essential lightbox styles */
.lightbox-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 9000;
  overflow: auto;
}

.lightbox-container {
  width: 95%;
  max-width: 1320px;
  height: 98%;
  position: relative;
  margin: 1% auto;
  background-color: #fff;
  padding: 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: auto;
  z-index: 9001;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--medium-text);
  padding: 4px 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.lightbox-close:hover {
  background-color: var(--light-bg);
  color: var(--dark-text);
}

/* Template and Save template lightboxes */
#template-lightbox, #save-template-lightbox, #log-lightbox, #manage-fonts-lightbox {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 1280px;
  height: 80%;
  max-height: 720px;
  background-color: #fff;
  padding: 24px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 2px solid #4285f4; /* Add this line to set a blue border */
  z-index: 9002;
}

#log-lightbox textarea {
  width: 100%;
  height: calc(100% - 60px);
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  resize: none;
  font-family: monospace;
  font-size: 0.875rem;
}

/* Layout and functional areas */
#block_layers_button {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  margin-bottom: 8px;
}

#block-layers {
  width: 1280px;
  height: 720px;
  margin-top: 10px;
  margin-bottom: 10px;
  position: relative;
  overflow: visible;
  border: 1px solid red; /* Changed border color to red */
  border-radius: 0; /* Removed border radius */
  box-shadow: var(--shadow-sm);
}

/* Media grid */
#image-grid, #voice-grid, #template-grid, #template-grid1 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  padding: 10px;
}

.image-item {
  position: relative;
  text-align: center;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px;
  box-sizing: border-box;
  transition: var(--transition);
  background-color: #fff;
}

.image-item:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* Progress bar */
.indeterminate-progress-bar {
  display: none;
  margin-top: 16px;
  background-color: var(--border-color);
  border-radius: 9999px;
  height: 4px;
  position: relative;
  overflow: hidden;
}

.indeterminate-progress-bar__progress {
  background-color: var(--primary-color);
  border-radius: 9999px;
  position: absolute;
  bottom: 0;
  top: 0;
  width: 50%;
  animation-duration: 2s;
  animation-iteration-count: infinite;
  animation-name: indeterminate-progress-bar;
}

@keyframes indeterminate-progress-bar {
  from { left: -50%; }
  to { left: 100%; }
}

/* Notes and helper text */
em {
  color: var(--medium-text);
  font-style: italic;
  font-size: 0.875rem;
}

/* Group of buttons */
#block_layers_button {
  background-color: var(--light-bg);
  border-radius: var(--radius-md);
  padding: 8px;
  margin-bottom: 8px;
}

/* Media query for smaller screens */
@media (max-width: 768px) {
  .lightbox-container {
    width: 95%;
    height: 95%;
    padding: 16px;
  }
  
  input[type="text"] {
    width: 300px;
  }
  
  select {
    width: 120px;
  }
  
  #block-layers {
    height: 500px;
  }
}

/* Ensure customization panels display properly with proper sizing */
#textCustomization, #autotextCustomization {
  max-width: 100%;
  overflow: visible;
}

/* Compact lightbox styles */
.lightbox-container {
  padding: 10px;  /* Reduced from 16px */
  font-size: 0.9rem; /* Base font size reduction */
}

/* Compact typography */
.lightbox-container h3 {
  font-size: 1rem;
  margin-bottom: 0.3rem;
  margin-top: 0.3rem;
}

.lightbox-container h2 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

/* Reduce button size */
.lightbox-container button {
  padding: 4px 8px;
  font-size: 0.8rem;
  margin-right: 3px;
  margin-bottom: 3px;
}

.lightbox-container .submitChangesBtn {
  padding: 6px 12px;
}

/* Compact form controls */
.lightbox-container input, 
.lightbox-container select, 
.lightbox-container textarea {
  height: 28px;
  padding: 0 4px;
  font-size: 0.8rem;
  margin-right: 3px;
}

/* Text in customization areas */
#textCustomization label,
#textCustomization div,
#autotextCustomization label,
#autotextCustomization div {
  font-size: 0.75rem;
}

/* Make text labels more compact */
#text-control, #autotext-text-control,
#rectangle-control, #autotext-rectangle-control,
#edit-text-content, #autotext-edit-text-content {
  font-size: 0.75rem;
  line-height: 1.2;
}

.lightbox-container input[type="color"] {
  height: 28px;
  width: 35px;
}

/* Tighter spacing for control sections */
#textCustomization, 
#autotextCustomization, 
#mediaCustomization {
  padding: 6px;
  margin-top: 5px;
  margin-bottom: 5px;
}

#edit-text-content, 
#autotext-edit-text-content,
#text-control, 
#autotext-text-control,
#rectangle-control, 
#autotext-rectangle-control {
  gap: 3px;
  margin-bottom: 5px;
  padding-bottom: 5px;
}

/* More compact block layers button group */
#block_layers_button {
  padding: 5px;
  margin-bottom: 5px;
  gap: 3px;
}

/* Helper text */
.lightbox-container em {
  font-size: 0.75rem;
}

/* Close button */
.lightbox-close {
  font-size: 1.2rem;
  padding: 3px 6px;
  top: 10px;
  right: 10px;
}

/* Notes section */
.lightbox-container > div:nth-child(4) { /* Targeting the note section */
  margin: 5px 0;
  font-size: 0.75rem;
}

/* Optional: Adjust the height of the editor area if needed */
#block-layers {
  height: 720px; /* Adjust as needed */
  margin-top: 5px;
  margin-bottom: 5px;
}

/* Input size adjustments */
.lightbox-container input[type="text"] {
  width: 300px;
}

.lightbox-container input[type="number"] {
  width: 45px;
}

.lightbox-container select {
  width: 130px;
}

#layerContextMenu {
  display: none;
  z-index: 10000;
  width: 120px;
  background-color: white;
  box-shadow: 0 0 5px grey;
  border-radius: 3px;
  z-index: 9010;
}

#layerContextMenu button {
  width: 100%;
  background-color: white;
  border: none;
  margin: 0;
  padding: 10px;
  text-align: left;
}

#layerContextMenu button:hover {
  background-color: lightgray;
}

/* Special styling for delete button */
#context_delete {
  color: #db4437; /* Using the danger color from your CSS */
}

/* Special styling for cancel button */
#context_cancel {
  border-top: 1px solid #dadce0;
}

#canvas-resolution {
  margin-left: 5px;
  padding: 4px 8px;
  font-size: 0.8rem;
  height: 28px;
  background-color: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

#canvas-resolution:hover {
  border-color: var(--medium-text);
}

/* Template Grid Styling */
#template-grid1, #template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
  padding: 16px;
  max-height: calc(100% - 80px);
  overflow-y: auto;
}

/* Template Item Styling */
.image-item {
  display: flex;
  flex-direction: column;
  position: relative;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: white;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
  height: 200px;
}

.image-item:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

/* Template Name Styling */
.template-name-span {
  background-color: rgba(255, 255, 255, 0.9);
  color: var(--dark-text);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 2;
}

/* Template Thumbnail Styling */
.image-item img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  flex-grow: 1;
}

/* Selection Button Styling */
.choose-span, .choose-span-new-template {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--primary-color);
  color: white;
  text-align: center;
  padding: 8px 0;
  font-weight: 600;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 2;
}

.image-item:hover .choose-span,
.image-item:hover .choose-span-new-template {
  opacity: 1;
}

/* Delete Button Styling */
.delete-template {
  position: absolute;
  top: 8px;
  right: 8px;
  background-color: var(--danger-color);
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  cursor: pointer;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.image-item:hover .delete-template {
  opacity: 1;
}

.delete-template:hover {
  transform: scale(1.1);
}

/* New Template Input Styling */
.image-item input[type="text"] {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin: 8px 0;
}

/* Empty State Messaging */
#template-grid:empty::after,
#template-grid1:empty::after {
  content: "No templates available";
  display: block;
  padding: 20px;
  text-align: center;
  color: var(--medium-text);
  font-style: italic;
  grid-column: 1 / -1;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  #template-grid1, #template-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    padding: 12px;
  }
  
  .image-item {
    height: 180px;
  }
  
  .template-name-span {
    padding: 6px 10px;
    font-size: 0.8rem;
  }
  
  .image-item img {
    height: 100px;
  }
  
  .choose-span, .choose-span-new-template {
    padding: 6px 0;
    font-size: 0.9rem;
    opacity: 1; /* Always visible on mobile */
  }
  
  .delete-template {
    opacity: 1; /* Always visible on mobile */
    width: 20px;
    height: 20px;
    font-size: 0.8rem;
  }
}

/* Dark mode compatibility */
@media (prefers-color-scheme: dark) {
  .image-item {
    background-color: #2d2d2d;
    border-color: #444;
  }
  
  .template-name-span {
    background-color: rgba(45, 45, 45, 0.9);
    color: #eee;
    border-color: #444;
  }
  
  .image-item input[type="text"] {
    background-color: #333;
    color: #eee;
    border-color: #555;
  }
}

/* Loading Bar Styles */
.loading-bar-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    z-index: 9999;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.loading-bar {
    width: 300px;
    height: 20px;
    background-color: #f3f3f3;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 10px;
}

.loading-bar-progress {
    height: 100%;
    width: 0%;
    background-color: #4CAF50;
    transition: width 0.3s ease;
}

.loading-text {
    color: white;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
}

/* Font Management styles */
#fonts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    padding: 16px;
    max-height: calc(100% - 100px);
    overflow-y: auto;
}

.font-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease;
}

.font-item:hover {
    box-shadow: var(--shadow-md);
}

.font-item.system-font {
    background-color: #f8f9fa;
    border-left: 4px solid var(--primary-color);
}

.font-preview {
    font-size: 20px;
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.font-name {
    font-weight: 600;
    color: var(--dark-text);
}

.font-actions {
    display: flex;
}

.delete-font {
    background-color: var(--danger-color);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    opacity: 0.9;
    transition: opacity 0.2s;
}

.system-font .delete-font {
    display: none;
}

.delete-font:hover {
    opacity: 1;
}

.fonts-actions {
    display: flex;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

  .template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
    padding: 16px;
  }
  
/* Edit button styling */
.edit-template-btn {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--primary-color);
    color: white;
    text-align: center;
    padding: 8px 0;
    font-weight: 600;
    cursor: pointer;
    border: none;
    border-radius: 0;
    z-index: 2;
}

/* Position the edit button inside the template card */
.image-item {
    position: relative;
    padding-bottom: 40px; /* Make space for the edit button */
}

/* Make sure the image doesn't overlap with the button */
.image-item img {
    max-height: calc(100% - 40px);
}

/* Help button styling */
.help-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-color: #f4b400;
  color: white;
  font-weight: bold;
  cursor: pointer;
  margin-left: 4px;
  border: none;
  font-size: 14px;
  box-shadow: var(--shadow-sm);
}

.help-button:hover {
  background-color: #e0a800;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

