/* === Brand Colors === */
/* Primary: #005249 (green) | Accent: #d4ad3a (yellow) */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f0f2f5;
  color: #1a1a2e;
  line-height: 1.5;
  padding: 20px;
}

header {
  text-align: center;
  margin-bottom: 24px;
}

.logo-placeholder {
  width: 60px;
  height: 60px;
  margin: 0 auto 8px;
  /* Placeholder for future logo — add background-image here */
}

header h1 {
  font-size: 1.8rem;
  color: #005249;
}

header p {
  color: #666;
}

nav {
  margin-top: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

nav a {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 4px;
  text-decoration: none;
  font-size: 0.9rem;
  color: #005249;
  background: #e6f0ef;
}

nav a:hover {
  background: #cce0dd;
}

nav a.active {
  background: #005249;
  color: #fff;
}

.nav-admin-link a {
  background: #d4ad3a;
  color: #333;
  font-weight: 600;
}

.nav-admin-link a:hover {
  background: #c09a2e;
}

.nav-spacer {
  flex: 1;
}

.user-info {
  font-size: 0.85rem;
  color: #005249;
  font-weight: 600;
}

.btn-logout {
  background: transparent;
  color: #005249;
  border: 1px solid #005249;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
}

.btn-logout:hover {
  background: #005249;
  color: #fff;
}

main {
  max-width: 900px;
  margin: 0 auto;
}

.card {
  background: #fff;
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.card h2 {
  margin-bottom: 16px;
  color: #005249;
  font-size: 1.2rem;
}

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

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 0.9rem;
}

.form-group input[type="tel"],
.form-group input[type="url"],
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.95rem;
}

.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.95rem;
  font-family: "Consolas", "Courier New", monospace;
  resize: vertical;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #005249;
  box-shadow: 0 0 0 2px rgba(0, 82, 73, 0.15);
}

.field-hint {
  display: block;
  font-size: 0.78rem;
  color: #888;
  margin-top: 4px;
}

.form-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.form-row .form-group {
  flex: 1;
  min-width: 140px;
}

.separator {
  text-align: center;
  color: #999;
  margin: 10px 0;
  font-size: 0.85rem;
}

button {
  background: #005249;
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.95rem;
}

button:hover {
  background: #003d37;
}

button:disabled {
  background: #999;
  cursor: not-allowed;
}

#sendResult {
  margin-top: 12px;
  font-size: 0.9rem;
}

#sendResult .success,
.success {
  color: #16a34a;
  font-weight: 600;
}

#sendResult .error,
.error {
  color: #dc2626;
  font-weight: 600;
}

/* Event Log */
.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.log-header h2 {
  margin-bottom: 0;
}

.log-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
}

