/* Virtual Actor Shared Variables */
:root {
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --accent-primary: #4f46e5; /* Indigo */
    --accent-secondary: #ec4899; /* Pink */
    --danger-primary: #ef4444;
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --input-bg: rgba(0, 0, 0, 0.2);
    --card-radius: 16px;
}

[data-theme="light"] {
    --glass-bg: rgba(255, 255, 255, 0.9);
    --glass-border: rgba(0, 0, 0, 0.05);
    --input-bg: rgba(255, 255, 255, 0.5);
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
}

/* =========================================
   Index Page (Actor Grid)
   ========================================= */
.actor-container {
    padding: 2rem 0;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-title {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.025em;
}

.btn-create {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 9999px;
    text-decoration: none;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
    transition: all 0.3s ease;
}

.btn-create:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.4);
    color: white;
}

.actor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.actor-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--card-radius);
    backdrop-filter: blur(12px);
    padding: 1.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.actor-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.actor-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.actor-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent-primary);
    background: #222;
}

.actor-info h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.actor-archetype {
    font-size: 0.875rem;
    color: var(--accent-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.actor-bio {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.5;
    margin-bottom: 1.5rem;
    display: -webkit-box;
    line-clamp: 3;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex-grow: 1;
}

.actor-stats {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--glass-border);
}

.stat-item {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.stat-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.actor-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-action {
    flex: 1;
    padding: 0.5rem;
    text-align: center;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.2s;
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
}

.btn-action:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent-primary);
}

.status-dot {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-active { background: #10b981; box-shadow: 0 0 8px #10b981; }
.status-dead { background: #ef4444; }

/* =========================================
   Details Page (Magazine Profile)
   ========================================= */
.profile-container {
    display: grid;
    grid-template-columns: 350px minmax(0, 1fr); /* Use minmax(0, 1fr) to prevent grid blowout */
    gap: 2rem;
    padding-top: 2rem;
}

@media (max-width: 768px) {
    .profile-container {
        grid-template-columns: minmax(0, 1fr); /* Ensure mobile column can shrink */
        display: flex; /* Switch to flex column for better mobile handling */
        flex-direction: column;
    }
}

.identity-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2rem;
    text-align: center;
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 2rem;
}

.profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--accent-primary);
    box-shadow: 0 0 20px rgba(79, 70, 229, 0.4);
    margin-bottom: 1.5rem;
}

