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

body {
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 14px;
    background: #f5f5f5;
    color: #1a1a1a;
}

/* ── Shell ──────────────────────────────────────────────────────────────────── */
.admin-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 200px;
    background: #18181b;
    color: #e4e4e7;
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    gap: 24px;
    flex-shrink: 0;
}

.sidebar-brand {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.02em;
}

.sidebar ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar a, .sidebar .logout-link {
    display: block;
    padding: 8px 12px;
    border-radius: 6px;
    color: #a1a1aa;
    text-decoration: none;
    transition: background 0.1s, color 0.1s;
}

.sidebar a:hover, .sidebar a.active {
    background: #27272a;
    color: #fff;
}

.sidebar .logout-link { margin-top: auto; }
            
.sidebar-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid #27272a;
}

/* ── Language Switcher ──────────────────────────────────────────────────────── */
.language-switcher {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
}

.lang-btn {
    background: transparent;
    border: 2px solid transparent;
    border-radius: 6px;
    padding: 6px;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
    transition: all 0.15s ease;
    opacity: 0.6;
}

.lang-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.05);
}

.lang-btn.active {
    opacity: 1;
    border-color: #6366f1;
    background: rgba(99, 102, 241, 0.1);
}

.client-nav .lang-btn {
    padding: 4px 6px;
    font-size: 20px;
}

.client-nav .lang-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

.content {
    flex: 1;
    padding: 32px;
    max-width: 1000px;
}

/* ── Login ──────────────────────────────────────────────────────────────────── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #f5f5f5;
}

.login-card {
    background: #fff;
    border: 1px solid #e4e4e7;
    border-radius: 12px;
    padding: 40px;
    width: 360px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.login-card h1 {
    font-size: 20px;
    font-weight: 700;
}

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.form-group label { font-weight: 500; color: #3f3f46; }

.form-group input, .config-form input {
    padding: 8px 12px;
    border: 1px solid #d4d4d8;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
    width: 100%;
}

.form-group input:focus, .config-form input:focus {
    border-color: #6366f1;
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: opacity 0.1s;
}

.btn:hover { opacity: 0.85; }

.btn-primary { background: #6366f1; color: #fff; }
.btn-danger  { background: #ef4444; color: #fff; }
.btn-ghost   { background: transparent; color: #71717a; border: 1px solid #d4d4d8; }
.btn-sm      { padding: 4px 10px; font-size: 13px; }

/* ── Alerts ─────────────────────────────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert-error   { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }

/* ── Admin product grid ─────────────────────────────────────────────────────────────── */
.product-admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.product-admin-card {
    background: #fff;
    border: 1px solid #e4e4e7;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.pac-thumb {
    height: 160px;
    background: #f4f4f5;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.pac-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pac-no-img {
    font-size: 12px;
    color: #a1a1aa;
}

.pac-body {
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.pac-title {
    font-size: 15px;
    font-weight: 700;
    color: #18181b;
}

.pac-client {
    display: flex;
    gap: 4px;
    align-items: center;
}

.pac-meta {
    display: flex;
    gap: 10px;
    font-size: 12px;
    color: #52525b;
    margin-top: 2px;
}

.pac-prompt {
    font-size: 12px;
    color: #71717a;
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Table ──────────────────────────────────────────────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid #e4e4e7;
    border-radius: 8px;
    overflow: hidden;
}

.data-table th {
    background: #fafafa;
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    color: #52525b;
    border-bottom: 1px solid #e4e4e7;
}

.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #f4f4f5;
    vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }

