/* ipChat Demo Styles */
:root {
    --primary-color: #5B7FFF;
    --primary-hover: #4A6FE8;
    --text-color: #1F2937;
    --text-secondary: #6B7280;
    --bg-color: #F3F4F6;
    --card-bg: #FFFFFF;
    --border-color: #E5E7EB;
    --success-color: #10B981;
    --warning-color: #F59E0B;
    --error-color: #EF4444;
}

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

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

.demo-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.demo-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 30px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 28px;
}

.logo-text {
    font-size: 22px;
    font-weight: 600;
    color: var(--primary-color);
}

.demo-badge {
    background: var(--primary-color);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.error-state {
    text-align: center;
    color: var(--error-color);
}

.error-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 16px;
}

/* Agent Info */
.agent-info {
    flex: 1;
}

.info-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.info-card h1 {
    font-size: 28px;
    margin-bottom: 8px;
}

.agent-website a {
    color: var(--primary-color);
    text-decoration: none;
}

.agent-website a:hover {
    text-decoration: underline;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

@media (max-width: 600px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* System Prompt */
.system-prompt-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.system-prompt-card h2 {
    font-size: 18px;
}

.toggle-btn {
    background: none;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-btn:hover {
    background: var(--primary-color);
    color: white;
}

.prompt-preview,
.prompt-full {
    background: var(--bg-color);
    padding: 16px;
    border-radius: 8px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 400px;
    overflow-y: auto;
}

/* Instructions Card */
.instructions-card h2 {
    font-size: 18px;
    margin-bottom: 12px;
}

.instructions-card p {
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.test-suggestions {
    background: var(--bg-color);
    padding: 16px;
    border-radius: 8px;
}

.test-suggestions p {
    margin-bottom: 8px;
    color: var(--text-color);
}

.test-suggestions ul {
    margin-left: 20px;
    color: var(--text-secondary);
}

.test-suggestions li {
    margin-bottom: 4px;
}

/* Footer */
.demo-footer {
    padding: 20px 0;
    margin-top: 30px;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

.demo-footer a {
    color: var(--primary-color);
    text-decoration: none;
}

.demo-footer a:hover {
    text-decoration: underline;
}

/* =============================================== */
/* Admin Page Styles */
/* =============================================== */

.admin-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.admin-header h1 {
    font-size: 24px;
}

/* Login Form */
.login-card {
    max-width: 400px;
    margin: 80px auto;
}

.login-card h2 {
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(91, 127, 255, 0.1);
}

.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* Agents Table */
.agents-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.agents-table th,
.agents-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.agents-table th {
    background: var(--bg-color);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

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

.agents-table tr:hover td {
    background: rgba(91, 127, 255, 0.03);
}

.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-active {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.status-inactive {
    background: rgba(107, 114, 128, 0.1);
    color: var(--text-secondary);
}

.demo-url-cell {
    max-width: 300px;
}

.demo-url {
    display: flex;
    align-items: center;
    gap: 8px;
}

.demo-url a {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 13px;
    word-break: break-all;
}

.demo-url a:hover {
    text-decoration: underline;
}

.copy-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.copy-btn:hover {
    opacity: 1;
}

.no-demo {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 13px;
}

.actions-cell {
    white-space: nowrap;
}

.actions-cell button {
    margin-right: 8px;
}

.actions-cell button:last-child {
    margin-right: 0;
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-color);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 10000;
    animation: fadeInUp 0.3s ease;
}

.toast.success {
    background: var(--success-color);
}

.toast.error {
    background: var(--error-color);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* 404 Page */
.error-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
    text-align: center;
    padding: 40px 20px;
}

.error-page .error-code {
    font-size: 120px;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1;
    margin-bottom: 16px;
}

.error-page h1 {
    font-size: 28px;
    margin-bottom: 12px;
}

.error-page p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    max-width: 400px;
}

/* =============================================== */
/* Live Preview Mode */
/* =============================================== */

.preview-btn {
    margin: 20px 0;
    width: 100%;
}

.preview-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 999990;
    background: #fff;
}

.preview-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.preview-close-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 999995;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.preview-close-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
}
