/* ./adm/css/styles.css */
/* Adopt CommonAI landing theme tokens while keeping existing var names */
:root {
    /* Primary/action color (use landing accent2 purple) */
    --primary-color: #8B5CF6;
    --primary-hover: #7C3AED;
    /* Dark theme background + cards from landing page */
    --background-color: #0b0d12; /* maps to --bg */
    --card-background: #11151f;  /* maps to --card */
    --text-color: #e8eef9;       /* maps to --txt */
    --muted-color: #9aa3b2;      /* maps to --muted */
    --error-color: #ef4444;
    /* Extra accents (not widely used, but available) */
    --accent1: #6EE7F9;
    --accent2: #8B5CF6;
    --accent3: #F43F5E;
    --ring: rgba(110,231,249,.6);
}

/* Action buttons layout: 2 per row, full-width */
.action-cell {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}
.action-cell button {
    width: 100%;
}

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

body {
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Inter, Arial, sans-serif;
    /* Landing background: two radial accents over dark base */
    background: radial-gradient(1200px 600px at 10% -10%, rgba(139,92,246,.25), transparent 50%),
                radial-gradient(1000px 600px at 90% 10%, rgba(244,63,94,.2), transparent 50%),
                var(--background-color);
    color: var(--text-color);
    line-height: 1.5;
}

/* Layout helpers for sticky footer */
html, body { height: 100%; }
body { display: flex; flex-direction: column; }
.main-content { flex: 1; }
.site-footer {
    padding: 0.75rem 0;
    border-top: 1px solid rgba(255,255,255,0.08);
    color: var(--muted-color);
}
.site-footer a { color: #cfd6e6; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: var(--card-background);
    padding: 2rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 30px rgba(0,0,0,.25), 0 0 0 1px rgba(255,255,255,.06) inset;
    width: 100%;
    max-width: 400px;
}

.login-card h1 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--text-color);
    font-size: 1.5rem;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid rgba(255,255,255,0.12);
    background: #0f1520;
    color: var(--text-color);
    border-radius: 0.375rem;
    font-size: 1rem;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--ring);
}

.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border: none;
    width: 100%;
}

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

.error-message {
    color: var(--error-color);
    text-align: center;
    margin-top: 1rem;
    display: none;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .login-card {
        margin: 1rem;
        padding: 1.5rem;
    }
}
/* Overlay for schedule run in progress */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
}
.modal-overlay .overlay-message {
    background: rgba(0, 0, 0, 0.75);
    color: #ffffff;
    padding: 1rem 2rem;
    border-radius: 0.5rem;
    font-size: 1.25rem;
    text-align: center;
}

/* Dashboard Layout */
.admin-header {
    background: var(--card-background);
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.35), 0 0 0 1px rgba(255,255,255,.06) inset;
    padding: 1rem 0;
    margin-bottom: 3.5rem; /* increased space below the dashboard header */
}

/* Keep dashboard header title white */
.admin-header h1 { color: var(--text-color); }

/* Help page section titles only */
.help-page h2 { color: var(--primary-color); }

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-actions {
    display: flex;
    gap: 1rem;
}

.btn-secondary {
    background-color: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background-color: #4b5563;
}

/* In header actions, use primary styling for secondary buttons to match "New Bot" */
.admin-header .header-actions .btn-secondary {
    background-color: var(--primary-color);
    color: #ffffff;
    border: none;
}
.admin-header .header-actions .btn-secondary:hover {
    background-color: var(--primary-hover);
}

/* LLM modal: make "Distribute to Clients" secondary button primary-styled */
.llm-actions .btn-secondary {
    background-color: var(--primary-color);
    color: #ffffff;
    border: none;
}
.llm-actions .btn-secondary:hover {
    background-color: var(--primary-hover);
}

/* Contextual button coloring by action (attribute selectors keep logic untouched) */
/* Cancel buttons: reddish */
.btn[onclick*="cancel"],
.btn[onclick*="closeModal"] {
    background-color: var(--accent3);
    color: #ffffff;
    border: none;
}
.btn[onclick*="cancel"]:hover,
.btn[onclick*="closeModal"]:hover {
    background-color: #e11d48; /* darker red */
}

