/* ============================================================
   Claude Portal – Stylesheet
   Refined editorial-corporate aesthetic
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --bg: #fafaf7;
    --surface: #ffffff;
    --surface-2: #f4f4ef;
    --border: #e6e5dc;
    --text: #1a1a18;
    --text-muted: #6b6b62;
    --accent: #7ab325;
    --accent-dark: #5e8a1d;
    --accent-light: #f0f7e3;
    --danger: #c0392b;
    --danger-light: #fce4e1;
    --success: #2e7d32;
    --success-light: #e8f5e9;
    --warning: #d97706;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 4px 16px rgba(0,0,0,0.06);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.10);
    --radius: 8px;
    --radius-lg: 14px;
    --font-sans: 'Inter', -apple-system, system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

html, body {
    height: 100%;
    font-family: var(--font-sans);
    color: var(--text);
    background: var(--bg);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-weight: 600; letter-spacing: -0.02em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; margin-bottom: 1rem; }
h3 { font-size: 1.05rem; }

.muted { color: var(--text-muted); }
.center { text-align: center; }
.small { font-size: 0.85rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* === Buttons === */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 500;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s ease;
}
.btn:hover { background: var(--surface-2); }
.btn-primary {
    background: var(--text);
    color: var(--bg);
    border-color: var(--text);
}
.btn-primary:hover { background: #000; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* === Auth pages === */
.auth-body {
    display: grid;
    place-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--bg) 0%, #eef0e6 100%);
    padding: 1rem;
}
.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem 2.25rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}
.brand { text-align: center; margin-bottom: 2rem; }
.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 56px; height: 56px;
    background: var(--text);
    color: var(--accent);
    border-radius: 14px;
    font-size: 1.8rem;
    margin-bottom: 1rem;
}
.brand-mark.small { width: 32px; height: 32px; font-size: 1.1rem; border-radius: 8px; margin: 0; }
.brand h1 { font-size: 1.4rem; margin-bottom: 0.25rem; }
.brand p { font-size: 0.9rem; }

.auth-card form { display: flex; flex-direction: column; gap: 1rem; }
.auth-card label {
    display: flex; flex-direction: column; gap: 0.4rem;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
}
input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.65rem 0.85rem;
    width: 100%;
    transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.footer-note {
    text-align: center;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

/* === Alerts === */
.alert {
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    border: 1px solid;
    margin-bottom: 1rem;
}
.alert-error { background: var(--danger-light); border-color: #f5c6c0; color: var(--danger); }
.alert-success { background: var(--success-light); border-color: #c8e6c9; color: var(--success); }

/* === Chat App Shell === */
.app-body { overflow: hidden; }
.app-shell {
    display: grid;
    grid-template-columns: 280px 1fr;
    height: 100vh;
}

.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.25rem;
    gap: 1rem;
}
.sidebar-head {
    display: flex; align-items: center; gap: 0.75rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}
.brand-name { font-weight: 600; font-size: 0.95rem; }
.brand-sub { font-size: 0.78rem; color: var(--text-muted); }

.conv-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin: 0 -0.5rem;
    padding: 0 0.5rem;
}
.conv-item {
    text-align: left;
    background: transparent;
    border: 1px solid transparent;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    font: inherit;
    color: var(--text);
    transition: background 0.12s;
}
.conv-item:hover { background: var(--surface-2); }
.conv-item.active {
    background: var(--accent-light);
    border-color: var(--accent);
}
.conv-title {
    font-size: 0.88rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}
.conv-date { font-size: 0.72rem; color: var(--text-muted); }

.sidebar-foot {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.usage-box {
    background: var(--surface-2);
    padding: 0.75rem;
    border-radius: var(--radius);
}
.usage-label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.usage-value { font-size: 1.1rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.usage-bar { height: 4px; background: var(--border); border-radius: 2px; margin: 0.4rem 0; overflow: hidden; }
.usage-bar span { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.usage-sub { font-size: 0.72rem; color: var(--text-muted); }
.link-row {
    display: block;
    padding: 0.45rem 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    border-radius: var(--radius);
}
.link-row:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }

/* === Chat main === */
.chat-main {
    display: flex;
    flex-direction: column;
    background: var(--bg);
    overflow: hidden;
}
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.chat-header h2 { font-size: 1rem; font-weight: 500; }
.model-info { font-size: 0.78rem; color: var(--text-muted); font-family: var(--font-mono); }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.welcome {
    margin: auto;
    text-align: center;
    color: var(--text-muted);
}
.welcome-icon {
    font-size: 3rem;
    color: var(--accent);
    margin-bottom: 1rem;
}
.welcome h3 { font-size: 1.2rem; color: var(--text); margin-bottom: 0.5rem; }

.msg {
    max-width: 760px;
    width: 100%;
    align-self: center;
    display: flex;
    gap: 1rem;
}
.msg-avatar {
    width: 32px; height: 32px;
    border-radius: 8px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    font-size: 0.85rem;
    font-weight: 600;
}
.msg-user .msg-avatar { background: var(--surface-2); color: var(--text); }
.msg-assistant .msg-avatar { background: var(--text); color: var(--accent); }
.msg-content {
    flex: 1;
    padding-top: 0.25rem;
    line-height: 1.65;
    overflow-wrap: break-word;
}
.msg-content p { margin-bottom: 0.75rem; }
.msg-content p:last-child { margin-bottom: 0; }
.msg-content pre {
    background: var(--text);
    color: #f4f4ef;
    padding: 1rem;
    border-radius: var(--radius);
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    margin: 0.5rem 0;
}
.msg-content code {
    background: var(--surface-2);
    padding: 0.1em 0.4em;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.88em;
}
.msg-content pre code { background: transparent; padding: 0; }

.chat-input-form {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 2rem 1.5rem;
    align-items: flex-end;
    background: var(--surface);
    border-top: 1px solid var(--border);
}
.chat-input-form textarea {
    flex: 1;
    resize: none;
    max-height: 200px;
}
.btn-spinner { font-family: var(--font-mono); animation: pulse 1.4s infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }

/* === Admin === */
.admin-body { background: var(--bg); }
.admin-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 2rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.admin-brand {
    display: flex; align-items: center; gap: 0.6rem;
    font-weight: 600;
    font-size: 0.95rem;
}
.admin-nav { display: flex; gap: 0.25rem; }
.admin-nav a {
    padding: 0.45rem 0.9rem;
    color: var(--text-muted);
    border-radius: var(--radius);
    font-size: 0.88rem;
    font-weight: 500;
}
.admin-nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.admin-nav a.active { color: var(--text); background: var(--accent-light); }

.admin-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}
.admin-page > h1 { margin-bottom: 0.5rem; }
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

/* Stats */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0 2.5rem;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
}
.stat-value {
    font-size: 1.75rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}
.stat-label { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.25rem; }

.admin-section { margin-bottom: 2.5rem; }

.quick-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}
.quick-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text);
}
.quick-card:hover { background: var(--surface-2); text-decoration: none; box-shadow: var(--shadow); transform: translateY(-1px); transition: all 0.15s; }
.quick-icon { font-size: 1.5rem; }

