:root {
    /* Premium Dark Theme Palette */
    --bg-dark: #09090b;
    --bg-surface: #18181b;
    --bg-surface-hover: #27272a;
    --primary: #3b82f6;
    --primary-gradient: linear-gradient(135deg, #3b82f6, #06b6d4);
    --secondary: #8b5cf6;
    --border: #27272a;
    --text-main: #f8fafc;
    --text-muted: #a1a1aa;
    
    /* Semantic Colors */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    
    /* Effects */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-glow: 0 0 15px rgba(59, 130, 246, 0.5);
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* --- Sidebar --- */
.sidebar {
    width: 280px;
    background-color: var(--bg-dark);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.sidebar-header {
    margin-bottom: 30px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: var(--primary-gradient);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-glow);
}

.logo h2 {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.nav-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 10px;
    letter-spacing: 1px;
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    text-align: left;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-btn:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-main);
    transform: translateX(4px);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background-color: var(--bg-surface-hover);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --- Main Content Area --- */
.main-content {
    flex: 1;
    display: flex;
    background-color: var(--bg-surface);
    position: relative;
    overflow: hidden;
}

/* --- Avatar Stage --- */
.avatar-stage {
    width: 35%;
    min-width: 280px;
    max-width: 450px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    position: relative;
    
    /* Futuristic Cyber Background */
    background-color: #050a18;
    background-image: url('assets/cyber_bg.png');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    
    border-right: 1px solid var(--border);
    overflow: hidden;
}

/* AI-RAS Watermark to inspire */
.avatar-stage::before {
    content: 'AI-RAS\\A DIGITAL\\A MANAGER';
    white-space: pre-wrap;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-10deg);
    font-size: 5rem;
    font-weight: 800;
    color: rgba(56, 189, 248, 0.03);
    text-align: center;
    line-height: 1;
    z-index: 0;
    pointer-events: none;
}

#full-body-avatar {
    width: 100%;
    height: 100%;
    max-height: 100%;
    object-fit: cover;
    object-position: center;
    border-radius: 0;
    box-shadow: none;
    border: none;
    z-index: 2;
    transition: opacity 0.5s ease;
    margin-bottom: 0;
}

.avatar-stage-floor {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 15%;
    background: linear-gradient(to top, var(--bg-dark), transparent);
    z-index: 1;
}

/* --- Chat Container --- */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: transparent;
    position: relative;
}

/* Header */
.chat-header {
    height: 70px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: rgba(24, 24, 27, 0.8);
    backdrop-filter: blur(10px);
    z-index: 10;
}

.agent-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.agent-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

.agent-details h1 {
    font-size: 1.1rem;
    font-weight: 600;
}

.agent-status {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: var(--success);
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px var(--success);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.2s;
}

.icon-btn:hover {
    color: var(--text-main);
}

/* Messages Area */
.messages-area {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
    scroll-behavior: smooth;
}

.message {
    display: flex;
    gap: 16px;
    max-width: 85%;
    animation: fadeIn 0.4s ease forwards;
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.message.user .msg-avatar {
    background-color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.msg-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message.user .msg-content {
    align-items: flex-end;
}

.msg-bubble {
    background-color: var(--bg-dark);
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    border-top-left-radius: 4px;
    font-size: 0.95rem;
    line-height: 1.5;
    border: 1px solid var(--border);
}

.message.user .msg-bubble {
    background: var(--primary-gradient);
    border: none;
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: 4px;
    color: white;
}

.msg-bubble p {
    margin-bottom: 8px;
}

.msg-bubble p:last-child {
    margin-bottom: 0;
}

/* Input Area */
.input-container {
    padding: 20px 24px;
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background-color: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 10px 16px;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.attach-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s, color 0.2s;
    margin-bottom: 2px;
}

.attach-btn:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-main);
}

#chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    resize: none;
    padding: 10px 0;
    max-height: 150px;
    outline: none;
    overflow-y: hidden;
}

#chat-input::placeholder {
    color: var(--text-muted);
}

.mic-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 4px;
}

.mic-btn:hover {
    color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}

.mic-btn.recording {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    animation: pulse-red 1.5s infinite;
}

@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.send-btn {
    background: var(--primary-gradient);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 4px;
}

.send-btn svg {
    width: 18px;
    height: 18px;
    margin-left: -2px; /* slight visual center tweak */
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-glow);
}

.input-footer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 10px;
}

/* --- Interactive Cards --- */
.interactive-card {
    background-color: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 350px;
    overflow: hidden;
    margin-top: 8px;
    box-shadow: var(--shadow-md);
    animation: slideUp 0.4s ease forwards;
}

.card-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.02);
}

.card-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
}

.badge {
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 12px;
    background: var(--primary);
    color: white;
    font-weight: 500;
}

.badge.warning { background: var(--warning); }
.badge.success { background: var(--success); }

.card-body {
    padding: 18px;
}

