/* KLAIRE Admin Panel Styles */
/* Extends style.css design tokens */

/* ========== LOGIN OVERLAY ========== */
.login-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-body);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.login-panel {
    padding: 48px;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-logo {
    font-size: 2rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.login-panel h2 {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.login-panel input {
    width: 100%;
    padding: 14px 16px;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
}

.login-panel input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.1);
}

.login-panel input::placeholder {
    color: var(--text-secondary);
}

.error-text {
    color: var(--accent-pink);
    font-size: 0.875rem;
    margin-top: 12px;
}

/* ========== ADMIN CONTAINER ========== */
.admin-container {
    display: grid;
    grid-template-rows: auto 1fr;
    height: 100vh;
    overflow: hidden;
}

/* ========== ADMIN HEADER ========== */
.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    border-radius: 0;
    border-bottom: 1px solid var(--border-color);
}

.header-logo {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.header-logo .logo-link {
    text-decoration: none;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.admin-nav {
    display: flex;
    gap: 8px;
}

.nav-btn {
    padding: 8px 20px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

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

.nav-btn.active {
    background: rgba(0, 240, 255, 0.1);
    border-color: rgba(0, 240, 255, 0.3);
    color: var(--accent-blue);
}

.logout-btn {
    padding: 8px 20px;
    background: rgba(255, 0, 110, 0.1);
    border: 1px solid rgba(255, 0, 110, 0.3);
    border-radius: 6px;
    color: var(--accent-pink);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.logout-btn:hover {
    background: rgba(255, 0, 110, 0.2);
}

/* ========== MAIN CONTENT ========== */
.admin-main {
    padding: 24px;
    overflow-y: auto;
}

.tab-content {
    display: none;
    animation: fadeIn 0.2s ease;
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.tab-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.tab-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 4px;
}

.filter-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

.filter-controls select {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
}

.filter-controls select:focus {
    outline: none;
    border-color: var(--accent-blue);
}

/* ========== BUTTONS ========== */
.primary-btn {
    padding: 10px 24px;
    background: var(--gradient-primary);
    border: none;
    border-radius: 6px;
    color: #000;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.primary-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.secondary-btn {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

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

.cancel-btn {
    padding: 10px 24px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

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

.danger-btn {
    padding: 10px 24px;
    background: rgba(255, 0, 110, 0.1);
    border: 1px solid var(--accent-pink);
    border-radius: 6px;
    color: var(--accent-pink);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.danger-btn:hover {
    background: rgba(255, 0, 110, 0.2);
}

/* ========== CARD LIST ========== */
.card-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.loading {
    text-align: center;
    padding: 48px;
    color: var(--text-secondary);
}

/* ========== SESSION ITEMS ========== */
.session-item {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s ease;
}

.session-item:hover {
    border-color: var(--accent-blue);
    background: rgba(0, 240, 255, 0.02);
}

.session-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.session-id {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.session-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.session-status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.session-status.active {
    background: rgba(0, 240, 255, 0.1);
    color: var(--accent-blue);
}

.session-status.completed {
    background: rgba(57, 255, 20, 0.1);
    color: var(--accent-green);
}

.session-turns {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.session-outcome {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.session-outcome.deal_closed {
    color: var(--accent-green);
}

/* Stuck Session Indicators */
.session-item.stuck {
    border-color: rgba(255, 200, 0, 0.4);
    background: rgba(255, 200, 0, 0.03);
}

.stuck-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 700;
    margin-left: 8px;
    vertical-align: middle;
}

.stuck-badge.warning {
    background: rgba(255, 200, 0, 0.2);
    color: #ffcc00;
}

.stuck-badge.error {
    background: rgba(255, 0, 110, 0.2);
    color: var(--accent-pink);
}

/* ========== AGENT CARDS ========== */
.admin-agent-card {
    display: grid;
    grid-template-columns: auto 1fr auto auto auto auto;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    transition: all 0.15s ease;
}

.admin-agent-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

.admin-agent-card .agent-icon {
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.admin-agent-card .agent-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.admin-agent-card .agent-name {
    font-weight: 600;
    color: var(--text-primary);
}

.admin-agent-card .agent-type {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.agent-type-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.agent-type-badge.buyer {
    background: rgba(0, 240, 255, 0.1);
    color: var(--accent-blue);
}

.agent-type-badge.seller {
    background: rgba(255, 0, 110, 0.1);
    color: var(--accent-pink);
}

.agent-type-badge.other {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
}

/* Toggle Switch */
.agent-toggle {
    width: 48px;
    height: 24px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
}

.agent-toggle.active {
    background: var(--accent-green);
}

.agent-toggle::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.2s;
}

.agent-toggle.active::after {
    transform: translateX(24px);
}

.edit-btn, .delete-btn {
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.edit-btn {
    background: rgba(0, 240, 255, 0.1);
    border: 1px solid rgba(0, 240, 255, 0.3);
    color: var(--accent-blue);
}

.edit-btn:hover {
    background: rgba(0, 240, 255, 0.2);
}

.delete-btn {
    background: rgba(255, 0, 110, 0.1);
    border: 1px solid rgba(255, 0, 110, 0.3);
    color: var(--accent-pink);
}

.delete-btn:hover {
    background: rgba(255, 0, 110, 0.2);
}

/* ========== SCENARIOS GRID ========== */
.scenarios-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.scenario-card {
    padding: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    transition: all 0.15s ease;
}

.scenario-card:hover {
    border-color: var(--accent-blue);
    transform: translateY(-2px);
}

.scenario-card .vertical-badge {
    display: inline-block;
    padding: 4px 12px;
    background: rgba(0, 240, 255, 0.1);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-blue);
    margin-bottom: 12px;
}

.scenario-card h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.scenario-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 16px;
}

.agent-preview {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    font-size: 1.25rem;
}

.apply-scenario-btn {
    width: 100%;
    padding: 12px;
    background: transparent;
    border: 1px solid var(--accent-blue);
    border-radius: 6px;
    color: var(--accent-blue);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.apply-scenario-btn:hover {
    background: rgba(0, 240, 255, 0.1);
}

/* ========== METRICS DASHBOARD ========== */
.metrics-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
}

.metric-card {
    padding: 24px;
    text-align: center;
}

.metric-card .metric-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

.metric-card .metric-value {
    font-size: 2rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-primary);
}

.accent-blue { color: var(--accent-blue) !important; }
.accent-green { color: var(--accent-green) !important; }
.accent-pink { color: var(--accent-pink) !important; }

/* ========== MODALS ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.15s ease;
}

.modal {
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.2s ease;
}

.modal-wide {
    max-width: 900px;
}

.modal-small {
    max-width: 400px;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

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

/* ========== FORMS ========== */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    padding: 24px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group.full-width {
    grid-column: 1 / -1;
    padding: 0 24px;
}

.form-group label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.1);
}

.form-group textarea {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    resize: vertical;
    min-height: 120px;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.checkbox-group {
    padding: 0 24px 16px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    text-transform: none;
    font-size: 0.9rem;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-green);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
}

/* ========== SESSION MODAL ========== */

/* Session Summary */
.session-summary {
    padding: 16px 24px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border-color);
}

.summary-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.summary-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.summary-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.summary-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.summary-value.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    width: fit-content;
}

.summary-value.status-badge.active {
    background: rgba(0, 240, 255, 0.15);
    color: var(--accent-blue);
}

.summary-value.status-badge.completed {
    background: rgba(57, 255, 20, 0.15);
    color: var(--accent-green);
}

.summary-value.status-badge.stuck {
    background: rgba(255, 200, 0, 0.2);
    color: #ffcc00;
    animation: pulse-warning 2s infinite;
}

@keyframes pulse-warning {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.summary-value.deal-closed {
    color: var(--accent-green);
    font-weight: 600;
}

.summary-value.deal-failed {
    color: var(--accent-pink);
}

/* Session Metrics Panel */
.session-metrics {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
}

.session-metrics h4 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 12px;
}

.session-metrics .metrics-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
}

.session-metrics .metric-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.session-metrics .metric-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.session-metrics .metric-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent-blue);
}

/* Participants Panel */
.session-participants {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
}

.session-participants h4 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 12px;
}

