* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
  background: #f5f5f5;
  color: #333;
}

.email-settings-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.settings-sidebar {
  width: 220px;
  background: #ffffff;
  border-right: 1px solid #e0e0e0;
  overflow-y: auto;
  flex-shrink: 0;
}

.embedded .settings-sidebar { display: none; }

/* Embedded mode adjustments for better iframe display */
.embedded .email-settings-main {
  padding: 20px 25px;
}

.embedded .email-settings-header {
  flex-direction: column;
  align-items: flex-start;
  gap: 15px;
}

.embedded .header-actions {
  width: 100%;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.settings-nav { padding: 15px 0; }

.settings-nav-item,
.settings-nav-subitem {
  display: block;
  padding: 10px 20px;
  color: #333;
  text-decoration: none;
  font-size: 13px;
  transition: background 0.2s;
  cursor: pointer;
  border-left: 3px solid transparent;
}

.settings-nav-item:hover,
.settings-nav-subitem:hover { background: #f5f5f5; }

.settings-nav-section { margin-top: 5px; }

.settings-nav-item.active-section {
  font-weight: 600;
  color: #2c5282;
  background: #e6f2ff;
  border-left-color: #4a90e2;
  cursor: default;
}

.settings-nav-subitem { padding: 8px 20px 8px 40px; color: #666; font-size: 12px; }

.settings-nav-subitem.active { background: #e6f2ff; color: #2c5282; font-weight: 500; border-left-color: #4a90e2; }

.email-settings-main {
  flex: 1;
  background: #ffffff;
  overflow-y: auto;
  padding: 30px 40px;
}

.email-settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.email-settings-title { margin: 0; font-size: 20px; font-weight: 700; }
.email-settings-subtitle { margin: 4px 0 0; color: #607d8b; font-size: 13px; }

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

.btn {
  padding: 10px 16px;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  min-width: fit-content;
}

.btn.primary { background: #1976d2; color: #fff; }
.btn.secondary { background: #455a64; color: #fff; }
.btn:hover { opacity: 0.92; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Responsive button sizing for embedded mode */
@media (max-width: 768px) {
  .embedded .btn {
    padding: 8px 12px;
    font-size: 12px;
  }
  
  .embedded .header-actions {
    gap: 8px;
  }
}

/* Card footer styling */
.card-footer {
  padding: 15px 20px;
  background: #fafafa;
  border-top: 1px solid #e0e0e0;
}

/* Embedded mode card footer adjustments */
.embedded .card-footer {
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
}

.embedded .card-footer .btn {
  width: 100%;
  justify-content: center;
}

.card {
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  margin-bottom: 18px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid #e0e0e0;
}

.card-header h2 { margin: 0; font-size: 16px; }

.card-body { padding: 16px; }

.card-actions { display: flex; gap: 10px; align-items: center; }

.card-actions input { flex: 1; padding: 10px; border: 1px solid #ccc; border-radius: 4px; font-size: 13px; }

.form-row { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #37474f; }
.form-row input, .form-row textarea, .form-row select {
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 13px;
}

.form-row.checkbox-row { flex-direction: row; align-items: center; gap: 10px; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.editor-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.toolbar-left, .toolbar-right { display: flex; gap: 8px; align-items: center; }

.tool-btn {
  padding: 8px 12px;
  border: 1px solid #cfd8dc;
  background: #fafafa;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
}

.tool-btn:hover { background: #eef3f7; }

.editor {
  border: 1px solid #cfd8dc;
  border-radius: 4px;
  min-height: 240px;
  padding: 12px;
  font-size: 14px;
  line-height: 1.5;
  background: #fff;
}

.editor:focus { outline: 2px solid #90caf9; }

#templateList { display: flex; flex-direction: column; gap: 8px; }

.template-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 10px;
}

.template-row .meta { display: flex; flex-direction: column; }

.template-row .actions { display: flex; gap: 8px; }

.btn.small { padding: 6px 10px; font-size: 12px; }

.tag-reference { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.tag-reference h3 { margin-top: 0; }
.tag-reference ul { list-style: none; padding-left: 0; margin: 0; }
.tag-reference li { padding: 4px 0; font-size: 13px; color: #455a64; }

.hint { font-size: 12px; color: #607d8b; padding: 0 16px 12px; }

.status-text { font-size: 12px; color: #455a64; margin-left: 10px; }

@media (max-width: 768px) {
  .email-settings-container { flex-direction: column; }
  .settings-sidebar { display: none; }
  .email-settings-main { padding: 20px; }
}
