/* CSS Variables for Theme Customization */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a25;
    --accent: #b76e79;
    --accent-dim: rgba(183, 110, 121, 0.3);
    --accent-glow: rgba(183, 110, 121, 0.5);
    --text-primary: #e8e8e8;
    --text-secondary: #a0a0a0;
    --text-dim: #606060;
    --border: #2a2a35;
    --success: #00ff88;
    --warning: #fbbf24;
    --error: #ff4444;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Roboto Mono', monospace;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Scanlines Effect */
.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.1) 0px,
        rgba(0, 0, 0, 0.1) 1px,
        transparent 1px,
        transparent 3px
    );
    opacity: 0.3;
}

.scanlines.hidden {
    display: none;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    border-bottom: 1px solid var(--border);
    position: relative;
}

.header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    height: 45px;
    width: auto;
    filter: drop-shadow(0 0 10px var(--accent-glow));
    transition: filter 0.3s ease;
}

.logo:hover {
    filter: drop-shadow(0 0 20px var(--accent));
}

.title {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--accent);
    text-shadow: 0 0 20px var(--accent-glow);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 10px var(--success);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.status-text {
    font-size: 0.75rem;
    letter-spacing: 2px;
    color: var(--success);
}

.header-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.header-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 15px var(--accent-dim);
}

/* Main Content Layout */
.main-content {
    display: flex;
    height: calc(100vh - 70px);
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 320px;
    min-width: 320px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* Widgets */
.widget {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.widget:hover {
    border-color: var(--accent-dim);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3), inset 0 0 1px var(--accent-dim);
}

.widget-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: linear-gradient(90deg, var(--bg-secondary), transparent);
    border-bottom: 1px solid var(--border);
}

.widget-header h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.7rem;
    font-weight: 400;
    letter-spacing: 2px;
    color: var(--accent);
    flex: 1;
}

.widget-icon {
    color: var(--accent);
    font-size: 1rem;
}

.widget-time {
    font-size: 0.65rem;
    color: var(--text-dim);
}

.widget-content {
    padding: 12px 16px;
    max-height: 200px;
    overflow-y: auto;
}

.widget-content::-webkit-scrollbar {
    width: 4px;
}

.widget-content::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

/* Briefing Widget */
.briefing-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.briefing-item:last-child {
    border-bottom: none;
}

.briefing-bullet {
    color: var(--accent);
    font-size: 0.8rem;
    margin-top: 2px;
}

.briefing-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Tasks Widget */
.task-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s ease;
}

.task-item:last-child {
    border-bottom: none;
}

.task-item:hover {
    padding-left: 5px;
}

.task-checkbox {
    width: 16px;
    height: 16px;
    border: 1px solid var(--accent);
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.task-item:hover .task-checkbox {
    box-shadow: 0 0 8px var(--accent-dim);
}

.task-checkbox.completed {
    background: var(--accent);
}

.task-checkbox.completed::after {
    content: '✓';
    color: var(--bg-primary);
    font-size: 10px;
}

.task-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    flex: 1;
}

.task-due {
    font-size: 0.65rem;
    color: var(--warning);
}

/* Alerts Widget */
.alert-badge {
    background: var(--error);
    color: white;
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}

.alert-badge.empty {
    background: var(--text-dim);
}

.alert-item {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.alert-item:last-child {
    border-bottom: none;
}

.alert-from {
    font-size: 0.75rem;
    color: var(--accent);
    margin-bottom: 2px;
}

.alert-subject {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.alert-time {
    font-size: 0.65rem;
    color: var(--text-dim);
    margin-top: 4px;
}

/* Quick Actions */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 12px;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    font-size: 0.65rem;
}

.action-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 15px var(--accent-dim);
    transform: translateY(-2px);
}

.action-icon {
    font-size: 1.2rem;
}

.refresh-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.refresh-btn:hover {
    color: var(--accent);
    transform: rotate(180deg);
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    position: relative;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* Welcome Message */
.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 20px;
    animation: fadeIn 0.5s ease;
}