/* Tables */
.table {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border-collapse: collapse;
}
.table th, .table td {
    padding: 0.85rem 1rem;
    text-align: left;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
}
.table th {
    background: var(--surface-2);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.row-disabled { opacity: 0.55; }

.badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    background: var(--surface-2);
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted);
    font-family: var(--font-mono);
}
.badge-admin { background: var(--text); color: var(--accent); }
.badge-user { background: var(--accent-light); color: var(--accent-dark); }

.status-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 0.4rem;
    vertical-align: middle;
}
.status-active { background: var(--success); }
.status-inactive { background: var(--text-muted); }

/* Action menu */
.action-menu { position: relative; display: inline-block; }
.action-menu summary {
    cursor: pointer;
    list-style: none;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    user-select: none;
}
.action-menu summary::-webkit-details-marker { display: none; }
.action-menu summary:hover { background: var(--surface-2); }
.action-popover {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
    min-width: 180px;
    box-shadow: var(--shadow-lg);
    z-index: 10;
    display: flex;
    flex-direction: column;
}
.action-popover button {
    text-align: left;
    background: transparent;
    border: 0;
    padding: 0.5rem 0.75rem;
    font: inherit;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text);
}
.action-popover button:hover { background: var(--surface-2); }
.action-popover button.danger { color: var(--danger); }
.action-popover button.danger:hover { background: var(--danger-light); }
.action-popover form { margin: 0; }

/* Modal */
.modal {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    width: 90%;
    max-width: 460px;
    box-shadow: var(--shadow-lg);
}
.modal::backdrop { background: rgba(0,0,0,0.4); backdrop-filter: blur(4px); }
.modal h2 { margin-bottom: 1rem; }
.modal form { display: flex; flex-direction: column; gap: 1rem; }
.modal label {
    display: flex; flex-direction: column; gap: 0.35rem;
    font-size: 0.82rem; font-weight: 500; color: var(--text-muted);
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

/* Mobile */
@media (max-width: 768px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .admin-main { padding: 1rem; }
    .table { font-size: 0.85rem; }
    .table th, .table td { padding: 0.6rem 0.5rem; }
    .chat-input-form { padding: 1rem; }
    .chat-messages { padding: 1rem; }
}


/* ============================================================
   Zusatz: Checkbox-Label im Edit-Modal
   In assets/style.css einfügen (z.B. ans Ende).
   ============================================================ */

.modal label.checkbox-label {
    flex-direction: row;
    align-items: center;
    gap: 0.6rem;
    color: var(--text);
    font-size: 0.92rem;
    font-weight: 400;
    cursor: pointer;
    padding: 0.35rem 0;
}
.modal label.checkbox-label input[type="checkbox"] {
    width: auto;
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
}
.modal label.checkbox-label input[type="checkbox"]:disabled {
    cursor: not-allowed;
}