.profile-name {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

.profile-archetype {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.25rem 1rem;
    background: rgba(79, 70, 229, 0.1);
    color: var(--accent-primary);
    border-radius: 99px;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.profile-meta {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    text-align: left;
}

.meta-row {
    display: flex;
    justify-content: space-between;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.9rem;
}

.meta-label { color: var(--text-muted); }
.meta-value { color: var(--text-primary); font-weight: 500; }

.content-section {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2rem;
    margin-bottom: 2rem;
    backdrop-filter: blur(12px);
}

.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.section-title i { color: var(--accent-secondary); }

.bio-text {
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text-secondary);
    white-space: pre-line;
}

.traits-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.trait-card {
    background: rgba(255,255,255,0.03);
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.trait-label { font-size: 0.8rem; color: var(--text-muted); display: block; margin-bottom: 0.25rem; }
.trait-value { font-size: 1rem; color: var(--text-primary); font-weight: 600; }

.action-bar {
    margin-top: 2rem;
    display: flex;
    gap: 1rem;
}

.btn-edit-profile {
    background: var(--accent-primary);
    color: white;
    padding: 0.75rem 2rem;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 600;
    transition: transform 0.2s;
    border: none;
}

.btn-back-profile {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    padding: 0.75rem 2rem;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 500;
    transition: background 0.2s;
}

.btn-edit-profile:hover { transform: translateY(-2px); color: white; }
.btn-back-profile:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }

/* =========================================
   Create / Edit Forms
   ========================================= */
.form-container {
    max-width: 900px;
    margin: 2rem auto;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 3rem;
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.form-title {
    font-size: 2rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 2.5rem;
    background: linear-gradient(135deg, var(--accent-primary), #ec4899);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.form-section {
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--glass-border);
}

.form-section:last-child { border-bottom: none; }

.section-header {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.form-group.full-width {
    grid-column: span 2;
}

.control-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.form-control {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.form-container .form-control[readonly],
.form-container .form-control:disabled {
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-secondary);
    cursor: default;
    opacity: 1;
}

[data-theme="light"] .form-container .form-control[readonly],
[data-theme="light"] .form-container .form-control:disabled {
    background-color: #e9ecef;
    color: #495057;
    opacity: 1;
}

.btn-submit {
    background: var(--accent-primary);
    color: white;
    padding: 1rem 3rem;
    border-radius: 99px;
    font-weight: 700;
    border: none;
    width: 100%;
    font-size: 1.125rem;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

.btn-back-form {
    display: block;
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
}

.btn-back-form:hover { color: var(--accent-primary); }

.text-danger {
    color: #ef4444;
    font-size: 0.8rem;
    margin-top: 0.25rem;
    display: block;
}

/* =========================================
   Delete Page
   ========================================= */
.delete-container {
    max-width: 600px;
    margin: 4rem auto;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 3rem;
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    text-align: center;
    border-top: 6px solid var(--danger-primary);
}

.warning-icon {
    font-size: 4rem;
    color: var(--danger-primary);
    margin-bottom: 1.5rem;
    animation: pulse 2s infinite;
}

.delete-title {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.delete-message {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 2.5rem;
    line-height: 1.6;
}

.agent-preview {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 1.5rem;
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
    text-align: left;
}

.preview-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
}

.preview-info h4 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.preview-info span {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.btn-delete {
    background: var(--danger-primary);
    color: white;
    padding: 1rem;
    border-radius: 12px;
    font-weight: 700;
    border: none;
    width: 100%;
    font-size: 1.125rem;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-cancel-delete {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    padding: 1rem;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 600;
    display: block;
    transition: background 0.2s;
}

.btn-delete:hover { transform: scale(1.02); }
.btn-cancel-delete:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

/* =========================================
   Permission Badges (Merged)
   ========================================= */
.badge-permission {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    display: inline-block;
    line-height: 1.2;
    margin-left: 0.5rem;
}

.level-0 { background-color: #e5e7eb; color: #374151; border: 1px solid #d1d5db; } /* Observer */
.level-1 { background-color: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; } /* ChatBot */
.level-2 { background-color: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; } /* Analyst */
.level-3 { background-color: #fffbeb; color: #92400e; border: 1px solid #fde68a; } /* Trader */
.level-4 { background-color: #ede9fe; color: #5b21b6; border: 1px solid #ddd6fe; } /* Manager */
.level-10 { background-color: #e0e7ff; color: #4338ca; border: 1px solid #c7d2fe; } /* DevEngineer */
.level-99 { background-color: #fee2e2; color: #991b1b; border: 1px solid #fecaca; } /* System */

/* =========================================
   Filter Bar (Merged)
   ========================================= */
.filter-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 2rem;
    padding: 0.5rem 0.25rem;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    position: sticky;
    top: 10px;
    z-index: 100;
}

/* Hide scrollbar for Chrome/Safari/Edge */
.filter-bar::-webkit-scrollbar {
    display: none;
}

.filter-btn {
    flex: 0 0 auto;
    padding: 0.6rem 1.2rem;
    border-radius: 2rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--glass-border);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--glass-bg);
    color: var(--text-secondary);
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.filter-btn:hover {
    background: rgba(255,255,255,0.1);
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    color: var(--text-primary);
}

.filter-btn.active {
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

/* Specific Level Filter Button colors when active - Modern Palette */
.filter-btn[data-target="all"].active { background: linear-gradient(135deg, #6b7280, #4b5563); }
.filter-btn[data-target="0"].active { background: linear-gradient(135deg, #9ca3af, #6b7280); } /* Observer */
.filter-btn[data-target="1"].active { background: linear-gradient(135deg, #3b82f6, #2563eb); } /* ChatBot */
.filter-btn[data-target="2"].active { background: linear-gradient(135deg, #10b981, #059669); } /* Analyst */
.filter-btn[data-target="3"].active { background: linear-gradient(135deg, #f59e0b, #d97706); } /* Trader */
.filter-btn[data-target="4"].active { background: linear-gradient(135deg, #8b5cf6, #7c3aed); } /* Manager */
.filter-btn[data-target="10"].active { background: linear-gradient(135deg, #6366f1, #4f46e5); } /* DevEngineer */
.filter-btn[data-target="99"].active { background: linear-gradient(135deg, #ef4444, #dc2626); } /* System */

/* Grid Transition */
.actor-card.hidden {
    display: none;
}

/* =========================================
   Visualization & Insights
   ========================================= */
.visualization-grid {
    display: grid;
    grid-template-columns: 1fr 250px;
    gap: 2rem;
    align-items: center;
}

@media (max-width: 992px) {
    .visualization-grid {
        grid-template-columns: 1fr;
    }
}

.radar-chart-container {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
}

.mood-gauge-container {
    text-align: center;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    border: 1px solid var(--glass-border);
}

.gauge-svg {
    width: 100%;
    max-width: 200px;
}

.gauge-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.05);
    stroke-width: 12;
}

.gauge-fill {
    fill: none;
    stroke: var(--accent-primary);
    stroke-width: 12;
    stroke-linecap: round;
    transition: stroke-dasharray 1s ease-out, stroke 1s ease;
}

.gauge-text {
    fill: var(--text-primary);
    font-size: 24px;
    font-weight: 800;
}

.gauge-label {
    fill: var(--text-secondary);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Latest Insights / Reflections */
.reflection-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.reflection-item {
    background: rgba(99, 102, 241, 0.05);
    border-left: 4px solid var(--accent-primary);
    padding: 1.25rem;
    border-radius: 0 12px 12px 0;
    position: relative;
    transition: transform 0.2s;
}

.reflection-item:hover {
    transform: translateX(4px);
    background: rgba(99, 102, 241, 0.08);
}

.reflection-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
}

.reflection-content {
    font-size: 0.95rem;
    color: var(--text-primary);
    line-height: 1.5;
    font-style: italic;
}

.reflection-content::before {
    content: '"';
    font-size: 1.5rem;
    color: var(--accent-primary);
    opacity: 0.5;
    margin-right: 0.25rem;
}

/* =========================================
   Mobile Responsive Table (Portfolio) - Scrollable
   ========================================= */
/* =========================================
   Mobile Responsive Table (Portfolio) - Scrollable
   ========================================= */
@media (max-width: 768px) {
    /* Ensure container scrolls */
    .table-container {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        /* Negative margin hack to pull to edges */
        margin-left: -1.5rem; 
        margin-right: -1.5rem;
        padding-left: 1.5rem;
        padding-right: 1.5rem;
        /* Ensure it takes full width of parent but not more */
        max-width: calc(100% + 3rem); 
    }
    
    /* Force table to keep width and not wrap, enabling scroll */
    .portfolio-table {
        width: 100%;
        min-width: 800px; /* Force minimum width to trigger scroll */
        table-layout: fixed;
    }

    .portfolio-table th, 
    .portfolio-table td {
        white-space: nowrap; /* Prevent text wrapping */
        padding: 0.75rem;
        box-sizing: border-box;
    }
}
