/* App Hub - Shared Styles (dependency-free) */

:root {
  --color-bg: #fafafa;
  --color-surface: #fff;
  --color-text: #111;
  --color-muted: #666;
  --color-border: #ddd;
  --color-accent: #0a58ca;
  --color-accent-hover: #084298;
  --color-success: #006b1f;
  --color-danger: #b00020;
  --color-danger-hover: #8a0018;
  --color-warning-bg: #fff3cd;
  --radius: 8px;
  --tap-min: 44px;
  --font-sans: ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

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

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  margin: 0;
  padding: 0;
  line-height: 1.5;
}

/* Header */
.hub-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}

.hub-header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.hub-header h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.hub-header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.env-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: #e0e0e0;
  color: #333;
}

.env-badge.prod {
  background: #dc3545;
  color: #fff;
}

.env-badge.dev {
  background: #198754;
  color: #fff;
}

.env-badge.staging {
  background: #fd7e14;
  color: #fff;
}

.identity {
  font-size: 0.85rem;
  color: var(--color-muted);
}

.identity strong {
  color: var(--color-text);
}

/* Container */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem;
}

/* Links */
a {
  color: var(--color-accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Headings */
h1, h2, h3 {
  margin: 0 0 0.75rem;
}

h2 {
  font-size: 1.1rem;
  margin-top: 1.5rem;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.5rem;
}

/* Muted text */
.muted {
  color: var(--color-muted);
  font-size: 0.9rem;
}

/* Cards */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 0.75rem 0;
}

.card a {
  font-weight: 500;
}

.card .desc {
  color: var(--color-muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

/* Buttons - minimum 44px tap target */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap-min);
  min-width: var(--tap-min);
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  font-family: inherit;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  touch-action: manipulation;
}

button:hover, .btn:hover {
  background: #f0f0f0;
  border-color: #bbb;
}

button:active, .btn:active {
  background: #e5e5e5;
}

/* Primary button */
button.primary, .btn.primary {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}

button.primary:hover, .btn.primary:hover {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
}

/* Destructive / danger button */
button.danger, .btn.danger {
  background: #fff;
  color: var(--color-danger);
  border-color: var(--color-danger);
}

button.danger:hover, .btn.danger:hover {
  background: var(--color-danger);
  color: #fff;
}

/* Small buttons */
button.sm, .btn.sm {
  min-height: 36px;
  min-width: 36px;
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
}

/* Button group */
.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Forms */
input, textarea, select {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.6rem 0.75rem;
  min-height: var(--tap-min);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  width: 100%;
}

input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

textarea {
  font-family: var(--font-mono);
  resize: vertical;
}

label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
}

.form-row {
  margin-bottom: 1rem;
}

.form-row.inline {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.form-row.inline > * {
  flex: 1;
}

/* Messages */
.msg {
  min-height: 1.4em;
  padding: 0.5rem 0;
  font-size: 0.9rem;
}

.msg.error {
  color: var(--color-danger);
}

.msg.success {
  color: var(--color-success);
}

/* Tables (desktop) */
.table-wrap {
  overflow-x: auto;
  margin: 0.75rem 0;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9rem;
  background: var(--color-surface);
}

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

th {
  background: #f7f7f7;
  font-weight: 600;
}

/* Responsive cards for admin - hide table on mobile */
.app-cards {
  display: none;
}

@media (max-width: 768px) {
  .table-wrap.responsive {
    display: none;
  }

  .app-cards {
    display: block;
  }

  .app-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
  }

  .app-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
  }

  .app-card-name {
    font-weight: 600;
    font-size: 1rem;
  }

  .app-card-status {
    font-size: 0.8rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    background: #e0e0e0;
  }

  .app-card-status.running {
    background: #d1e7dd;
    color: #0f5132;
  }

  .app-card-status.stopped {
    background: #f8d7da;
    color: #842029;
  }

  .app-card-details {
    font-size: 0.85rem;
    color: var(--color-muted);
    margin-bottom: 0.75rem;
  }

  .app-card-details dt {
    font-weight: 500;
    display: inline;
  }

  .app-card-details dd {
    display: inline;
    margin: 0 1rem 0 0.25rem;
  }

  .app-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--color-border);
  }
}

/* Magic link token display */
.token-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.token-truncated {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: #f5f5f5;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-btn {
  min-width: 32px;
  min-height: 32px;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.copy-btn.copied {
  background: var(--color-success);
  color: #fff;
  border-color: var(--color-success);
}

/* Magic link table on mobile */
@media (max-width: 768px) {
  .magic-cards {
    display: block;
  }

  .magic-table-wrap {
    display: none;
  }

  .magic-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
  }

  .magic-card-header {
    font-weight: 500;
    margin-bottom: 0.5rem;
  }

  .magic-card-expires {
    font-size: 0.85rem;
    color: var(--color-muted);
    margin-bottom: 0.5rem;
  }

  .magic-card-url {
    font-size: 0.8rem;
    word-break: break-all;
    margin-bottom: 0.75rem;
  }
}

@media (min-width: 769px) {
  .magic-cards {
    display: none;
  }
}

/* Warning/caution banner */
.warning-banner {
  background: var(--color-warning-bg);
  border: 1px solid #ffecb5;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* Confirmation dialog overlay */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.confirm-dialog {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.confirm-dialog h3 {
  margin: 0 0 0.75rem;
}

.confirm-dialog p {
  margin: 0 0 1.25rem;
  color: var(--color-muted);
}

.confirm-dialog .btn-group {
  justify-content: flex-end;
}

/* Utilities */
.hidden {
  display: none !important;
}

.text-mono {
  font-family: var(--font-mono);
}

.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
