/* =====================================================
   FORM BUILDER FEATURE - STYLES
   Matches class names used in: forms.html, build-form.html,
   form-page.html, form-responses.html
   ===================================================== */

/* =====================================================
   SHARED LAYOUT
   ===================================================== */

.forms-container {
  margin-left: 270px;
  padding: 30px 40px;
  min-height: 100vh;
  box-sizing: border-box;
  flex-grow: 1;
  width: 100%;
  max-width: calc(100vw - 270px);
}

/* =====================================================
   FORMS LISTING PAGE (forms.html)
   ===================================================== */

/* Header */
.forms-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  flex-wrap: wrap;
  gap: 15px;
}

.forms-header h1 {
  font-size: 28px;
  font-weight: 700;
  margin: 0;
}

/* Create Button */
.create-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  background-color: #2F5061;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.create-btn:hover {
  background-color: #234559;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transform: translateY(-1px);
}

body.dark-mode .create-btn {
  background-color: #4297A0;
}

body.dark-mode .create-btn:hover {
  background-color: #3a8695;
}

/* Search Section */
.search-section {
  margin-bottom: 24px;
}

.search-container {
  max-width: 500px;
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 0 14px;
  transition: border-color 0.2s;
}

body.dark-mode .search-input-wrapper {
  background-color: #2d2d2d;
  border-color: #444;
}

.search-input-wrapper:focus-within {
  border-color: #2F5061;
  box-shadow: 0 0 0 3px rgba(47, 80, 97, 0.1);
}

body.dark-mode .search-input-wrapper:focus-within {
  border-color: #4297A0;
  box-shadow: 0 0 0 3px rgba(66, 151, 160, 0.15);
}

.search-icon {
  color: #999;
  font-size: 14px;
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  padding: 12px 0;
  font-size: 14px;
  font-family: inherit;
  background: transparent;
  color: inherit;
}

.search-input::placeholder {
  color: #aaa;
}

body.dark-mode .search-input::placeholder {
  color: #777;
}

.clear-search-btn {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  padding: 4px;
  font-size: 12px;
  flex-shrink: 0;
}

.clear-search-btn:hover {
  color: #333;
}

/* Responses search (form-responses.html uses just .search-input without wrapper) */
.responses-search {
  margin-bottom: 20px;
}

.responses-search .search-input {
  width: 100%;
  max-width: 500px;
  padding: 12px 16px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: white;
  color: #333;
  box-sizing: border-box;
}

body.dark-mode .responses-search .search-input {
  background: #2d2d2d;
  border-color: #444;
  color: #e0e0e0;
}

.responses-search .search-input:focus {
  outline: none;
  border-color: #2F5061;
  box-shadow: 0 0 0 3px rgba(47, 80, 97, 0.1);
}

/* Forms Grid */
.forms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

/* Form Card */
.form-card {
  background-color: white;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  padding: 24px;
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease;
  border: 1px solid #eee;
}

body.dark-mode .form-card {
  background-color: #2d2d2d;
  border-color: #404040;
}

.form-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.form-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
  gap: 10px;
}

.form-name {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  flex: 1;
  line-height: 1.3;
}

.form-name a {
  color: #2F5061;
  text-decoration: none;
}

.form-name a:hover {
  color: #4297A0;
  text-decoration: underline;
}

body.dark-mode .form-name a {
  color: #7ec8d0;
}

.form-badge {
  display: inline-block;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.badge-active {
  background-color: #e8f5e9;
  color: #2e7d32;
}

body.dark-mode .badge-active {
  background-color: rgba(76, 175, 80, 0.15);
  color: #81c784;
}

.badge-closed {
  background-color: #ffebee;
  color: #c62828;
}

body.dark-mode .badge-closed {
  background-color: rgba(229, 127, 132, 0.15);
  color: #e8a0a7;
}

/* Card Body */
.form-card-body {
  flex: 1;
  margin-bottom: 16px;
}

.form-description {
  font-size: 13px;
  color: #666;
  margin: 0 0 14px 0;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

body.dark-mode .form-description {
  color: #aaa;
}

.form-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: #888;
}

body.dark-mode .form-meta {
  color: #999;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Settings Tags (on cards) */
.form-settings-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.form-settings-tags .setting-tag {
  font-size: 11px;
  padding: 4px 10px;
}

/* Card Actions */
.form-card-actions {
  display: flex;
  gap: 8px;
  border-top: 1px solid #eee;
  padding-top: 14px;
}

body.dark-mode .form-card-actions {
  border-top-color: #404040;
}

.action-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: white;
  color: #555;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

body.dark-mode .action-btn {
  background: #3a3a3a;
  border-color: #555;
  color: #ccc;
}

.action-btn:hover {
  background-color: #f5f5f5;
  border-color: #bbb;
}

body.dark-mode .action-btn:hover {
  background: #444;
  border-color: #666;
}

.delete-form-btn:hover {
  background-color: #ffebee;
  border-color: #E57F84;
  color: #c62828;
}

body.dark-mode .delete-form-btn:hover {
  background-color: rgba(229, 127, 132, 0.15);
  color: #e8a0a7;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 20px;
  color: #999;
}

.empty-state i {
  font-size: 56px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state h2,
.empty-state h3 {
  font-size: 20px;
  font-weight: 600;
  color: #555;
  margin: 0 0 8px 0;
}

body.dark-mode .empty-state h2,
body.dark-mode .empty-state h3 {
  color: #bbb;
}

.empty-state p {
  font-size: 14px;
  color: #888;
  margin: 0 0 20px 0;
}

/* =====================================================
   FORM BUILDER (build-form.html)
   ===================================================== */

.back-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #2F5061;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 20px;
}

.back-button:hover {
  color: #4297A0;
}

body.dark-mode .back-button {
  color: #7ec8d0;
}

.form-builder {
  max-width: 800px;
}

.form-builder h1 {
  font-size: 26px;
  font-weight: 700;
  margin: 0 0 24px 0;
}

/* Form Settings (name + description card) */
.form-settings {
  background-color: white;
  border-radius: 10px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border: 1px solid #eee;
}

body.dark-mode .form-settings {
  background-color: #2d2d2d;
  border-color: #404040;
}

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

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #333;
}

body.dark-mode .form-group label {
  color: #ddd;
}

.form-group input[type="text"],
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: white;
  color: #333;
  box-sizing: border-box;
  transition: border-color 0.2s;
}

