/* VVP Issuer - Shared Styles */

/* ==========================================================================
   CSS Custom Properties
   ========================================================================== */
:root {
  /* Issuer uses teal/green theme to distinguish from Verifier (blue) */
  --vvp-primary: #2a9d8f;
  --vvp-primary-hover: #238b80;
  --vvp-secondary: #95a5a6;
  --vvp-secondary-hover: #7f8c8d;
  --vvp-success: #28a745;
  --vvp-danger: #dc3545;
  --vvp-warning: #ffc107;
  --vvp-info: #17a2b8;
  --vvp-muted: #6c757d;
  --vvp-dark: #264653;
  --vvp-dark-secondary: #2d5a4e;
  --vvp-light: #f8faf9;
  --vvp-border: #d4e6e1;
  --vvp-text: #495057;
  --vvp-text-muted: #666;
  /* Color for links to Verifier service */
  --vvp-verifier-color: #0066cc;
}

/* ==========================================================================
   Base Styles
   ========================================================================== */
body {
  font-family: system-ui, -apple-system, sans-serif;
  margin: 0;
  padding: 2rem;
  max-width: 1100px;
  background: var(--vvp-light);
}

h1 {
  color: var(--vvp-dark);
  margin-bottom: 0.5rem;
}

h2 {
  color: var(--vvp-dark-secondary);
  margin-top: 0;
}

.subtitle {
  color: var(--vvp-text-muted);
  margin-bottom: 2rem;
}

/* ==========================================================================
   Site Header & Navigation
   ========================================================================== */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--vvp-border);
}

.site-header .logo {
  font-weight: bold;
  font-size: 1.5rem;
  text-decoration: none;
  color: var(--vvp-dark);
}

.site-header .logo:hover {
  color: var(--vvp-primary);
}

.nav-links {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.nav-links a {
  color: var(--vvp-primary);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  background: white;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  transition: background 0.2s, color 0.2s;
}

.nav-links a:hover {
  background: #e8f4ff;
}

.nav-links a.active {
  background: var(--vvp-primary);
  color: white;
}

/* Header branding with OVC logo */
.header-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-brand .ovc-logo {
  height: 40px;
  width: auto;
}

.header-brand .logo {
  display: flex;
  flex-direction: column;
}

.header-brand .service-label {
  font-size: 0.75rem;
  color: var(--vvp-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Cross-service link (styled with Verifier's blue) */
.nav-links a.verifier-link {
  background: var(--vvp-verifier-color);
  color: white;
}

.nav-links a.verifier-link:hover {
  background: #0055aa;
}

/* ==========================================================================
   Cards
   ========================================================================== */
.card {
  background: white;
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.card h2 {
  margin-top: 0;
}

/* ==========================================================================
   Forms
   ========================================================================== */
.form-group {
  margin-bottom: 1rem;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
  box-sizing: border-box;
}

textarea {
  font-family: 'SFMono-Regular', Consolas, monospace;
  min-height: 150px;
  resize: vertical;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--vvp-primary);
  box-shadow: 0 0 0 2px rgba(52,152,219,0.2);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 1rem 0;
}

.checkbox-row input {
  width: auto;
}

.checkbox-row label {
  margin: 0;
  font-weight: normal;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
button,
.button {
  background: var(--vvp-primary);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
  text-decoration: none;
  display: inline-block;
}

button:hover,
.button:hover {
  background: var(--vvp-primary-hover);
}

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

button.secondary {
  background: var(--vvp-secondary);
}

button.secondary:hover {
  background: var(--vvp-secondary-hover);
}

button.small {
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
}

.button-row {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
}

/* ==========================================================================
   Alerts
   ========================================================================== */
.success {
  background: #d4edda;
  border: 1px solid #c3e6cb;
  color: #155724;
  padding: 1rem;
  border-radius: 4px;
  margin-top: 1rem;
}

.error {
  background: #f8d7da;
  border: 1px solid #f5c6cb;
  color: #721c24;
  padding: 1rem;
  border-radius: 4px;
  margin-top: 1rem;
}

.info {
  background: #cce5ff;
  border: 1px solid #b8daff;
  color: #004085;
  padding: 1rem;
  border-radius: 4px;
  margin-top: 1rem;
}

.warning {
  background: #fff3cd;
  border: 1px solid #ffeeba;
  color: #856404;
  padding: 1rem;
  border-radius: 4px;
  margin-top: 1rem;
}

/* ==========================================================================
   Badges
   ========================================================================== */
.badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-transferable {
  background: #d4edda;
  color: #155724;
}

.badge-non-transferable {
  background: #f8d7da;
  color: #721c24;
}

.status-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.875rem;
  font-weight: 500;
}

.status-issued {
  background: #d4edda;
  color: #155724;
}

.status-revoked {
  background: #f8d7da;
  color: #721c24;
}

/* ==========================================================================
   Tables
   ========================================================================== */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

th, td {
  text-align: left;
  padding: 0.75rem;
  border-bottom: 1px solid var(--vvp-border);
}

th {
  background: var(--vvp-light);
  font-weight: 600;
}

tr:hover {
  background: var(--vvp-light);
}

tr.selected {
  background: #cce5ff;
}

.said-cell {
  font-family: monospace;
  font-size: 0.875rem;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.said-cell:hover {
  overflow: visible;
  white-space: normal;
  word-break: break-all;
}

/* ==========================================================================
   Result Fields
   ========================================================================== */
.result-field {
  margin: 0.75rem 0;
  padding: 0.5rem;
  background: var(--vvp-light);
  border-radius: 4px;
}

.result-field strong {
  color: var(--vvp-text);
}

.result-field code {
  display: block;
  margin-top: 0.25rem;
  padding: 0.5rem;
  background: #e9ecef;
  border-radius: 4px;
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 0.85rem;
  word-break: break-all;
}

/* ==========================================================================
   OOBI URLs
   ========================================================================== */
.oobi-url {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.25rem 0;
}

.oobi-url code {
  flex: 1;
  margin: 0;
  font-size: 0.8rem;
}

.copy-btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  background: var(--vvp-muted);
}

.copy-btn:hover {
  background: #5a6268;
}

/* ==========================================================================
   Identity List
   ========================================================================== */
.identity-list {
  display: grid;
  gap: 1rem;
}

.identity-item {
  background: var(--vvp-light);
  border: 1px solid var(--vvp-border);
  border-radius: 4px;
  padding: 1rem;
}

.identity-item h4 {
  margin: 0 0 0.5rem 0;
  color: var(--vvp-dark);
}

.identity-item .aid {
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--vvp-muted);
  word-break: break-all;
}

.identity-meta {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--vvp-text-muted);
}

/* ==========================================================================
   Loading & Spinner
   ========================================================================== */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

.spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid #fff;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 0.5rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   Witness Results
   ========================================================================== */
.publish-results {
  margin-top: 1rem;
}

.witness-result {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
  font-size: 0.85rem;
}

.witness-success {
  color: var(--vvp-success);
}

.witness-fail {
  color: var(--vvp-danger);
}

/* ==========================================================================
   Tabs
   ========================================================================== */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--vvp-border);
  margin-bottom: 1rem;
}