.log-controls button {
  padding: 4px 12px;
  font-size: 0.8rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th {
  background: #f0f2f5;
  text-align: left;
  padding: 8px 10px;
  border-bottom: 2px solid #ddd;
}

td {
  padding: 8px 10px;
  border-bottom: 1px solid #eee;
  vertical-align: top;
}

td.empty {
  text-align: center;
  color: #999;
  padding: 24px;
}

td pre {
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 0.8rem;
  background: #f8f9fa;
  padding: 6px 8px;
  border-radius: 4px;
  margin: 0;
}

/* Event type badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-send { background: #dcfce7; color: #16a34a; }
.badge-send-error { background: #fee2e2; color: #dc2626; }
.badge-incoming { background: #e6f0ef; color: #005249; }
.badge-received { background: #e0e7ff; color: #4f46e5; }
.badge-status-callback { background: #fef3c7; color: #d97706; }
.badge-downloaded { background: #dcfce7; color: #16a34a; }
.badge-download-error { background: #fee2e2; color: #dc2626; }
.badge-swml-event { background: #e6f0ef; color: #005249; }
.badge-fax-failed { background: #fee2e2; color: #dc2626; }
.badge-manual-download { background: #fef3c7; color: #d97706; }

/* Admin badges */
.badge-admin { background: #d4ad3a; color: #333; }
.badge-user { background: #e6f0ef; color: #005249; }
.badge-active { background: #dcfce7; color: #16a34a; }
.badge-revoked { background: #fee2e2; color: #dc2626; }

tr.event-send-error { background: #fff5f5; }
tr.row-inactive { opacity: 0.6; }

/* Setup section */
dl {
  margin-bottom: 16px;
}

dt {
  font-weight: 600;
  margin-top: 10px;
  font-size: 0.9rem;
}

dd.url-display {
  font-family: "Consolas", "Courier New", monospace;
  background: #f0f2f5;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 0.85rem;
  margin: 4px 0 0 0;
  word-break: break-all;
}

.card h3 {
  margin-top: 16px;
  margin-bottom: 6px;
  font-size: 1rem;
  color: #333;
}

code.test-url {
  display: block;
  background: #f0f2f5;
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 0.8rem;
  word-break: break-all;
  cursor: pointer;
}

code.test-url:hover {
  background: #e2e5ea;
}

/* Received Faxes page */
.fax-count {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 12px;
}

.mono {
  font-family: "Consolas", "Courier New", monospace;
  font-size: 0.85rem;
}

.center {
  text-align: center;
}

.date-cell .date {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
}

.date-cell .time {
  display: block;
  font-size: 0.78rem;
  color: #666;
}

.file-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 700;
  margin-right: 4px;
  vertical-align: middle;
}

.file-pdf { background: #fee2e2; color: #dc2626; }
.file-tiff { background: #e6f0ef; color: #005249; }

.filename {
  font-size: 0.75rem;
  color: #666;
  word-break: break-all;
}

.actions {
  white-space: nowrap;
}

.btn-download {
  background: #005249;
  color: #fff;
  border: none;
  padding: 4px 10px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.78rem;
  margin-right: 4px;
}

.btn-download:hover {
  background: #003d37;
}

.btn-delete {
  background: #dc2626;
  color: #fff;
  border: none;
  padding: 4px 10px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.78rem;
}

.btn-delete:hover {
  background: #b91c1c;
}

/* Sync bar */
.sync-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 10px 14px;
  background: #f8f9fa;
  border-radius: 4px;
}

.btn-sync {
  background: #d4ad3a;
  color: #333;
  border: none;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

.btn-sync:hover {
  background: #c09a2e;
}

.btn-sync:disabled {
  background: #999;
  cursor: not-allowed;
}

#syncStatus {
  font-size: 0.85rem;
  color: #666;
}

.sync-success {
  color: #16a34a !important;
  font-weight: 600;
}

.sync-error {
  color: #dc2626 !important;
  font-weight: 600;
}

/* Status messages */
.status-msg {
  margin-left: 12px;
  font-size: 0.85rem;
}

/* === Login Page === */
.login-card {
  max-width: 400px;
  margin: 60px auto;
}

.login-card h2 {
  text-align: center;
  margin-bottom: 20px;
}

#loginError {
  margin-top: 12px;
  text-align: center;
}

/* === Admin Page === */
.admin-form {
  background: #f8f9fa;
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 20px;
}

.admin-form h3 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 0.95rem;
  color: #005249;
}

/* Token display */
.token-display {
  background: #fef3c7;
  border: 2px solid #d4ad3a;
  border-radius: 6px;
  padding: 14px;
  margin-bottom: 20px;
}

.token-display p {
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.token-value {
  display: block;
  background: #fff;
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 0.8rem;
  word-break: break-all;
  font-family: "Consolas", "Courier New", monospace;
  margin-bottom: 8px;
  border: 1px solid #e5e7eb;
}

.btn-copy {
  background: #d4ad3a;
  color: #333;
  padding: 4px 14px;
  font-size: 0.8rem;
  font-weight: 600;
}

.btn-copy:hover {
  background: #c09a2e;
}

/* === API Docs Page === */
.docs-main {
  max-width: 900px;
}

.inline-code {
  background: #f0f2f5;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 0.85rem;
}

.endpoint-card {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 16px;
}

.endpoint-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.method-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  font-family: "Consolas", "Courier New", monospace;
}

.method-get {
  background: #005249;
  color: #fff;
}

.method-post {
  background: #d4ad3a;
  color: #333;
}

.method-delete {
  background: #dc2626;
  color: #fff;
}

.method-patch {
  background: #7c3aed;
  color: #fff;
}

.endpoint-path {
  font-family: "Consolas", "Courier New", monospace;
  font-size: 0.9rem;
  font-weight: 600;
}

.endpoint-card h4 {
  margin-top: 14px;
  margin-bottom: 6px;
  font-size: 0.85rem;
  color: #333;
}

.docs-table {
  margin-bottom: 12px;
}

.docs-table code {
  background: #f0f2f5;
  padding: 1px 4px;
  border-radius: 2px;
  font-size: 0.8rem;
}

.code-block {
  background: #1a1a2e;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 12px;
}

.code-header {
  background: #2a2a3e;
  padding: 6px 12px;
  font-size: 0.75rem;
  color: #999;
  font-weight: 600;
  text-transform: uppercase;
}

.code-block pre {
  padding: 12px;
  margin: 0;
  color: #e4e4e7;
  font-size: 0.8rem;
  font-family: "Consolas", "Courier New", monospace;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  background: transparent;
}

/* Try It section */
.btn-try {
  background: #d4ad3a;
  color: #333;
  font-weight: 600;
}

.btn-try:hover {
  background: #c09a2e;
}

.try-result {
  margin-top: 14px;
}

.try-status-ok {
  color: #16a34a;
  font-weight: 600;
  margin-left: 8px;
}

.try-status-error {
  color: #dc2626;
  font-weight: 600;
  margin-left: 8px;
}

/* === Fax Viewer Modal === */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: #fff;
  border-radius: 8px;
  width: 90vw;
  height: 90vh;
  max-width: 1100px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #005249;
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
}

.modal-close {
  background: transparent;
  color: #fff;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.modal-body {
  flex: 1;
  overflow: auto;
  background: #f0f2f5;
}

/* View button */
.btn-view {
  background: #4f46e5;
  color: #fff;
  border: none;
  padding: 4px 10px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.78rem;
  margin-right: 4px;
}

.btn-view:hover {
  background: #4338ca;
}

/* Sent fax error info */
.error-info {
  font-size: 0.72rem;
  color: #dc2626;
  margin-top: 2px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Batch send results */
.batch-header {
  font-size: 0.85rem;
  color: #005249;
  margin-bottom: 8px;
  font-weight: 600;
}

.batch-results {
  font-size: 0.85rem;
}

.batch-result {
  padding: 4px 0;
  border-bottom: 1px solid #eee;
}

.batch-result.success {
  color: #16a34a;
}

.batch-result.error {
  color: #dc2626;
}

/* === API Logs Page === */
.summary-grid {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.summary-stat {
  text-align: center;
  padding: 10px 16px;
  background: #f0f2f5;
  border-radius: 6px;
  min-width: 100px;
}

.summary-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: #005249;
}

.summary-label {
  display: block;
  font-size: 0.78rem;
  color: #666;
  margin-top: 2px;
}