body.dark-mode .form-group input[type="text"],
body.dark-mode .form-group textarea {
  background: #3a3a3a;
  border-color: #555;
  color: #e0e0e0;
}

.form-group input[type="text"]:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #2F5061;
  box-shadow: 0 0 0 3px rgba(47, 80, 97, 0.08);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

/* Question List */
.question-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 20px;
}

/* Question Item Card */
.question-item {
  background-color: white;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 20px;
  transition: all 0.2s ease;
}

body.dark-mode .question-item {
  background-color: #2d2d2d;
  border-color: #404040;
}

.question-item:hover {
  border-color: #4297A0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

/* Question Header (drag handle + main area) */
.question-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.question-drag-handle {
  flex-shrink: 0;
  cursor: grab;
  font-size: 18px;
  color: #ccc;
  padding: 8px 2px;
  user-select: none;
}

.question-drag-handle:active {
  cursor: grabbing;
}

body.dark-mode .question-drag-handle {
  color: #666;
}

.question-main {
  flex: 1;
  min-width: 0;
}

/* Question label input */
.question-label {
  width: 100%;
  padding: 10px 14px;
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: white;
  color: #333;
  box-sizing: border-box;
  margin-bottom: 12px;
  transition: border-color 0.2s;
}

body.dark-mode .question-label {
  background: #3a3a3a;
  border-color: #555;
  color: #e0e0e0;
}

.question-label:focus {
  outline: none;
  border-color: #2F5061;
  box-shadow: 0 0 0 3px rgba(47, 80, 97, 0.08);
}

.question-label::placeholder {
  color: #aaa;
  font-weight: 400;
}

/* Question Controls Row */
.question-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.question-type-select {
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: white;
  color: #333;
  cursor: pointer;
}

body.dark-mode .question-type-select {
  background: #3a3a3a;
  border-color: #555;
  color: #e0e0e0;
}

.required-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #666;
  cursor: pointer;
  user-select: none;
}

body.dark-mode .required-toggle {
  color: #aaa;
}

.required-toggle input[type="checkbox"] {
  cursor: pointer;
  accent-color: #2F5061;
}

.delete-question-btn {
  padding: 6px 12px;
  font-size: 13px;
  font-family: inherit;
  background-color: transparent;
  color: #c62828;
  border: 1px solid #ddd;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  margin-left: auto;
}

.delete-question-btn:hover {
  background-color: #ffebee;
  border-color: #E57F84;
}

body.dark-mode .delete-question-btn {
  color: #e8a0a7;
  border-color: #555;
}

body.dark-mode .delete-question-btn:hover {
  background-color: rgba(229, 127, 132, 0.15);
}

/* Question Options (for multiple_choice, checkbox, dropdown) */
.question-options {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #eee;
}

body.dark-mode .question-options {
  border-top-color: #404040;
}

.options-label {
  font-size: 13px;
  font-weight: 600;
  color: #888;
  margin-bottom: 10px;
}

body.dark-mode .options-label {
  color: #999;
}

.option-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.option-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.option-input {
  flex: 1;
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: white;
  color: #333;
}

body.dark-mode .option-input {
  background: #3a3a3a;
  border-color: #555;
  color: #e0e0e0;
}

.option-input:focus {
  outline: none;
  border-color: #2F5061;
}

.remove-option-btn {
  padding: 6px 10px;
  background: transparent;
  border: 1px solid #ddd;
  color: #c62828;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
}

.remove-option-btn:hover {
  background-color: #ffebee;
  border-color: #E57F84;
}

.remove-option-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

body.dark-mode .remove-option-btn {
  border-color: #555;
  color: #e8a0a7;
}