.tab {
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: 1rem;
  color: var(--vvp-muted);
  transition: color 0.2s, border-color 0.2s;
}

.tab:hover {
  color: var(--vvp-primary);
}

.tab.active {
  color: var(--vvp-primary);
  border-bottom-color: var(--vvp-primary);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ==========================================================================
   Preview Areas
   ========================================================================== */
.dossier-preview,
.json-preview {
  background: var(--vvp-light);
  border: 1px solid var(--vvp-border);
  border-radius: 4px;
  padding: 1rem;
  margin-top: 1rem;
  max-height: 400px;
  overflow: auto;
}

.dossier-preview pre,
.json-preview pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 0.875rem;
}

/* ==========================================================================
   Stat Boxes
   ========================================================================== */
.stat-box {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: #e9ecef;
  border-radius: 4px;
  margin-right: 0.5rem;
}

.stat-box strong {
  color: var(--vvp-text);
}

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  max-width: 600px;
  max-height: 80vh;
  overflow: auto;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.modal h3 {
  margin-top: 0;
}

/* ==========================================================================
   404 Error Page
   ========================================================================== */
.error-page {
  text-align: center;
  padding: 4rem 2rem;
}

.error-page h1 {
  font-size: 6rem;
  margin: 0;
  color: var(--vvp-muted);
}

.error-page h2 {
  margin-top: 0.5rem;
}

.error-page p {
  color: var(--vvp-muted);
  margin-bottom: 2rem;
}

.error-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 768px) {
  body {
    padding: 1rem;
  }

  .site-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .nav-links {
    width: 100%;
  }

  .nav-links a {
    flex: 1;
    text-align: center;
    padding: 0.5rem;
    font-size: 0.9rem;
  }

  .button-row {
    flex-direction: column;
  }

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

  .error-page h1 {
    font-size: 4rem;
  }
}

@media (max-width: 480px) {
  .nav-links a {
    padding: 0.4rem;
    font-size: 0.8rem;
  }
}

/* ==========================================================================
   Help Menu
   ========================================================================== */
.help-btn {
  background: var(--vvp-info);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.help-btn:hover {
  background: #138496;
}

.help-modal {
  max-width: 700px;
  width: 90%;
}

.help-modal h3 {
  margin-top: 0;
  color: var(--vvp-dark);
  border-bottom: 2px solid var(--vvp-border);
  padding-bottom: 0.5rem;
}

.help-section {
  margin-bottom: 1.5rem;
}

.help-section h4 {
  color: var(--vvp-primary);
  margin: 0 0 0.5rem 0;
  font-size: 1.1rem;
}

.help-section p {
  margin: 0 0 0.5rem 0;
  color: var(--vvp-text);
}

.help-options {
  list-style: none;
  padding: 0;
  margin: 0;
}

.help-options li {
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background: var(--vvp-light);
  border-radius: 4px;
  border-left: 3px solid var(--vvp-primary);
}

.help-options li strong {
  color: var(--vvp-dark);
  display: block;
  margin-bottom: 0.25rem;
}

.help-options li span {
  font-size: 0.9rem;
  color: var(--vvp-text-muted);
}

.help-options a {
  color: var(--vvp-primary);
  text-decoration: none;
}

.help-options a:hover {
  text-decoration: underline;
}

.help-tip {
  background: #e8f4ff;
  border: 1px solid var(--vvp-info);
  border-radius: 4px;
  padding: 0.75rem;
  margin-top: 1rem;
  font-size: 0.9rem;
}

.help-tip strong {
  color: var(--vvp-info);
}