/* Edit buttons: purple */
.btn[onclick^="edit"],
.btn[onclick*="edit("] {
    background-color: var(--primary-color);
    color: #ffffff;
    border: none;
}
.btn[onclick^="edit"]:hover,
.btn[onclick*="edit("]:hover {
    background-color: var(--primary-hover);
}
/* Icon edit button in bot cards */
.btn-icon[onclick^="edit"],
.btn-icon[title*="Edit"] {
    color: var(--primary-color);
}
.btn-icon[onclick^="edit"]:hover,
.btn-icon[title*="Edit"]:hover {
    background-color: rgba(139,92,246,0.15);
}

/* Delete buttons: reddish (text/icon); retain .btn-danger where used) */
.btn-icon[onclick^="delete"],
.btn-icon.delete-bot {
    background-color: var(--accent3);
    color: #ffffff !important;
}
.btn-icon[onclick^="delete"]:hover,
.btn-icon.delete-bot:hover {
    background-color: #e11d48;
}
.btn.btn-danger { background-color: var(--accent3); border: none; color: #fff; }
.btn.btn-danger:hover { background-color: #e11d48; }

/* Link-styled delete buttons should also be filled red like Cancel */
.btn.text-danger {
    background-color: var(--accent3);
    color: #ffffff !important;
    border: none;
}
.btn.text-danger:hover { background-color: #e11d48; }

/* Add row buttons: purple */
.btn[onclick^="addSettingRow"],
.btn[onclick^="addPrePromptRow"],
.btn[onclick^="addToolRow"] {
    background-color: var(--primary-color);
    color: #ffffff;
    border: none;
}
.btn[onclick^="addSettingRow"]:hover,
.btn[onclick^="addPrePromptRow"]:hover,
.btn[onclick^="addToolRow"]:hover {
    background-color: var(--primary-hover);
}

/* Clients table: make Copy Resources and Login as purple like primary */
.btn[onclick^="openSeedResources"],
.btn[onclick^="impersonateClient"] {
    background-color: var(--primary-color);
    color: #ffffff !important;
    border: none;
    text-decoration: none;
}
.btn[onclick^="openSeedResources"]:hover,
.btn[onclick^="impersonateClient"]:hover {
    background-color: var(--primary-hover);
}

/* Schedules: View Logs and Run Now buttons in purple */
.btn[onclick^="viewScheduleLogs"],
.btn[onclick^="runSchedule"] {
    background-color: var(--primary-color);
    color: #ffffff !important;
    border: none;
}
.btn[onclick^="viewScheduleLogs"]:hover,
.btn[onclick^="runSchedule"]:hover {
    background-color: var(--primary-hover);
}

/* Events: make "API Docs" button purple and same visual weight as New Event */
.schedule-actions .btn[onclick^="showEventApiDocs"] {
    background-color: var(--primary-color);
    color: #ffffff !important;
    border: none;
}
.schedule-actions .btn[onclick^="showEventApiDocs"]:hover {
    background-color: var(--primary-hover);
}
/* In Events modal, stack buttons with spacing and equal width like Tools */
#eventsModal .schedule-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
#eventsModal .schedule-actions .btn {
    width: 100%;
}

/* Bot Grid */
.bot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    padding: 1rem 0;
}

.bot-card {
    background: var(--card-background);
    border-radius: 0.5rem;
    box-shadow: 0 10px 30px rgba(0,0,0,.25), 0 0 0 1px rgba(255,255,255,.06) inset;
    overflow: hidden;
}

.bot-card-header {
    padding: 1rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.bot-card-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.bot-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-color);
    border-radius: 0.375rem;
    transition: background-color 0.2s;
}

.btn-icon:hover {
    background-color: rgba(255,255,255,0.06);
}

.delete-bot {
    color: var(--error-color);
}

.bot-card-body {
    padding: 1rem;
}