.add-option-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-family: inherit;
  background: transparent;
  color: #2F5061;
  border: 1px dashed #2F5061;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.add-option-btn:hover {
  background-color: #2F5061;
  color: white;
  border-style: solid;
}

body.dark-mode .add-option-btn {
  color: #4297A0;
  border-color: #4297A0;
}

body.dark-mode .add-option-btn:hover {
  background-color: #4297A0;
  color: white;
}

/* Add Question Button */
.add-question-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  border: 2px dashed #2F5061;
  background: transparent;
  color: #2F5061;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 24px;
}

.add-question-btn:hover {
  background-color: #2F5061;
  color: white;
  border-style: solid;
}

body.dark-mode .add-question-btn {
  border-color: #4297A0;
  color: #4297A0;
}

body.dark-mode .add-question-btn:hover {
  background-color: #4297A0;
  color: white;
}

/* Form Actions (Save / Cancel) */
.form-actions {
  display: flex;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.btn-primary {
  background-color: #2F5061;
  color: white;
}

.btn-primary:hover {
  background-color: #234559;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  transform: translateY(-1px);
}

body.dark-mode .btn-primary {
  background-color: #4297A0;
}

body.dark-mode .btn-primary:hover {
  background-color: #3a8695;
}

.btn-secondary {
  background-color: #4297A0;
  color: white;
}

.btn-secondary:hover {
  background-color: #3a8695;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  transform: translateY(-1px);
}

/* =====================================================
   SETTINGS SUMMARY TAGS (form-responses.html)
   ===================================================== */

.settings-summary {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.setting-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 20px;
  white-space: nowrap;
}

.setting-tag i {
  font-size: 12px;
}

.setting-tag-anonymous {
  background-color: #e3f2fd;
  color: #1565c0;
}

body.dark-mode .setting-tag-anonymous {
  background-color: rgba(21, 101, 192, 0.15);
  color: #64b5f6;
}

.setting-tag-identity {
  background-color: #e8f5e9;
  color: #2e7d32;
}

body.dark-mode .setting-tag-identity {
  background-color: rgba(76, 175, 80, 0.15);
  color: #81c784;
}

.setting-tag-enddate {
  background-color: #fff3e0;
  color: #e65100;
}

body.dark-mode .setting-tag-enddate {
  background-color: rgba(230, 81, 0, 0.15);
  color: #ffb74d;
}

.setting-tag-expired {
  background-color: #ffebee;
  color: #c62828;
}

body.dark-mode .setting-tag-expired {
  background-color: rgba(198, 40, 40, 0.15);
  color: #ef9a9a;
}

.setting-tag-limit {
  background-color: #f3e5f5;
  color: #6a1b9a;
}

body.dark-mode .setting-tag-limit {
  background-color: rgba(106, 27, 154, 0.15);
  color: #ce93d8;
}

/* =====================================================
   FORM RESPONSES PAGE (form-responses.html)
   ===================================================== */

.responses-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 15px;
}

.responses-header h1 {
  font-size: 26px;
  font-weight: 700;
  margin: 0;
}

.response-count {
  font-size: 13px;
  color: #888;
  margin-top: 4px;
}

body.dark-mode .response-count {
  color: #999;
}

.responses-actions {
  display: flex;
  gap: 10px;
}

.export-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  background-color: #2e7d32;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.export-btn:hover {
  background-color: #1b5e20;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  transform: translateY(-1px);
}

/* Response Table */
.responses-table-wrapper {
  background-color: white;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  overflow-x: auto;
  border: 1px solid #eee;
}

body.dark-mode .responses-table-wrapper {
  background-color: #2d2d2d;
  border-color: #404040;
}

.responses-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.responses-table thead {
  background-color: #f5f7f8;
}

body.dark-mode .responses-table thead {
  background-color: #3a3a3a;
}

.responses-table th {
  padding: 14px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  color: #555;
  border-bottom: 2px solid #e0e0e0;
  white-space: nowrap;
}

body.dark-mode .responses-table th {
  color: #bbb;
  border-bottom-color: #444;
}

.responses-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  color: #333;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.dark-mode .responses-table td {
  color: #ddd;
  border-bottom-color: #3a3a3a;
}

.responses-table tbody tr {
  transition: background-color 0.15s;
}

.responses-table tbody tr:hover {
  background-color: #f9fbfc;
}

body.dark-mode .responses-table tbody tr:hover {
  background-color: #333;
}

.responses-table tbody tr:nth-child(even) {
  background-color: #fafafa;
}

body.dark-mode .responses-table tbody tr:nth-child(even) {
  background-color: #2a2a2a;
}

/* =====================================================
   RESPONSIVE
   ===================================================== */

@media (max-width: 1200px) {
  .forms-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .forms-container {
    margin-left: 0;
    padding: 16px;
  }

  .forms-grid {
    grid-template-columns: 1fr;
  }

  .forms-header {
    flex-direction: column;
    align-items: stretch;
  }

  .form-builder {
    max-width: 100%;
  }

  .question-controls {
    flex-direction: column;
    align-items: stretch;
  }

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

  .responses-header {
    flex-direction: column;
    align-items: stretch;
  }
}
