body {
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  background: #0d1117;
  color: #ffffff;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Main Content */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
}

/* Login Section */
.login-section {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 64px);
  width: 100%;
}

.login-container {
  max-width: 400px;
  width: 90%;
  padding: 24px;
  background: #1e1e1e;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  text-align: center;
}

/* Admin Container */
.admin-container {
  max-width: 960px;
  width: 90%;
  margin: 24px auto;
  padding: 24px;
  background: #1e1e1e;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Headings */
.login-section h2 {
  font-size: 26px;
  font-weight: 600;
  color: #4fc3f7;
  margin-bottom: 20px;
}

.admin-section h2, .template-upload h3, .chat-requests h3, .chat-reply h3 {
  font-size: 20px;
  font-weight: 500;
  color: #4fc3f7;
  margin-bottom: 16px;
  text-align: center;
}

.template-card h3, .chat-request-card h3, .custom-request-card h3 {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 10px;
}

/* Tabs */
.admin-tabs {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.tab-button {
  padding: 10px 20px;
  background: #4fc3f71a;
  color: #4fc3f7;
  border: 1px solid #4fc3f7;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.tab-button.active {
  background: #4fc3f7;
  color: #000;
  transform: translateY(-2px);
  box-shadow: 0 2px 6px rgba(79, 195, 247, 0.3);
}

.tab-button:hover {
  background: #4fc3f7;
  color: #000;
  transform: translateY(-2px);
}

/* Sections */
.admin-section {
  display: none;
}

.admin-section.active {
  display: block;
}

/* Forms */
.form-group {
  margin-bottom: 16px;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #ffffff;
  margin-bottom: 8px;
}

.template-upload form, .email-form, .login-form, .chat-reply-form, #editTemplateForm {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 500px;
  margin: 0 auto;
  background: #1e1e1e;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.template-upload input, .template-upload select, .template-upload textarea,
.email-form input, .email-form select, .login-form input, .chat-reply-form textarea,
#editTemplateForm input, #editTemplateForm select, #editTemplateForm textarea {
  padding: 12px;
  background: #2a2a2a;
  color: #ffffff;
  border: 2px solid #4fc3f7;
  border-radius: 8px;
  font-size: 13px;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
  box-sizing: border-box;
}

.template-upload input:focus, .template-upload select:focus, .template-upload textarea:focus,
.email-form input:focus, .email-form select:focus, .login-form input:focus, .chat-reply-form textarea:focus,
#editTemplateForm input:focus, #editTemplateForm select:focus, #editTemplateForm textarea:focus {
  outline: none;
  border-color: #03a9f4;
  box-shadow: 0 0 6px rgba(3, 169, 244, 0.4);
}

.chat-reply-form textarea, .template-upload textarea, #editTemplateForm textarea {
  min-height: 120px;
  resize: vertical;
}

/* File Inputs */
.file-input-wrapper {
  position: relative;
  width: 100%;
}

.file-input-wrapper input[type="file"] {
  display: none;
}

.file-input-label {
  display: block;
  padding: 12px;
  background: #4fc3f7;
  color: #000;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  text-align: center;
  font-size: 13px;
  transition: background-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.file-input-label:hover {
  background: #03a9f4;
  transform: translateY(-2px);
  box-shadow: 0 2px 6px rgba(3, 169, 244, 0.3);
}

#imagePreview, #editImagePreview {
  margin-top: 12px;
}

#imagePreview img, #editImagePreview img {
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid #4fc3f7;
}

/* Template Grid */
.template-grid, #templateList {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  margin-top: 24px;
  justify-items: center;
}

.template-card {
  background: #2a2a2a;
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
  width: 100%;
  max-width: 260px;
  text-align: center;
}

