/* ============================================================
   Settings Page — Additional Styles
   ============================================================ */

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

.settings-main {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-secondary);
}

.settings-header {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  padding: 20px 32px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.settings-header .back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius);
  transition: all var(--transition);
  text-decoration: none;
}
.settings-header .back-link:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}
.settings-header h1 {
  font-size: 20px;
  font-weight: 700;
}

.settings-body {
  max-width: 800px;
  margin: 0 auto;
  padding: 32px;
}

/* ---------- Section Cards ---------- */
.settings-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.settings-card h2 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}
.settings-card .card-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.5;
}

/* ---------- Account List ---------- */
.account-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.account-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-secondary);
  transition: all var(--transition);
}
.account-card:hover {
  border-color: #d1d5db;
  box-shadow: var(--shadow-sm);
}

.account-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.account-icon.gmail    { background: #fce8e6; color: #ea4335; }
.account-icon.outlook  { background: #e8f0fe; color: #0078d4; }
.account-icon.imap     { background: #f0f0f0; color: #555; }
.account-icon svg { width: 22px; height: 22px; }

.account-info {
  flex: 1;
  min-width: 0;
}
.account-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.account-email {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.status-badge.verified   { background: #d1fae5; color: #059669; }
.status-badge.unverified { background: #fef3c7; color: #d97706; }
.status-badge.error      { background: #fee2e2; color: #dc2626; }
.status-badge svg { width: 12px; height: 12px; }
.status-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.status-badge.verified .dot   { background: #059669; }
.status-badge.unverified .dot { background: #d97706; }
.status-badge.error .dot      { background: #dc2626; }

.provider-tag {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 4px;
  background: #f3f4f6;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.account-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* ---------- Empty State ---------- */
.accounts-empty {
  text-align: center;
  padding: 48px 20px;
  border: 2px dashed var(--border);
  border-radius: 12px;
  margin-bottom: 20px;
}
.accounts-empty svg {
  width: 48px;
  height: 48px;
  color: #d1d5db;
  margin-bottom: 12px;
}
.accounts-empty h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}
.accounts-empty p {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ---------- Add Account Modal ---------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
.modal-overlay.open { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--bg-primary);
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,.25);
  animation: modalSlide 0.25s ease;
}

@keyframes modalSlide {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px 0;
}
.modal-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.modal-body {
  padding: 20px 28px 28px;
}

/* ---------- Provider Picker ---------- */
.provider-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.provider-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 12px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--bg-primary);
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}
.provider-option:hover {
  border-color: #d1d5db;
  background: var(--bg-secondary);
}
.provider-option.selected {
  border-color: var(--accent);
  background: var(--accent-light);
}
.provider-option .prov-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.provider-option .prov-icon.gmail   { background: #fce8e6; color: #ea4335; }
.provider-option .prov-icon.outlook { background: #e8f0fe; color: #0078d4; }
.provider-option .prov-icon.imap    { background: #f0f0f0; color: #555; }
.provider-option .prov-name {
  font-size: 13px;
  font-weight: 600;
}
.provider-option .prov-desc {
  font-size: 11px;
  color: var(--text-secondary);
}

/* ---------- Form inside modal ---------- */
.modal-form .form-group {
  margin-bottom: 16px;
}
.modal-form .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.modal-form .form-help {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.4;
}
.modal-form .form-help a {
  color: var(--accent);
}

.imap-fields {
  display: none;
}
.imap-fields.show {
  display: block;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 28px 24px;
}

/* Verify result */
.verify-result {
  display: none;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.5;
}
.verify-result.success {
  display: block;
  background: #d1fae5;
  color: #065f46;
}
.verify-result.error {
  display: block;
  background: #fee2e2;
  color: #991b1b;
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.spinner.dark {
  border-color: rgba(0,0,0,.15);
  border-top-color: var(--accent);
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Delete Confirmation ---------- */
.confirm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.confirm-overlay.open { display: flex; }
.confirm-box {
  background: var(--bg-primary);
  border-radius: 12px;
  padding: 28px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  text-align: center;
}
.confirm-box h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
}
.confirm-box p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.5;
}
.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .settings-body { padding: 20px 16px; }
  .settings-card { padding: 20px; }
  .account-card { flex-wrap: wrap; }
  .account-actions { width: 100%; justify-content: flex-end; margin-top: 8px; }
  .provider-picker { grid-template-columns: 1fr; }
  .modal-form .form-row { grid-template-columns: 1fr; }
  .settings-layout .sidebar { display: none; }
}

/* ---------- Import Modal ---------- */
.import-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.import-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-primary);
  cursor: pointer;
  transition: all 0.15s ease;
}
.import-option:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}
.import-option.selected {
  border-color: var(--accent);
  background: var(--accent-light);
  box-shadow: 0 0 0 2px rgba(59,130,246,0.2);
}
.import-option-days {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}
.import-option-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}
.import-option.selected .import-option-days,
.import-option:hover .import-option-days {
  color: var(--accent);
}
.spinner-lg {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@media (max-width: 480px) {
  .import-options { grid-template-columns: repeat(2, 1fr); }
}
