/* === Tresor – Secure Credential Vault === */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --brand-color: #2563eb;
  --brand-hover: #1d4ed8;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --warning-bg: #fef3c7;
  --warning-border: #f59e0b;
  --success-bg: #d1fae5;
  --success-border: #059669;
  --error-bg: #fef2f2;
  --error-border: #ef4444;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.08);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', SFMono-Regular, 'Consolas', 'Liberation Mono', Menlo, monospace;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* === Header === */

.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  height: 56px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}

.brand-icon {
  font-size: 1.4rem;
}

.brand-logo {
  height: 28px;
  width: auto;
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* === Main === */

.main {
  flex: 1;
  padding: 32px 24px;
}

.container {
  max-width: 860px;
  margin: 0 auto;
}

/* === Cards === */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.card-narrow {
  max-width: 460px;
  margin-left: auto;
  margin-right: auto;
}

.card-empty {
  text-align: center;
  padding: 48px 28px;
}

.card-icon {
  font-size: 2rem;
  margin-bottom: 12px;
}

.card h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.card h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 12px;
}

/* === Dashboard header === */

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  gap: 16px;
}

.dashboard-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.back-link {
  display: inline-block;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  margin-bottom: 4px;
  transition: color 0.15s;
}

.back-link:hover {
  color: var(--brand-color);
}

/* === Forms === */

.form {
  margin-top: 20px;
}

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

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.form-group small {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.95rem;
  font-family: var(--font);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--brand-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

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

.form-row {
  display: flex;
  gap: 16px;
}

.form-row .form-group {
  flex: 1;
}

.form-group-grow {
  flex: 2 !important;
}

.form-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

.optional {
  font-weight: 400;
  color: var(--text-muted);
}

/* === Buttons === */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font);
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-full {
  width: 100%;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.825rem;
}

.btn-primary {
  background: var(--brand-color);
  color: white;
  border-color: var(--brand-color);
}

.btn-primary:hover {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--bg);
  border-color: var(--text-muted);
}

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
}

/* === Alerts === */

.alert {
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 0.9rem;
  line-height: 1.5;
  border: 1px solid;
}

.alert-error {
  background: var(--error-bg);
  border-color: var(--error-border);
  color: var(--danger);
}

.alert-warning {
  background: var(--warning-bg);
  border-color: var(--warning-border);
  color: #92400e;
}

.alert-success {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: #065f46;
}

/* === Rooms list === */

.rooms-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: -4px -8px;
}

.room-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: background 0.15s;
}

.room-item:hover {
  background: var(--bg);
}

.room-inactive {
  opacity: 0.6;
}

.room-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.room-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.room-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.room-counts {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* === Badges === */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 99px;
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.badge-unread {
  background: var(--brand-color);
  color: white;
  border-color: var(--brand-color);
}

.badge-inactive {
  background: var(--error-bg);
  color: var(--danger);
  border-color: var(--error-border);
}

.badge-expired {
  background: var(--warning-bg);
  color: #92400e;
  border-color: var(--warning-border);
}

/* === Share link === */

.share-link-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 12px 0;
}

.share-link {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  word-break: break-all;
  flex: 1;
  color: var(--text);
}

.room-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* === Submissions === */

.submissions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.submission-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}

.submission-item:last-child {
  border-bottom: none;
}

.submission-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.submission-sender {
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.submission-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.submission-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.submission-final-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.dot-unread {
  background: var(--brand-color);
}

/* === Credentials (decrypted view) === */

.credential-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 16px;
}

.credential-item label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.credential-value {
  font-size: 0.95rem;
}

.credential-value code {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  background: var(--bg);
  padding: 6px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: inline-block;
  word-break: break-all;
}

.credential-value pre {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: var(--bg);
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  white-space: pre-wrap;
  word-break: break-word;
}

.credential-secret {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* === TOTP setup === */

.qr-container {
  text-align: center;
  padding: 24px 0;
}

.qr-code {
  width: 220px;
  height: 220px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.secret-details {
  margin: 16px 0;
  font-size: 0.875rem;
}

.secret-details summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.secret-code {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: var(--bg);
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin: 10px 0 6px;
  word-break: break-all;
  text-align: center;
  letter-spacing: 0.05em;
}

/* === Success page === */

.success-details {
  margin: 20px 0;
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.success-item {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
}

.success-item + .success-item {
  border-top: 1px solid var(--border);
}

.success-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.success-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: #059669;
}

/* === GDPR notice === */

.gdpr-notice {
  max-width: 460px;
  margin: 24px auto 0;
  padding: 20px 24px;
  font-size: 0.825rem;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.gdpr-notice h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.gdpr-notice ul {
  padding-left: 18px;
}

.gdpr-notice li {
  margin-bottom: 4px;
  line-height: 1.5;
}

/* === Security notice === */

.security-notice {
  padding: 14px 18px;
  font-size: 0.85rem;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
  color: #166534;
  margin: 20px 0 4px;
  line-height: 1.5;
}

/* === Text helpers === */

.text-muted {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* === Footer === */

.footer {
  padding: 20px 24px;
  text-align: center;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.footer-inner {
  max-width: 860px;
  margin: 0 auto;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-gdpr {
  margin-top: 4px;
  font-size: 0.75rem;
}

/* === Responsive === */

@media (max-width: 640px) {
  .main {
    padding: 20px 16px;
  }

  .card {
    padding: 20px;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .dashboard-header {
    flex-direction: column;
  }

  .submission-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .submission-actions {
    margin-top: 8px;
  }

  .credential-secret {
    flex-direction: column;
    align-items: flex-start;
  }

  .share-link-box {
    flex-direction: column;
  }

  .submission-final-actions {
    flex-direction: column;
    width: 100%;
  }

  .submission-final-actions .btn {
    width: 100%;
  }
}

/* === Vault room (customer-facing) === */

.vault-header {
  margin-bottom: 24px;
}

.vault-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.instructions-text {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
}

.vault-submissions {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 12px;
}

.vault-submission-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.vault-submission-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.vault-submission-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* === Admin room instructions detail === */

.room-instructions-detail {
  margin-top: 12px;
  font-size: 0.875rem;
}

.room-instructions-detail summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.room-instructions-text {
  margin-top: 8px;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

/* === Header actions === */

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* === Settings: color input === */

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

.color-input-row input[type="color"] {
  width: 42px;
  height: 38px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--surface);
}

.color-input-row input[type="text"] {
  flex: 1;
}

.logo-preview {
  margin-bottom: 16px;
}

/* === Settings: templates === */

.templates-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.template-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  gap: 12px;
}

.template-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.template-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.template-preview {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.new-template-details {
  margin-top: 12px;
}

.new-template-details summary {
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--brand-color);
}

/* === Template selector on dashboard === */

.template-selector {
  margin-bottom: 8px;
}

.template-selector select {
  width: 100%;
  padding: 8px 12px;
  font-size: 0.9rem;
  font-family: var(--font);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.template-selector select:focus {
  outline: none;
  border-color: var(--brand-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* === User management === */

.users-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.user-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  gap: 12px;
}

.user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.user-name {
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.badge-owner {
  background: var(--brand-color);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}

.badge-pending {
  background: #f59e0b;
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}

/* === Logo upload preview === */

.logo-preview-box {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
}

.logo-preview-img {
  max-height: 48px;
  max-width: 200px;
  object-fit: contain;
}

.logo-preview-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}