.bot-title {
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.bot-description {
    color: #6b7280;
    font-size: 0.875rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

/* Make modal-content a positioning context for overlay */
.modal-content {
    position: relative;
    background: var(--card-background);
    margin: 2rem auto;
    padding: 0;
    width: 90%;
    max-width: 600px;
    border-radius: 0.5rem;
    box-shadow: 0 20px 60px rgba(0,0,0,.45), 0 0 0 1px rgba(255,255,255,.06) inset;
    /* allow vertical scrolling if content overflows */
    max-height: 80vh;
    overflow-y: auto;
    /* prevent minor horizontal overflow causing scrollbars */
    overflow-x: hidden;
}

.modal-large {
    max-width: 1000px;
}

.modal-header {
    padding: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
}

.close {
    font-size: 1.5rem;
    font-weight: 700;
    color: #6b7280;
    cursor: pointer;
}

.close:hover {
    color: var(--text-color);
}

.modal-body {
    padding: 1rem;
}

.modal-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Form Elements */
textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid rgba(255,255,255,0.12);
    background: #0f1520;
    color: var(--text-color);
    border-radius: 0.375rem;
    font-size: 1rem;
    font-family: inherit;
}

/* Tabs */
.tab-container {
    display: flex;
    flex-direction: column;
}

.tab-buttons {
    display: flex;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 1rem;
}

.tab-btn {
    padding: 0.5rem 1rem;
    border: none;
    background: none;
    cursor: pointer;
    color: #6b7280;
    font-weight: 500;
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
}

.tab-pane {
    display: none;
    padding: 1rem 0;
}

.tab-pane.active {
    display: block;
}

.memory-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.memory-content {
    background: rgba(255,255,255,0.03);
    padding: 1rem;
    border-radius: 0.375rem;
    min-height: 300px;
    max-height: 500px;
    overflow-y: auto;
}

.form-select {
    padding: 0.5rem;
    border: 1px solid rgba(255,255,255,0.12);
    background: #0f1520;
    color: var(--text-color);
    border-radius: 0.375rem;
    font-size: 1rem;
    min-width: 200px;
}

/* Generic form control styling (inputs/textareas/selects using .form-control) */
.form-control {
    padding: 0.5rem;
    border: 1px solid rgba(255,255,255,0.12);
    background: #0f1520;
    color: var(--text-color);
    border-radius: 0.375rem;
    font-size: 1rem;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--ring);
}
::placeholder { color: var(--muted-color); opacity: 1; }

/* Tables (dark theme) */
.table { width: 100%; border-collapse: collapse; color: var(--text-color); }
.table th, .table td { border-bottom: 1px solid rgba(255,255,255,0.08); padding: 0.5rem; text-align: left; }
.table-striped tbody tr:nth-child(odd) { background: rgba(255,255,255,0.03); }

/* Responsive Adjustments */
@media (max-width: 640px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .modal-content {
        margin: 1rem;
        width: auto;
    }
    
    .tab-buttons {
        flex-wrap: wrap;
    }
}

/* Add to ./adm/css/styles.css */

.add-trait-form {
    background: var(--card-background);
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 10px 30px rgba(0,0,0,.25), 0 0 0 1px rgba(255,255,255,.06) inset;
}

.trait-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.form-actions .form-select {
    flex: 1;
}

.form-actions .btn {
    white-space: nowrap;
}

.token-input-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.token-input-group input {
    flex: 1;
}

.token-input-group .btn {
    padding: 0.5rem;
    min-width: 40px;
}

/* Add to ./adm/css/styles.css */

.launch-bot {
    color: #2563eb;
}

.launch-bot:hover {
    color: #a78bfa;
}

.instruction-item {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
    position: relative;
}

.instruction-item::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.5rem;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background-color: #2563eb;
}

.launch-actions {
    margin-top: 2rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.launch-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
}

/* Improve spacing for Event API Docs modal */
#eventApiDocsModal .modal-body {
    padding: 1.5rem 2rem; /* add extra space away from borders */
}
#eventApiDocsModal .modal-body p {
    margin-bottom: 0.75rem;
}
#eventApiDocsModal .modal-body ul {
    margin-left: 1.25rem;
    margin-bottom: 0.75rem;
}
#eventApiDocsModal pre {
    margin-top: 0.5rem;
    padding: 0.75rem 1rem;
}