/* Task List styles */
.task-list {
    list-style: none;
}
.task-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.task-item:last-child { border-bottom: none; }
.task-item input {
    accent-color: var(--primary);
    width: 16px; height: 16px;
    cursor: pointer;
}
.task-item label {
    flex: 1;
    font-size: 0.9rem;
    cursor: pointer;
}
.tag {
    font-size: 0.65rem; padding: 2px 6px; border-radius: 4px;
}
.tag.high { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
.tag.urgent { background: rgba(239, 68, 68, 0.2); color: var(--danger); }
.tag.normal { background: rgba(59, 130, 246, 0.2); color: var(--primary); }

/* Buttons */
.action-btn {
    background: var(--bg-surface-hover);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}
.action-btn:hover { background: var(--primary); border-color: var(--primary); }
.action-btn.secondary { background: transparent; }
.action-btn.secondary:hover { background: var(--bg-surface-hover); border-color: var(--text-muted); }
.w-full { width: 100%; }
.mt-10 { margin-top: 10px; }

/* Progress Stats */
.progress-stats { display: flex; gap: 15px; margin-bottom: 15px; }
.stat-box {
    flex: 1; background: var(--bg-surface-hover); padding: 12px;
    border-radius: var(--radius-sm); display: flex; flex-direction: column;
}
.stat-value { font-size: 1.2rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; margin-top: 4px;}
.progress-bar-container { height: 8px; background: var(--bg-surface-hover); border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary-gradient); border-radius: 4px; }

/* Photos */
.photo-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.photo-grid .photo-placeholder:first-child { grid-column: span 2; height: 100px; }
.photo-placeholder {
    height: 70px; border-radius: var(--radius-sm); display: flex;
    align-items: center; justify-content: center; font-weight: 600; text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Billing */
.billing-summary { display: flex; flex-direction: column; gap: 12px; }
.bill-row { display: flex; justify-content: space-between; font-size: 0.9rem; }
.bill-row.highlight { color: var(--warning); padding-top: 8px; border-top: 1px solid var(--border); }

/* Button Groups */
.button-group { display: flex; gap: 10px; margin-top: 15px;}
.button-group button { flex: 1; }

/* Typing indicator */
.typing-indicator {
    display: flex; gap: 4px; padding: 10px 15px; background: var(--bg-dark);
    border-radius: var(--radius-lg); width: fit-content; border: 1px solid var(--border);
}
.typing-dot {
    width: 6px; height: 6px; background: var(--text-muted); border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}
.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes typing {
    0%, 100% { transform: scale(1); opacity: 0.4; }
    50% { transform: scale(1.5); opacity: 1; }
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar { position: absolute; transform: translateX(-100%); z-index: 20; height: 100%; }
    .sidebar.active { transform: translateX(0); }
    .message { max-width: 95%; }
}

/* Login Overlay Styles */
.login-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--bg-dark);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 60px 20px;
    overflow-y: auto;
}

.login-header {
    text-align: center;
    margin-bottom: 50px;
}

.login-header h2 {
    font-size: 2.5rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.role-cards {
    display: flex;
    gap: 30px;
    max-width: 900px;
    width: 100%;
}

.role-card {
    flex: 1;
    background-color: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.role-card:hover {
    transform: translateY(-10px);
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
}

.role-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.role-card h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.role-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Passcode Modal */
.passcode-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(9, 9, 11, 0.85);
    backdrop-filter: blur(5px);
    z-index: 4000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.passcode-content {
    background-color: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 30px;
    width: 350px;
    text-align: center;
    box-shadow: var(--shadow-glow);
    animation: slideUp 0.3s ease forwards;
}

.passcode-inputs {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.passcode-char {
    width: 50px;
    height: 60px;
    background-color: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 1.5rem;
    text-align: center;
    color: var(--text-main);
    transition: all 0.2s;
}

.passcode-char:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* --- Dashboard Widgets Panel --- */
.dashboard-widgets {
    width: 250px;
    background-color: var(--bg-surface);
    border-left: 1px solid var(--border);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
}

.widget-card {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 15px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.widget-card h4 {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.widget-card h2 {
    font-size: 2rem;
    color: var(--primary);
    margin: 5px 0;
}

.widget-sub {
    font-size: 0.75rem;
    color: var(--success);
}

.progress-ring-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.progress-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: conic-gradient(var(--primary) 45%, var(--bg-surface) 0);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    position: relative;
}

.progress-circle::before {
    content: "";
    position: absolute;
    width: 60px;
    height: 60px;
    background-color: var(--bg-dark);
    border-radius: 50%;
}

.progress-circle span {
    position: relative;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-main);
}

/* --- GUEST LANDING PAGE OVERRIDES --- */
.guest-hero {
    position: relative;
    flex: 1;
    background-image: url('assets/herobg.jpeg');
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 0;
}

body.role-guest .main-content {
    flex-direction: row;
    justify-content: flex-start;
    background: #0b0f19;
}

body.role-guest .chat-container {
    width: 420px;
    flex: none;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: -10px 10px 40px rgba(0,0,0,0.5);
    z-index: 1;
    margin: 20px;
    border-radius: 16px;
    height: calc(100% - 40px);
}

body.role-guest .chat-header {
    background: transparent;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

@media (max-width: 1200px) {
    html, body, .app-container { flex-direction: column !important; overflow-y: auto !important; overflow-x: hidden !important; height: auto !important; min-height: 100vh !important; }
    .sidebar { width: 100% !important; height: auto !important; position: relative !important; flex: none !important; transform: none !important; }
    .main-content, body.role-guest .main-content { flex-direction: column !important; height: auto !important; flex: none !important; overflow-y: auto !important; }
    .guest-hero { width: 100% !important; height: 100vh !important; min-height: 600px !important; flex: none !important; }
    .avatar-stage { width: 100% !important; height: 60vh !important; min-height: 400px !important; flex: none !important; }
    .chat-container, body.role-guest .chat-container { width: 100% !important; margin: 0 !important; border-radius: 0 !important; height: 800px !important; flex: none !important; }
    #analytics-dashboard { width: 100% !important; position: relative !important; height: auto !important; padding: 20px !important; }
    .site-grid { grid-template-columns: 1fr !important; gap: 15px !important; }
}
