/* ═══════════════════════════════════════════════
   AiSsis Admin Panel — Design System
   ═══════════════════════════════════════════════ */

:root {
    /* Color palette — dark neon */
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a1f2e;
    --bg-card-hover: #222840;
    --bg-input: #0d1220;
    --bg-modal: rgba(0, 0, 0, 0.7);

    --accent: #6c5ce7;
    --accent-hover: #7c6ff7;
    --accent-glow: rgba(108, 92, 231, 0.3);
    --danger: #e74c3c;
    --danger-hover: #ff5e4d;
    --success: #2ecc71;
    --warning: #f39c12;

    --text-primary: #e8eaed;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    --border: #2d3348;
    --border-focus: #6c5ce7;

    --radius: 0.75rem;
    --radius-sm: 0.5rem;
    --radius-lg: 1rem;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: 0.2s ease;
}

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

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1.5;
    min-height: 100vh;
}

/* ─── Typography ─────────────────────────────── */

h1 { font-size: 2.5rem; font-weight: 700; line-height: 1.2; }
h2 { font-size: 1.5rem; font-weight: 600; line-height: 1.3; margin-bottom: 1rem; }
h3 { font-size: 1.25rem; font-weight: 600; line-height: 1.3; margin-bottom: 0.5rem; }

@media (max-width: 768px) {
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.125rem; }
}

/* ─── Screens ────────────────────────────────── */

.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

/* ─── Login Screen ───────────────────────────── */

.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
    width: 100%;
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
    letter-spacing: 0.05em;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-top: 0.5rem;
}

.login-form {
    width: 92%;
    max-width: 24rem;
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* ─── Inputs ─────────────────────────────────── */

.input-group {
    margin-bottom: 1rem;
}

.input-group label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    font-weight: 500;
}

input[type="text"],
input[type="password"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 1rem;
    transition: border-color var(--transition);
    min-height: 2.75rem;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea { resize: vertical; }

.input-sm {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
}
.input-icon { max-width: 6rem; text-align: center; }
.input-url { flex: 1; }

/* ─── Buttons ────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    min-height: 2.75rem;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    color: #fff;
}
.btn-primary:hover { background: linear-gradient(135deg, var(--accent-hover), #9b7ff8); transform: translateY(-1px); }

.btn-accent {
    background: var(--accent);
    color: #fff;
}
.btn-accent:hover { background: var(--accent-hover); transform: translateY(-1px); }

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    min-height: 2.25rem;
}

.btn-full { width: 100%; }

/* ─── Topbar ─────────────────────────────────── */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.topbar-title { font-size: 1.25rem; font-weight: 600; }

@media (max-width: 768px) {
    .topbar { padding: 0.75rem 1rem; }
    .topbar-right { gap: 0.25rem; }
    .topbar-right .btn { padding: 0.5rem 0.75rem; font-size: 0.75rem; }
}

/* ─── Dashboard ──────────────────────────────── */

.dashboard-content {
    padding: 1.5rem;
    max-width: 80rem;
    margin: 0 auto;
    width: 95%;
}

@media (max-width: 768px) {
    .dashboard-content { padding: 1rem 0; width: 92%; }
}

.keys-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
    gap: 1rem;
}

@media (max-width: 768px) {
    .keys-grid {
        grid-template-columns: 1fr;
    }
}

.key-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.key-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), #8b5cf6);
    opacity: 0;
    transition: opacity var(--transition);
}

.key-card:hover {
    border-color: var(--accent);
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
.key-card:hover::before { opacity: 1; }

.key-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.key-card-avatar {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: var(--bg-input);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 700;
    flex-shrink: 0;
}

.key-card-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.key-card-name {
    font-size: 1.125rem;
    font-weight: 600;
}

.key-card-meta {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.key-card-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    font-size: 0.875rem;
}

.status-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
}
.status-dot.active { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.inactive { background: var(--danger); }

/* ─── Settings Screen ────────────────────────── */

.settings-content {
    padding: 1.5rem;
    max-width: 55rem;
    margin: 0 auto;
    width: 95%;
}

@media (max-width: 768px) {
    .settings-content { padding: 1rem 0; width: 92%; }
}

.settings-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 768px) {
    .form-grid { grid-template-columns: 1fr; }
}

.full-width { grid-column: 1 / -1; }

/* Token */
.token-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.token-value {
    background: var(--bg-input);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-family: monospace;
    font-size: 0.875rem;
    color: var(--accent);
    border: 1px solid var(--border);
    word-break: break-all;
    flex: 1;
}

/* Avatar */
.avatar-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.avatar-preview {
    width: 4rem;
    height: 4rem;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}

/* Test Chat Section */
.test-chat-section {
    border: 1px solid var(--accent);
    background: rgba(17, 24, 39, 0.95);
}

.test-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.test-chat-messages {
    height: 320px;
    max-height: 50vh;
    overflow-y: auto;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.test-chat-msg {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    font-size: 0.9375rem;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
}

.test-chat-msg.assistant {
    align-self: flex-start;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.test-chat-msg.user {
    align-self: flex-end;
    background: var(--accent);
    color: #fff;
}

.test-chat-msg.error {
    align-self: flex-start;
    background: rgba(231, 76, 60, 0.15);
    color: var(--danger);
    border: 1px solid rgba(231, 76, 60, 0.3);
}

.test-chat-input-row {
    display: flex;
    gap: 0.5rem;
}

.test-chat-input-row input {
    flex: 1;
}

/* Buttons list */
.buttons-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.button-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.button-item-icon { font-size: 0.875rem; color: var(--accent); flex-shrink: 0; }
.button-item-label { font-weight: 500; flex-shrink: 0; }
.button-item-url { color: var(--text-muted); font-size: 0.875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.button-item-remove {
    background: none; border: none; color: var(--danger);
    cursor: pointer; font-size: 1rem; padding: 0.25rem;
    min-width: 2.25rem; min-height: 2.25rem;
    display: flex; align-items: center; justify-content: center;
}
.button-item-remove:hover { color: var(--danger-hover); }

.add-button-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .add-button-row { flex-direction: column; }
    .add-button-row .input-icon { max-width: 100%; }
}

/* Embed code */
.embed-code {
    background: var(--bg-input);
    padding: 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-family: monospace;
    font-size: 0.875rem;
    color: var(--success);
    white-space: pre-wrap;
    word-break: break-all;
    margin-bottom: 0.75rem;
    line-height: 1.6;
}

/* ─── Empty State ────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 4rem 1.5rem;
    color: var(--text-muted);
}

/* ─── Error Text ─────────────────────────────── */

.error-text {
    color: var(--danger);
    font-size: 0.875rem;
    margin-top: 0.75rem;
    text-align: center;
}

/* ─── Modal ──────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
    backdrop-filter: blur(4px);
}

.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    max-width: 28rem;
    width: 92%;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 1.5rem 0;
}

.modal-header h3 { font-size: 1.25rem; }

.modal-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    min-width: 2.75rem;
    min-height: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-close-btn:hover { color: var(--text-primary); }

.modal-body {
    padding: 1.5rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0 1.5rem 1.5rem;
}

/* ─── Scrollbar ──────────────────────────────── */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Toast/Notification ─────────────────────── */

.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.5rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 200;
    animation: toastIn 0.3s ease;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(1rem); }
    to { opacity: 1; transform: translateY(0); }
}