.apikey-cell { display: flex; align-items: center; gap: 8px; font-family: monospace; }
.notes-cell  { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #52525b; }

/* ── Create client bar ──────────────────────────────────────────────────────── */
.create-client {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.create-client input {
    padding: 8px 12px;
    border: 1px solid #d4d4d8;
    border-radius: 6px;
    font-size: 14px;
    width: 260px;
    outline: none;
}

.create-client input:focus { border-color: #6366f1; }

h2 { font-size: 20px; font-weight: 700; margin-bottom: 20px; }

.empty { color: #71717a; margin: 20px 0; }

.config-form { max-width: 480px; }

.badge-default {
    display: inline-block;
    background: #6366f1;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}

.data-table select {
    padding: 4px 8px;
    border: 1px solid #d4d4d8;
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
    cursor: pointer;
}

/* ── Help page ──────────────────────────────────────────────────────────────── */
.help-intro { color: #52525b; margin-bottom: 24px; }

.help-section {
    background: #fff;
    border: 1px solid #e4e4e7;
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 20px;
}

.help-section h3 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 10px;
    color: #18181b;
}

.help-section h4 {
    font-size: 13px;
    font-weight: 600;
    color: #52525b;
    margin: 16px 0 6px;
}

.help-section p { color: #3f3f46; margin-bottom: 8px; line-height: 1.6; }

.help-section ul { padding-left: 20px; color: #3f3f46; line-height: 1.8; }

.help-section pre {
    background: #18181b;
    color: #e4e4e7;
    border-radius: 6px;
    padding: 14px 16px;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.6;
}

.help-section code {
    font-family: ui-monospace, monospace;
    font-size: 13px;
    background: #f4f4f5;
    padding: 2px 5px;
    border-radius: 4px;
    color: #18181b;
}

.help-section pre code {
    background: none;
    padding: 0;
    color: inherit;
}

/* ── Client usage page ──────────────────────────────────────────────────────── */
.usage-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
}

.back-link {
    font-size: 13px;
    color: #6366f1;
    text-decoration: none;
    display: block;
    margin-bottom: 6px;
}

.back-link:hover { text-decoration: underline; }

.usage-notes { color: #71717a; font-size: 13px; margin-top: 4px; }

.usage-stats {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border: 1px solid #e4e4e7;
    border-radius: 8px;
    padding: 16px 20px;
    min-width: 140px;
    flex: 1;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: #18181b;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-size: 12px;
    color: #71717a;
    margin-top: 4px;
}

/* ── Confirmation modal ─────────────────────────────────────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-card {
    background: #fff;
    border-radius: 12px;
    padding: 28px 32px;
    width: 360px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.modal-card h3 { font-size: 16px; font-weight: 700; }
.modal-card p  { color: #3f3f46; font-size: 14px; line-height: 1.5; }

.modal-card input[type="password"] {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d4d4d8;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
}

.modal-card input[type="password"]:focus { border-color: #6366f1; }

/* ── Test page ──────────────────────────────────────────────────────────────── */
.test-grid {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.test-slot {
    display: flex;
    flex-direction: column;
    flex: 1 1 200px;
    min-width: 180px;
}

.test-prompt-slot { flex: 2 1 260px; }

.form-label { font-weight: 500; color: #3f3f46; margin-bottom: 6px; font-size: 14px; }

.test-prompt {
    flex: 1;
    min-height: 120px;
    padding: 8px 12px;
    border: 1px solid #d4d4d8;
    border-radius: 6px;
    font-size: 14px;
    resize: vertical;
    font-family: inherit;
    outline: none;
}

.test-prompt:focus { border-color: #6366f1; }

.drop-zone {
    border: 2px dashed #d4d4d8;
    border-radius: 8px;
    background: #fafafa;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px;
    transition: border-color 0.15s, background 0.15s;
    cursor: default;
}

.drop-zone.dragover {
    border-color: #6366f1;
    background: #eef2ff;
}

.drop-label { font-weight: 600; color: #3f3f46; font-size: 13px; }
.drop-hint  { color: #a1a1aa; font-size: 12px; }

.image-preview {
    max-width: 100%;
    max-height: 160px;
    border-radius: 6px;
    object-fit: contain;
}

.drop-url { margin-top: 6px; }

.drop-url input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #d4d4d8;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
}

.drop-url input:focus { border-color: #6366f1; }

.result-box {
    background: #fff;
    border: 1px solid #e4e4e7;
    border-radius: 8px;
    padding: 20px;
    margin-top: 8px;
}

.result-label {
    font-weight: 600;
    color: #52525b;
    font-size: 13px;
    margin-bottom: 12px;
}

.result-box pre {
    background: #18181b;
    color: #e4e4e7;
    border-radius: 6px;
    padding: 14px 16px;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ── Client Portal Layout ────────────────────────────────────────────────── */
.client-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.client-header {
    background: #18181b;
    color: #e4e4e7;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 52px;
    flex-shrink: 0;
}

.client-brand {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.02em;
}

.client-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.client-nav a {
    display: block;
    padding: 6px 12px;
    border-radius: 6px;
    color: #a1a1aa;
    text-decoration: none;
    transition: background 0.1s, color 0.1s;
    font-size: 14px;
    cursor: pointer;
}

.client-nav a:hover, .client-nav a.active {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.client-content {
    flex: 1;
    padding: 32px 40px;
    max-width: 960px;
}

.api-key-card {
    background: #fff;
    border: 1px solid #e4e4e7;
    border-radius: 8px;
    padding: 16px 20px;
    margin-top: 20px;
}

.api-key-display {
    font-family: monospace;
    font-size: 14px;
    background: #f4f4f5;
    padding: 6px 10px;
    border-radius: 4px;
    word-break: break-all;
}
