/* ==========================================================================
   VISIONAI MAESTRO AGENTIC HUB - ENTERPRISE CORPORATE DESIGN SYSTEM (v2.1.0)
   ========================================================================== */

:root {
    --bg-main: #0b0f19;
    --bg-surface: #111827;
    --bg-surface-elevated: #1e293b;
    --bg-card: rgba(17, 24, 39, 0.85);
    --bg-card-hover: rgba(30, 41, 59, 0.95);
    
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(56, 189, 248, 0.4);
    --border-strong: rgba(255, 255, 255, 0.15);
    
    --primary: #38bdf8;
    --primary-hover: #0ea5e9;
    --primary-glow: rgba(56, 189, 248, 0.18);
    --primary-gradient: linear-gradient(135deg, #0284c7 0%, #2563eb 50%, #4f46e5 100%);
    
    --accent-emerald: #10b981;
    --accent-indigo: #6366f1;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;
    --accent-slate: #64748b;

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-inverse: #0f172a;

    --font-sans: 'Inter', 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 25px rgba(56, 189, 248, 0.15);

    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
    background-image: 
        radial-gradient(at 0% 0%, rgba(2, 132, 199, 0.08) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(99, 102, 241, 0.06) 0px, transparent 50%),
        radial-gradient(at 50% 100%, rgba(15, 23, 42, 0.8) 0px, transparent 100%);
    background-attachment: fixed;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   LAYOUT STRUCTURE
   ========================================================================== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 270px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1.1rem;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
}

.brand-logo {
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(99, 102, 241, 0.2));
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: var(--radius-md);
}

.brand-info h2 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: #ffffff;
}

.badge-tag {
    font-size: 0.65rem;
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--primary);
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.25);
    padding: 2px 7px;
    border-radius: var(--radius-sm);
    display: inline-block;
    margin-top: 3px;
}

/* Nav Menu */
.nav-menu {
    list-style: none;
    margin-top: 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: var(--transition);
    border: 1px solid transparent;
}

.nav-item a:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.06);
}

.nav-item.active a {
    background: linear-gradient(135deg, rgba(2, 132, 199, 0.18), rgba(99, 102, 241, 0.15));
    color: var(--primary);
    border-color: rgba(56, 189, 248, 0.3);
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.1);
}

.sidebar-footer {
    padding-top: 1rem;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.system-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.2);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--accent-emerald);
    box-shadow: 0 0 8px var(--accent-emerald);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ==========================================================================
   MAIN CONTENT & HEADER
   ========================================================================== */
.main-content {
    margin-left: 270px;
    flex: 1;
    padding: 2rem 2.5rem;
    max-width: 1440px;
}

.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
}

.header-title h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: #ffffff;
}

.header-title p {
    color: var(--text-secondary);
    font-size: 0.88rem;
    margin-top: 2px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid var(--border-subtle);
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
}

/* ==========================================================================
   KPI STATS CARDS (ENTERPRISE DASHBOARD)
   ========================================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.4rem;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: rgba(56, 189, 248, 0.3);
    box-shadow: var(--shadow-glow);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary-gradient);
    opacity: 0;
    transition: var(--transition);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-icon {
    font-size: 1.3rem;
    opacity: 0.85;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin: 0.5rem 0 0.2rem;
    color: #ffffff;
    font-family: var(--font-mono);
}

.stat-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ==========================================================================
   BUTTONS & FORM CONTROLS
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0.65rem 1.25rem;
    font-size: 0.88rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary-gradient);
    color: #ffffff;
    box-shadow: 0 2px 10px rgba(2, 132, 199, 0.35);
}

.btn-primary:hover {
    box-shadow: 0 4px 16px rgba(2, 132, 199, 0.5);
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(30, 41, 59, 0.8);
    color: var(--text-primary);
    border-color: var(--border-subtle);
}

.btn-secondary:hover {
    background: rgba(51, 65, 85, 0.9);
    border-color: var(--border-strong);
}

.btn-sm {
    padding: 0.4rem 0.85rem;
    font-size: 0.78rem;
}

/* Form inputs */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
    background: rgba(15, 23, 42, 0.95);
}

/* ==========================================================================
   AGENT MATRIX & CARDS
   ========================================================================== */
.agents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.25rem;
}

.agent-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.agent-card:hover {
    transform: translateY(-2px);
    border-color: rgba(56, 189, 248, 0.3);
    box-shadow: var(--shadow-glow);
}

.agent-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.9rem;
}

.agent-card-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: #ffffff;
}

.agent-desc {
    font-size: 0.84rem;
    color: var(--text-secondary);
    margin-bottom: 1.1rem;
    flex: 1;
}

.agent-meta {
    background: rgba(10, 14, 23, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    font-size: 0.78rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 1rem;
}

.agent-meta strong {
    color: var(--text-secondary);
}

.agent-skills-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 1.25rem;
}

.skill-chip {
    font-size: 0.72rem;
    font-family: var(--font-mono);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
}

/* Status Badges */
.status-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.status-badge.online {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-emerald);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.scaffolded {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-amber);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* ==========================================================================
   TASKS TABLE & TERMINAL MODAL
   ========================================================================== */
.tasks-table-container {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.tasks-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.86rem;
}

.tasks-table th {
    background: rgba(15, 23, 42, 0.9);
    padding: 0.9rem 1.25rem;
    font-size: 0.76rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-subtle);
}

.tasks-table td {
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
}

.tasks-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-primary);
}

/* Terminal Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.active {
    display: flex;
}

.terminal-modal {
    background: #0d1117;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 860px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    overflow: hidden;
}

.terminal-header {
    background: #161b22;
    padding: 0.9rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-subtle);
}

.terminal-body {
    padding: 1.25rem;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.6;
    flex: 1;
    background: #090d13;
}

.log-step {
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    border-left: 3px solid var(--border-subtle);
    background: rgba(255, 255, 255, 0.02);
}

.log-step.thinking { border-left-color: var(--accent-indigo); }
.log-step.tool { border-left-color: var(--primary); }
.log-step.action { border-left-color: var(--accent-amber); }
.log-step.success { border-left-color: var(--accent-emerald); }

/* Full-Screen Login Gate */
#auth-gate-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at 50% 30%, #1e293b 0%, #0b0f19 80%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
}

.auth-gate-card {
    background: rgba(17, 24, 39, 0.9);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(56, 189, 248, 0.25);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6), var(--shadow-glow);
}