.participants-list {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.participant-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    min-width: 180px;
}

.participant-card.buyer {
    border-color: rgba(0, 240, 255, 0.3);
    background: rgba(0, 240, 255, 0.05);
}

.participant-card.seller {
    border-color: rgba(255, 0, 110, 0.3);
    background: rgba(255, 0, 110, 0.05);
}

.participant-icon {
    font-size: 1.25rem;
}

.participant-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.participant-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.participant-type {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.participant-count {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 4px;
}

/* Transcript Section */
.transcript-section {
    padding: 16px 24px 0;
}

.transcript-section h4 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 12px;
}

.transcript-feed {
    max-height: 350px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 16px;
}

.transcript-message {
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    border-left: 3px solid var(--border-color);
}

.transcript-message.buyer {
    border-left-color: var(--accent-blue);
}

.transcript-message.seller {
    border-left-color: var(--accent-pink);
}

.transcript-message .message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.agent-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

.agent-badge.buyer {
    background: rgba(0, 240, 255, 0.1);
    color: var(--accent-blue);
}

.agent-badge.seller {
    background: rgba(255, 0, 110, 0.1);
    color: var(--accent-pink);
}

.agent-badge.other {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
}

.agent-badge .agent-icon {
    font-size: 0.9rem;
}

.agent-badge .agent-name {
    font-weight: 600;
}

.turn-number {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 4px;
}

.transcript-message .content {
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
}

/* Modal Actions */
.modal-actions {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.confirm-message {
    padding: 20px 24px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ========== EMPTY STATES ========== */
.empty-state {
    text-align: center;
    padding: 48px;
    color: var(--text-secondary);
}

.empty-state h3 {
    font-size: 1.125rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .admin-header {
        flex-wrap: wrap;
        gap: 12px;
    }

    .admin-nav {
        order: 3;
        width: 100%;
        justify-content: center;
    }

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

    .summary-row {
        grid-template-columns: 1fr 1fr;
    }

    .session-metrics .metrics-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .participants-list {
        flex-direction: column;
    }

    .participant-card {
        min-width: auto;
        width: 100%;
    }

    .admin-agent-card {
        grid-template-columns: auto 1fr;
        gap: 12px;
    }

    .admin-agent-card .agent-toggle,
    .admin-agent-card .edit-btn,
    .admin-agent-card .delete-btn,
    .admin-agent-card .agent-type-badge {
        grid-column: 1 / -1;
        justify-self: start;
    }

    .modal-actions {
        flex-direction: column;
    }

    .modal-actions button {
        width: 100%;
    }
}
