/* ==========================================================================
   RepoVault — shared components
   Depends on tokens.css. Used by every page.
   ========================================================================== */

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6 {
    margin: 0;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

h1 { font-size: var(--text-2xl); line-height: 1.15; }
h2 { font-size: var(--text-xl); line-height: 1.2; }
h3 { font-size: var(--text-lg); line-height: 1.3; }
h4 { font-size: var(--text-md); line-height: 1.4; }

p { margin: 0; color: var(--text-secondary); }

code, pre {
    font-family: var(--font-mono);
    font-size: 0.92em;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 8px 14px;
    font-family: inherit;
    font-size: var(--text-sm);
    font-weight: 500;
    line-height: 1.2;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    transition: background var(--transition), color var(--transition),
                border-color var(--transition), transform var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled,
.btn[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    color: #fff;
}

.btn-ghost {
    background: var(--bg-elevated);
    border-color: var(--border);
    color: var(--text-primary);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--border-strong);
}

.btn-subtle {
    background: transparent;
    color: var(--text-secondary);
}

.btn-subtle:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-danger {
    background: transparent;
    border-color: rgba(239, 68, 68, 0.4);
    color: var(--status-danger);
}

.btn-danger:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--status-danger);
}

.btn-sm {
    padding: 4px 10px;
    font-size: var(--text-xs);
}

.btn-lg {
    padding: 12px 20px;
    font-size: var(--text-md);
}

.btn-block {
    width: 100%;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition), color var(--transition),
                border-color var(--transition);
    font-size: 18px;
    line-height: 1;
    text-decoration: none;
}

.icon-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.icon-btn.active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}

/* Emoji glyphs render oversized at 18px — scale them down so they feel
   the same visual weight as the monochrome unicode icons. */
.icon-btn-emoji {
    font-size: 15px;
}

/* ---------- Inputs ---------- */
.input,
.select,
.textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: var(--text-md);
    line-height: 1.4;
    transition: border-color var(--transition), background var(--transition);
}

.input::placeholder,
.textarea::placeholder {
    color: var(--text-muted);
}

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--bg-elevated);
}

.input:disabled,
.select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.select {
    appearance: none;
    padding-right: 36px;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23a3a3a3' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.input-group > label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    font-weight: 500;
}

.input-hint {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* ---------- Cards ---------- */
.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.card-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
}

.card-subtitle {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-top: var(--space-1);
}

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px 8px;
    border-radius: 999px;
    font-size: var(--text-xs);
    font-weight: 500;
    line-height: 1.4;
    background: var(--bg-hover);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.badge-accent {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: rgba(139, 92, 246, 0.3);
}

.badge-success {
    background: rgba(34, 197, 94, 0.1);
    color: var(--status-success);
    border-color: rgba(34, 197, 94, 0.3);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--status-warning);
    border-color: rgba(245, 158, 11, 0.3);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--status-danger);
    border-color: rgba(239, 68, 68, 0.3);
}

.badge-info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--status-info);
    border-color: rgba(59, 130, 246, 0.3);
}

/* ---------- Alerts / flash messages ---------- */
.alert {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-size: var(--text-sm);
    margin-bottom: var(--space-4);
}

.alert-success {
    background: rgba(34, 197, 94, 0.08);
    border-color: rgba(34, 197, 94, 0.3);
    color: var(--status-success);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--status-danger);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.3);
    color: var(--status-warning);
}

/* ---------- Tables ---------- */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.table th,
.table td {
    padding: var(--space-3);
    text-align: left;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

.table th {
    font-weight: 500;
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-elevated);
}

.table tr:hover td {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ---------- Utility ---------- */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-success { color: var(--status-success); }
.text-danger { color: var(--status-danger); }

.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-md { font-size: var(--text-md); }
.text-lg { font-size: var(--text-lg); }

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

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }

.hidden { display: none !important; }

/* ---------- Modal primitives ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
    padding: var(--space-4);
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    max-width: 560px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(8px);
    transition: transform var(--transition);
}

.modal-overlay.open .modal {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
}

.modal-title {
    font-size: var(--text-lg);
    font-weight: 600;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: var(--text-xl);
    cursor: pointer;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    line-height: 1;
}

.close-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}