.welcome-avatar {
    width: 300px;
    height: 300px;
    border-radius: 50%;
    margin-bottom: 24px;
    filter: drop-shadow(0 0 30px var(--accent-glow));
    animation: float 3s ease-in-out infinite;
    border: 3px solid var(--accent);
    object-fit: cover;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.welcome-message h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.8rem;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.welcome-message p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Chat Messages */
.message {
    display: flex;
    gap: 12px;
    animation: slideIn 0.3s ease;
    max-width: 85%;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

.message.user {
    flex-direction: row-reverse;
    align-self: flex-end;
}

.message.user .message-content {
    background: linear-gradient(135deg, var(--accent), var(--accent-dim));
    border-color: var(--accent);
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.message-avatar.user {
    background: var(--accent);
    color: var(--bg-primary);
    font-weight: bold;
    font-size: 0.9rem;
}

.message-content {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 16px;
}

.message-text {
    font-size: 0.9rem;
    line-height: 1.6;
    white-space: pre-wrap;
}

.message-text code {
    background: var(--bg-primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.85em;
}

.message-text pre {
    background: var(--bg-primary);
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
}

.message-time {
    font-size: 0.65rem;
    color: var(--text-dim);
    margin-top: 6px;
}

/* Typing Indicator */
.typing-indicator {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    color: var(--text-secondary);
}

.typing-indicator.active {
    display: flex;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    animation: typingBounce 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; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

.typing-text {
    font-size: 0.8rem;
    font-style: italic;
}

/* Chat Input */
.chat-input-form {
    padding: 16px 24px 24px;
    background: linear-gradient(0deg, var(--bg-secondary) 0%, transparent 100%);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 16px;
    transition: all 0.3s ease;
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-dim);
}

#chatInput {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    resize: none;
    max-height: 150px;
    line-height: 1.5;
}

#chatInput:focus {
    outline: none;
}

#chatInput::placeholder {
    color: var(--text-dim);
}

.send-btn {
    background: var(--accent);
    border: none;
    color: var(--bg-primary);
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.send-btn:hover {
    box-shadow: 0 0 20px var(--accent-glow);
    transform: scale(1.05);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 400px;
    max-width: 90%;
    animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.9rem;
    letter-spacing: 2px;
    color: var(--accent);
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close-btn:hover {
    color: var(--accent);
}

.modal-body {
    padding: 20px;
}

.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.color-options {
    display: flex;
    gap: 10px;
}

.color-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.3s ease;
}

.color-btn:hover {
    transform: scale(1.1);
}

.color-btn.active {
    border-color: var(--text-primary);
    box-shadow: 0 0 15px currentColor;
}

/* Toggle Switch */
.toggle {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 26px;
    transition: 0.3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: var(--text-dim);
    border-radius: 50%;
    transition: 0.3s;
}

.toggle input:checked + .toggle-slider {
    border-color: var(--accent);
}

.toggle input:checked + .toggle-slider:before {
    background: var(--accent);
    transform: translateX(24px);
}

.setting-group input[type="number"] {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 6px;
    width: 100px;
    font-family: inherit;
}

.setting-group input[type="number"]:focus {
    outline: none;
    border-color: var(--accent);
}

/* Loading Animation */
.loading-pulse {
    color: var(--text-dim);
    font-size: 0.8rem;
    animation: loadingPulse 1.5s infinite;
}

@keyframes loadingPulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 20px;
    color: var(--text-dim);
    font-size: 0.8rem;
}

/* Notification Banners */
.notification-banner {
    position: fixed;
    top: 80px;
    right: 20px;
    max-width: 400px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 3000;
    animation: slideInRight 0.3s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.notification-banner.info { border-color: var(--accent); }
.notification-banner.success { border-color: var(--success); }
.notification-banner.warning { border-color: var(--warning); }
.notification-banner.error { border-color: var(--error); }

.notif-icon { font-size: 1.2rem; }
.notif-message { flex: 1; font-size: 0.85rem; color: var(--text-primary); }

.notif-close {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 4px;
}

.notif-close:hover { color: var(--text-primary); }

/* Responsive */
@media (max-width: 900px) {
    .main-content {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        min-width: auto;
        max-height: 40vh;
        flex-direction: row;
        flex-wrap: wrap;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    
    .widget {
        flex: 1;
        min-width: 280px;
    }
    
    .title {
        font-size: 1rem;
    }
}

@media (max-width: 600px) {
    .header {
        padding: 10px 16px;
    }
    
    .logo {
        height: 35px;
    }
    
    .title {
        font-size: 0.8rem;
        letter-spacing: 1px;
    }
    
    .chat-input-form {
        padding: 12px 16px 16px;
    }
    
    .quick-actions {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Notification banners */
.notification-banner {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 40px 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    z-index: 10000;
    max-width: 400px;
    animation: slideIn 0.3s ease;
}

.notification-banner.success { border-left: 4px solid var(--success); }
.notification-banner.warning { border-left: 4px solid var(--warning); }
.notification-banner.error { border-left: 4px solid var(--error); }
.notification-banner.info { border-left: 4px solid var(--accent); }

.notif-icon { font-size: 1.2rem; }
.notif-message { flex: 1; color: var(--text); }

.notif-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    border-radius: 4px;
    transition: all 0.2s;
}

.notif-close:hover {
    background: var(--bg-tertiary);
    color: var(--text);
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
