/* ========== BASE ========== */
:root {
    --brand: #6366f1;
    --brand-hover: #4f46e5;
    --brand-light: #eef2ff;
    --brand-subtle: #c7d2fe;
    --surface: #ffffff;
    --surface-hover: #f8fafc;
    --surface-alt: #f1f5f9;
    --border: #e2e8f0;
    --border-hover: #cbd5e1;
    --text: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #22c55e;
    --sidebar-bg: #0f172a;
    --sidebar-active: rgba(99, 102, 241, 0.25);
    --sidebar-hover: rgba(255, 255, 255, 0.06);
    --radius: 10px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
}

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--surface-alt);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

/* ========== LINKS & BUTTONS ========== */
a {
    color: var(--brand);
    transition: color 0.15s;
}
a:hover {
    color: var(--brand-hover);
}

.btn-primary {
    background: var(--brand);
    border-color: var(--brand);
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
}
.btn-primary:hover, .btn-primary:active {
    background: var(--brand-hover);
    border-color: var(--brand-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-outline-primary {
    color: var(--brand);
    border-color: var(--brand-subtle);
    border-radius: var(--radius-sm);
    font-weight: 500;
}
.btn-outline-primary:hover {
    background: var(--brand);
    border-color: var(--brand);
}

.btn-outline-danger {
    color: var(--danger);
    border-color: #fecaca;
    border-radius: var(--radius-sm);
    font-weight: 500;
}
.btn-outline-danger:hover {
    background: var(--danger);
    border-color: var(--danger);
}

.btn-outline-secondary {
    color: var(--text-secondary);
    border-color: var(--border);
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.btn:focus, .btn:active:focus, .form-control:focus, .form-select:focus, .form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
    border-color: var(--brand-subtle);
}

/* ========== FORMS ========== */
.form-control, .form-select {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.875rem;
    font-size: 0.925rem;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: var(--surface);
}
.form-control:hover, .form-select:hover {
    border-color: var(--border-hover);
}
.form-label {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text);
    margin-bottom: 0.375rem;
}
textarea.form-control {
    font-size: 0.9rem;
    line-height: 1.7;
    font-family: 'Inter', sans-serif;
}

/* ========== LAYOUT ========== */
.content {
    padding-top: 1.5rem;
    max-width: 1200px;
}

h1 {
    font-weight: 700;
    font-size: 1.75rem;
    letter-spacing: -0.025em;
    color: var(--text);
}
h1:focus { outline: none; }

/* ========== PAGE HEADER ========== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.75rem;
}
.page-header h1 { margin: 0; }

/* ========== FILTER PILLS ========== */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.filter-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: 100px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.15s;
    white-space: nowrap;
}
.filter-pill:hover {
    background: var(--surface-alt);
    border-color: var(--border-hover);
    color: var(--text);
}
.filter-pill.active {
    background: var(--brand);
    border-color: var(--brand);
    color: white;
}
.filter-sub {
    margin-left: 0.5rem;
    padding-left: 0.75rem;
    border-left: 2px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.filter-pill-sub {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 100px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.15s;
    white-space: nowrap;
}
.filter-pill-sub:hover {
    background: var(--surface-alt);
    color: var(--text-secondary);
}
.filter-pill-sub.active {
    background: var(--text);
    border-color: var(--text);
    color: white;
}

/* ========== PROMPT CARDS ========== */
.prompt-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}
@media (max-width: 640px) {
    .prompt-grid { grid-template-columns: 1fr; }
}

.prompt-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: all 0.2s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
}
.prompt-card:hover {
    border-color: var(--brand-subtle);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    color: inherit;
}
.prompt-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
    line-height: 1.4;
}
.prompt-card-preview {
    font-size: 0.8125rem;
    color: var(--text-muted);
    line-height: 1.5;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.prompt-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.875rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ========== BADGES ========== */
.cat-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.6rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-radius: 100px;
    background: var(--brand-light);
    color: var(--brand);
}
.cat-badge-separator {
    opacity: 0.4;
}

/* ========== PROMPT DETAIL ========== */
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}
.detail-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}
.detail-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}
.prompt-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    font-size: 0.925rem;
    line-height: 1.75;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ========== BACK LINK ========== */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    margin-bottom: 1.25rem;
    transition: color 0.15s;
}
.back-link:hover {
    color: var(--brand);
}

/* ========== FORM PAGE ========== */
.form-page {
    max-width: 720px;
}
.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.75rem;
    box-shadow: var(--shadow-sm);
}

/* ========== CATEGORIES PAGE ========== */
.cat-add-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}
.cat-tree {
    max-width: 700px;
}
.cat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 0.375rem;
    transition: border-color 0.15s;
}
.cat-item:hover {
    border-color: var(--border-hover);
}
.cat-item-child {
    margin-left: 1.75rem;
    border-left: 3px solid var(--brand-subtle);
}
.cat-item-name {
    font-weight: 600;
    font-size: 0.925rem;
    color: var(--text);
}
.cat-item-child .cat-item-name {
    font-weight: 500;
    color: var(--text-secondary);
}
.cat-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.375rem;
    height: 1.375rem;
    padding: 0 0.375rem;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 100px;
    background: var(--surface-alt);
    color: var(--text-muted);
    margin-left: 0.5rem;
}

/* ========== EMPTY STATE ========== */
.empty-state {
    text-align: center;
    padding: 4rem 1rem;
}
.empty-state-icon {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    opacity: 0.4;
}
.empty-state h4 {
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}
.empty-state p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ========== LOGIN PAGE ========== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sidebar-bg);
    padding: 1rem;
}
.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border-radius: 12px;
    padding: 2.5rem 2rem;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
}
.login-header {
    text-align: center;
    margin-bottom: 2rem;
}
.login-header i {
    font-size: 2.5rem;
    color: var(--brand);
    margin-bottom: 0.75rem;
    display: block;
}
.login-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.375rem;
}
.login-header p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin: 0;
}
.login-error {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
    padding: 0.625rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

/* ========== BLAZOR ========== */
.blazor-error-boundary {
    background: var(--danger);
    padding: 1rem;
    color: white;
    border-radius: var(--radius-sm);
}
.blazor-error-boundary::after {
    content: "Wystapil blad."
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--success);
}
.invalid {
    outline: 1px solid var(--danger);
}
.validation-message {
    color: var(--danger);
    font-size: 0.8125rem;
}