.template-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.template-card img {
  width: 100%;
  max-width: 140px;
  height: auto;
  border-radius: 8px;
  margin-bottom: 12px;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.template-card p {
  font-size: 13px;
  color: #cccccc;
  margin-bottom: 10px;
}

.template-card a {
  color: #4fc3f7;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  display: inline-block;
  margin-bottom: 12px;
}

.template-card a:hover {
  text-decoration: underline;
}

/* Template Card Buttons */
.template-card .button-container {
  display: flex;
  flex-direction: row;
  gap: 10px;
  justify-content: center;
  margin-top: 10px;
}

.template-card .btn {
  padding: 8px;
  font-size: 12px;
  max-width: 120px;
}

/* Chat and Custom Request Cards */
.chat-request-card, .custom-request-card {
  background: #2a2a2a;
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
  margin-bottom: 24px;
  width: 100%;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.custom-request-card ul {
  list-style: none;
  padding: 0;
  margin: 12px 0;
}

.custom-request-card ul li {
  font-size: 13px;
  color: #cccccc;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.custom-request-card ul li a {
  color: #4fc3f7;
  text-decoration: none;
}

.custom-request-card ul li a:hover {
  text-decoration: underline;
}

/* Buttons */
.btn {
  padding: 12px;
  background: #4fc3f7;
  color: #000;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.2s, box-shadow 0.2s;
  width: 100%;
  max-width: 200px;
  margin: 10px auto;
  display: block;
}

.btn:hover {
  background: #03a9f4;
  transform: translateY(-2px);
  box-shadow: 0 2px 6px rgba(3, 169, 244, 0.3);
}

.btn:disabled {
  background: #4fc3f77a;
  cursor: not-allowed;
  transform: none;
}

.btn-logout {
  background: #ff4d4d;
  width: auto;
  padding: 10px 20px;
  margin-left: auto;
  display: block;
}

.btn-logout:hover {
  background: #e60000;
  transform: translateY(-2px);
  box-shadow: 0 2px 6px rgba(230, 0, 0, 0.3);
}

.btn-cancel, .btn-delete {
  background: #ff4d4d;
}

.btn-cancel:hover, .btn-delete:hover {
  background: #e60000;
  transform: translateY(-2px);
  box-shadow: 0 2px 6px rgba(230, 0, 0, 0.3);
}

/* Loading Popup */
.loading-popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.loading-content {
  background: #1e1e1e;
  padding: 24px;
  border-radius: 12px;
  text-align: center;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.spinner {
  border: 3px solid #4fc3f7;
  border-top: 3px solid #03a9f4;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  animation: spin 1s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Result Messages */
.result.success {
  color: #4fc3f7;
  font-weight: 600;
  padding: 12px;
  border-radius: 8px;
  background: #4fc3f71a;
  margin: 16px auto;
  max-width: 500px;
}

.result.error {
  color: #ff4d4d;
  font-weight: 600;
  padding: 12px;
  border-radius: 8px;
  background: #ff4d4d1a;
  margin: 16px auto;
  max-width: 500px;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  overflow-y: auto;
}

.modal-content {
  background: #1e1e1e;
  padding: 24px;
  border-radius: 12px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  text-align: center;
}

.modal-content p {
  font-size: 14px;
  margin-bottom: 24px;
}

.modal-content button {
  margin: 10px;
}

/* Edit Template Modal */
#editTemplateModal {
  overflow-y: auto;
  max-height: 90vh;
}

#editTemplateModal .modal-content {
  background: #1e1e1e;
  padding: 24px;
  border-radius: 12px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  max-height: 80vh;
  overflow-y: auto;
}

#editTemplateModal h2 {
  font-size: 20px;
  font-weight: 500;
  color: #4fc3f7;
  margin-bottom: 20px;
}

#editTemplateForm {
  max-height: none;
  overflow: visible;
}

#editTemplateForm .form-group {
  margin-bottom: 16px;
}

#editTemplateForm .form-group label {
  font-size: 13px;
  font-weight: 500;
  color: #ffffff;
  margin-bottom: 8px;
  text-align: left;
}

#editTemplateForm input, #editTemplateForm select, #editTemplateForm textarea {
  padding: 12px;
  background: #2a2a2a;
  color: #ffffff;
  border: 2px solid #4fc3f7;
  border-radius: 8px;
  font-size: 13px;
  width: 100%;
  box-sizing: border-box;
}

#editTemplateForm input:focus, #editTemplateForm select:focus, #editTemplateForm textarea:focus {
  outline: none;
  border-color: #03a9f4;
  box-shadow: 0 0 6px rgba(3, 169, 244, 0.4);
}

/* Mobile Styles */
@media (max-width: 600px) {
  body {
    padding: 0;
  }

  main {
    padding: 0;
  }

  .admin-container, .login-container {
    padding: 16px;
    margin: 16px auto;
  }

  .login-section h2 {
    font-size: 22px;
  }

  .admin-section h2, .template-upload h3, .chat-requests h3, .chat-reply h3, #editTemplateModal h2 {
    font-size: 18px;
  }

  .admin-tabs {
    flex-direction: column;
    gap: 10px;
  }

  .tab-button {
    padding: 8px 16px;
    font-size: 13px;
  }

  .btn-logout {
    width: 100%;
    padding: 8px;
  }

  .template-upload form, .email-form, .login-form, .chat-reply-form, #editTemplateForm {
    gap: 10px;
    padding: 16px;
  }

  .template-upload input, .template-upload select, .template-upload textarea,
  .email-form input, .email-form select, .login-form input, .chat-reply-form textarea,
  #editTemplateForm input, #editTemplateForm select, #editTemplateForm textarea {
    padding: 10px;
    font-size: 12px;
  }

  .file-input-label, .btn {
    padding: 10px;
    font-size: 12px;
  }

  .template-grid, #templateList {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .template-card, .chat-request-card, .custom-request-card {
    padding: 12px;
    max-width: 100%;
  }

  .template-card h3, .chat-request-card h3, .custom-request-card h3 {
    font-size: 14px;
  }

  .template-card p, .chat-request-card p, .custom-request-card p {
    font-size: 12px;
  }

  .template-card .button-container {
    flex-direction: column;
    gap: 8px;
  }

  .template-card .btn {
    padding: 8px;
    font-size: 12px;
    max-width: 100%;
  }

  .loading-content, .modal-content, #editTemplateModal .modal-content {
    padding: 16px;
  }

  .spinner {
    width: 24px;
    height: 24px;
  }

  .modal, #editTemplateModal {
    overflow-y: auto;
  }

  #editTemplateModal .modal-content {
    padding: 16px;
    max-height: 85vh;
    overflow-y: auto;
  }
}

/* Desktop-Specific Styles */
@media (min-width: 601px) {
  .template-card .btn {
    padding: 8px;
    font-size: 12px;
    max-width: 120px;
  }
  }
