/* Templates Page Styles */
.templates-page {
  padding: 2rem;
}

.templates-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.templates-header h1 {
  font-size: 2.5rem;
}

.template-categories {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.category-btn {
  padding: 0.75rem 1.5rem;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
}

.category-btn.active {
  background: var(--accent-gradient);
  border-color: transparent;
  color: white;
}

.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 2rem;
}

.template-card {
  background: var(--card-bg);
  padding: 2rem;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  transition: transform 0.3s ease;
}

.template-card:hover {
  transform: translateY(-5px);
}

.template-card h3 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.template-card ul {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
}

.template-card li {
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.template-card li:last-child {
  border-bottom: none;
}

.template-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
}

/* ---------- Modal Styles ---------- */
.modal {
  display: none;
  position: fixed;
  z-index: 10000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  visibility: hidden;
}

.modal.show {
  display: flex;
  opacity: 1;
  visibility: visible;
  animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    backdrop-filter: blur(0px);
  }
  to {
    opacity: 1;
    backdrop-filter: blur(10px);
  }
}

.modal-content {
  background: var(--card-bg);
  backdrop-filter: blur(20px) saturate(180%);
  border-radius: 24px;
  padding: 2.5rem;
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transform: scale(0.9);
  transition: transform 0.3s ease;
  animation: modalSlideUp 0.3s ease;
}

.modal.show .modal-content {
  transform: scale(1);
}

@keyframes modalSlideUp {
  from {
    transform: translateY(50px) scale(0.9);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.modal-content h2 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.close-modal {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  font-size: 1.75rem;
  font-weight: 300;
  cursor: pointer;
  color: var(--muted);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.3s ease;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 10;
}

.close-modal:hover {
  color: var(--text);
  background: rgba(248, 113, 113, 0.2);
  border-color: rgba(248, 113, 113, 0.3);
  transform: rotate(90deg) scale(1.1);
}

.close-modal:active {
  transform: rotate(90deg) scale(0.95);
}

/* Form Styles */
#new-template-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.form-group label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 0.85rem;
}

.form-group label i {
  color: var(--accent);
  font-size: 1rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 1rem 1.25rem;
  border: 2px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  transition: all 0.3s ease;
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 0 4px rgba(79, 209, 197, 0.1);
  transform: translateY(-2px);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.form-group select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23fff' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 3rem;
}

.form-group textarea {
  min-height: 150px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.6;
}

/* Submit Button */
#new-template-form .btn-primary {
  padding: 1rem 2rem;
  background: linear-gradient(135deg, #4fd1c5, #3b82f6);
  border: none;
  border-radius: 50px;
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
  box-shadow: 0 8px 25px rgba(79, 209, 197, 0.3);
  position: relative;
  overflow: hidden;
}

#new-template-form .btn-primary::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

#new-template-form .btn-primary:hover::before {
  width: 300px;
  height: 300px;
}

#new-template-form .btn-primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 35px rgba(79, 209, 197, 0.4);
}

#new-template-form .btn-primary:active {
  transform: translateY(-1px);
}

#new-template-form .btn-primary i {
  position: relative;
  z-index: 1;
  transition: transform 0.3s ease;
}

#new-template-form .btn-primary:hover i {
  transform: translateX(3px);
}

#new-template-form .btn-primary span {
  position: relative;
  z-index: 1;
}

/* Dark Mode Modal Adjustments */
body.dark-mode .modal-content {
  background: rgba(20, 20, 30, 0.95);
  border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .form-group input,
body.dark-mode .form-group select,
body.dark-mode .form-group textarea {
  background: rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

body.dark-mode .form-group input:focus,
body.dark-mode .form-group select:focus,
body.dark-mode .form-group textarea:focus {
  background: rgba(0, 0, 0, 0.4);
  border-color: var(--accent);
}

/* Responsive Templates Page */
@media (max-width: 768px) {
  .templates-page {
    padding: 1rem;
  }

  .templates-header {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .templates-header h1 {
    font-size: 1.75rem;
  }

  .templates-header .btn-primary {
    width: 100%;
    min-height: 44px;
  }

  .template-categories {
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  .category-btn {
    flex: 1 1 auto;
    min-width: calc(50% - 0.25rem);
    min-height: 44px;
    padding: 10px 14px;
  }

  .templates-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .template-card {
    padding: 1.5rem;
  }

  .template-actions {
    flex-direction: column;
  }

  .template-actions .btn-primary {
    width: 100%;
    min-height: 44px;
  }
}

/* Responsive Modal */
@media (max-width: 768px) {
  .modal {
    padding: 1rem;
    align-items: flex-end; /* Slide up from bottom on mobile */
  }

  .modal-content {
    padding: 2rem 1.5rem;
    width: 100%;
    max-width: 100%;
    max-height: 90vh;
    border-radius: 24px 24px 0 0;
    margin: 0;
    animation: modalSlideUpMobile 0.3s ease;
  }

  @keyframes modalSlideUpMobile {
    from {
      transform: translateY(100%);
      opacity: 0;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }

  .modal-content h2 {
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
  }

  .close-modal {
    top: 1rem;
    right: 1rem;
    width: 44px;
    height: 44px;
    font-size: 1.5rem;
    min-width: 44px;
    min-height: 44px;
  }

  .form-group {
    gap: 0.75rem;
  }

  .form-group label {
    font-size: 0.9rem;
  }

  .form-group input,
  .form-group select,
  .form-group textarea {
    padding: 14px 16px;
    font-size: 16px; /* Prevent iOS zoom */
    min-height: 44px;
  }

  .form-group textarea {
    min-height: 150px;
  }

  #new-template-form .btn-primary {
    padding: 14px 20px;
    font-size: 1rem;
    min-height: 44px;
    width: 100%;
  }
}

@media (max-width: 480px) {
  .modal-content {
    padding: 1.5rem 1rem;
    border-radius: 20px 20px 0 0;
    max-height: 95vh;
  }

  .modal-content h2 {
    font-size: 1.5rem;
    margin-bottom: 1.25rem;
  }

  .close-modal {
    width: 40px;
    height: 40px;
    font-size: 1.25rem;
  }

  .form-group label {
    font-size: 0.85rem;
  }

  .form-group input,
  .form-group select,
  .form-group textarea {
    padding: 12px 14px;
    font-size: 16px;
  }
}

