/**
 * App Hub UI Framework
 * Standardized styles for all App Hub applications
 */

:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --text-primary: #c9d1d9;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --accent-primary: #58a6ff;
  --accent-success: #238636;
  --accent-danger: #f85149;
  --accent-warning: #d29922;
  --border-color: #30363d;
  --code-bg: #21262d;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  color: var(--accent-primary);
  margin-bottom: 0.5em;
  line-height: 1.2;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }

p { margin-bottom: 1em; }
a { color: var(--accent-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header */
header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 20px 0;
  margin-bottom: 30px;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

nav a {
  color: var(--text-primary);
  text-decoration: none;
  margin-left: 20px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}

nav a:hover {
  background: var(--bg-tertiary);
  text-decoration: none;
}

/* Cards */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 20px;
  transition: border-color 0.2s;
}

.card:hover {
  border-color: var(--accent-primary);
}

.card-title {
  color: var(--accent-primary);
  font-size: 1.3rem;
  margin-bottom: 10px;
}

.card-description {
  color: var(--text-secondary);
  margin-bottom: 15px;
}

/* Stats Grid */
.stats {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 30px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}

.stat-item {
  text-align: center;
}

.stat-value {
  font-size: 2.5rem;
  font-weight: bold;
  color: var(--accent-primary);
}

.stat-label {
  color: var(--text-secondary);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 600;
  transition: all 0.2s;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
}

.btn-primary {
  background: var(--accent-success);
  color: white;
}

.btn-primary:hover {
  background: #2ea043;
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

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

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

.btn-danger:hover {
  background: #da3633;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1.1rem;
}

/* Forms */
.form-group {
  margin-bottom: 20px;
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-secondary);
  font-weight: 500;
}

input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 1rem;
  transition: border-color 0.2s;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent-primary);
}

textarea {
  resize: vertical;
  min-height: 100px;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-right: 5px;
  margin-bottom: 5px;
}

.badge-primary { background: var(--accent-primary); color: white; }
.badge-success { background: var(--accent-success); color: white; }
.badge-danger { background: var(--accent-danger); color: white; }
.badge-warning { background: var(--accent-warning); color: black; }
.badge-secondary { background: var(--text-muted); color: white; }

/* Tables */
.table-container {
  overflow-x: auto;
  margin: 20px 0;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background: var(--bg-tertiary);
}

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

th {
  font-weight: 600;
  color: var(--text-secondary);
}

tbody tr:hover {
  background: var(--bg-tertiary);
}

/* Code blocks */
code {
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
  font-size: 0.9em;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 15px;
  overflow-x: auto;
  margin: 15px 0;
}

pre code {
  background: none;
  padding: 0;
}

/* Alerts */
.alert {
  padding: 15px 20px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
}

.alert-success {
  background: rgba(35, 134, 54, 0.2);
  border: 1px solid var(--accent-success);
  color: #3fb950;
}

.alert-danger {
  background: rgba(248, 81, 73, 0.2);
  border: 1px solid var(--accent-danger);
  color: #f85149;
}

.alert-warning {
  background: rgba(210, 153, 34, 0.2);
  border: 1px solid var(--accent-warning);
  color: #d29922;
}

.alert-info {
  background: rgba(88, 166, 255, 0.2);
  border: 1px solid var(--accent-primary);
  color: var(--accent-primary);
}

/* Loading spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--bg-tertiary);
  border-top: 4px solid var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Grid system */
.grid {
  display: grid;
  gap: 20px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }

  .stats {
    grid-template-columns: 1fr;
  }
}

/* Flex utilities */
.flex {
  display: flex;
}

.flex-between {
  justify-content: space-between;
  align-items: center;
}

.flex-center {
  justify-content: center;
  align-items: center;
}

.flex-gap {
  gap: 10px;
}

/* Spacing */
.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }
.mt-3 { margin-top: 30px; }
.mb-1 { margin-bottom: 10px; }
.mb-2 { margin-bottom: 20px; }
.mb-3 { margin-bottom: 30px; }

/* Text utilities */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--accent-success); }
.text-danger { color: var(--accent-danger); }
.text-warning { color: var(--accent-warning); }

/* Section titles */
.section-title {
  color: var(--accent-primary);
  font-size: 1.5rem;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
}

/* Footer */
footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 20px 0;
  margin-top: 50px;
  text-align: center;
  color: var(--text-secondary);
}

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