/* TradeMaster AI Pro - Professional Trading WebView Plugin */

/* CSS Variables for Theme Management */
:root {
    /* Light Theme Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --shadow-color: rgba(0, 0, 0, 0.1);
    
    /* Accent Colors */
    --accent-primary: #3b82f6;
    --accent-secondary: #8b5cf6;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #06b6d4;
    
    /* Trading Colors */
    --buy-color: #10b981;
    --sell-color: #ef4444;
    --positive-color: #10b981;
    --negative-color: #ef4444;
    
    /* Sizes */
    --header-height: 60px;
    --footer-height: 40px;
    --sidebar-width: 280px;
    --border-radius: 8px;
    --border-radius-sm: 4px;
    --border-radius-lg: 12px;
    
    /* Animations */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-color: #475569;
    --shadow-color: rgba(0, 0, 0, 0.3);
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-content {
    text-align: center;
    color: white;
}

.logo-container {
    margin-bottom: 2rem;
}

.logo-container i {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    display: block;
}

.logo-container h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 1rem auto;
}

.loading-text {
    font-size: 0.9rem;
    opacity: 0.9;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* App Layout */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    transition: var(--transition-normal);
}

.hidden {
    display: none !important;
}

/* Header */
.app-header {
    height: var(--header-height);
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    box-shadow: 0 1px 3px var(--shadow-color);
}

.header-left,
.header-center,
.header-right {
    flex: 1;
    display: flex;
    align-items: center;
}

.header-center {
    justify-content: center;
}

.header-right {
    justify-content: flex-end;
    gap: 0.5rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--accent-primary);
}

.logo i {
    font-size: 1.5rem;
}

.logo-text {
    font-size: 1.1rem;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: 1rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.status-indicator {
    font-size: 0.6rem;
    color: var(--warning-color);
    animation: pulse 2s infinite;
}

.status-indicator.connected {
    color: var(--success-color);
    animation: none;
}

.status-indicator.disconnected {
    color: var(--danger-color);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.symbol-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1rem;
    background-color: var(--bg-primary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.symbol-name {
    font-weight: 600;
    font-size: 1rem;
}

.symbol-price {
    font-weight: 500;
    font-size: 1.1rem;
}

.symbol-change {
    font-size: 0.9rem;
    font-weight: 500;
}

.symbol-change.positive {
    color: var(--positive-color);
}

.symbol-change.negative {
    color: var(--negative-color);
}

/* Buttons */
.btn-icon {
    width: 36px;
    height: 36px;
    border: none;
    background-color: transparent;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
    color: var(--text-secondary);
}

.btn-icon:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-icon.active {
    background-color: var(--accent-primary);
    color: white;
}

.btn-small {
    width: 28px;
    height: 28px;
}

/* Main Content */
.app-main {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.sidebar-left,
.sidebar-right {
    width: var(--sidebar-width);
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 1rem;
    gap: 1rem;
}

.sidebar-right {
    border-right: none;
    border-left: 1px solid var(--border-color);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    gap: 1rem;
    overflow: hidden;
}

/* Panels */
.panel {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 1px 3px var(--shadow-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--bg-secondary);
}

.panel-header h3 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.panel-content {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
}

/* AI Chat Interface */
.ai-chat-panel {
    flex: 1;
    min-height: 400px;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding-right: 0.5rem;
    margin-bottom: 1rem;
}

.message {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.ai-message .message-avatar {
    background-color: var(--accent-primary);
    color: white;
}

.user-message .message-avatar {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.message-content {
    flex: 1;
    background-color: var(--bg-secondary);
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius-lg);
    font-size: 0.9rem;
    line-height: 1.5;
}

.user-message .message-content {
    background-color: var(--accent-primary);
    color: white;
    margin-left: auto;
    max-width: 80%;
}

.message-content ul {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.message-content li {
    margin-bottom: 0.25rem;
}

.chat-input-container {
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}

.chat-input-wrapper {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

#chat-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition-fast);
}

#chat-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.btn-send {
    width: 42px;
    height: 42px;
    border: none;
    background-color: var(--accent-primary);
    color: white;
    border-radius: var(--border-radius-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.btn-send:hover {
    background-color: #2563eb;
    transform: translateY(-1px);
}

.btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.quick-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.quick-action-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background-color: var(--bg-primary);
    color: var(--text-secondary);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.8rem;
    transition: var(--transition-fast);
}

.quick-action-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background-color: rgba(59, 130, 246, 0.05);
}

/* Chart Panel */
.chart-panel {
    flex: 1;
    min-height: 300px;
}

.chart-controls {
    display: flex;
    gap: 0.5rem;
}

.select-small {
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.8rem;
    cursor: pointer;
}

.chart-container {
    height: 250px;
    margin-bottom: 1rem;
}

.analysis-insights {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.insight-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    font-size: 0.85rem;
}

.text-success { color: var(--success-color); }
.text-danger { color: var(--danger-color); }
.text-warning { color: var(--warning-color); }
.text-info { color: var(--info-color); }

/* Trading Panel */
.trade-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.btn-buy,
.btn-sell {
    padding: 1rem;
    border: none;
    border-radius: var(--border-radius-lg);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: var(--transition-fast);
}

.btn-buy {
    background-color: var(--buy-color);
    color: white;
}

.btn-buy:hover {
    background-color: #059669;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-sell {
    background-color: var(--sell-color);
    color: white;
}

.btn-sell:hover {
    background-color: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Portfolio Panel */
.portfolio-summary {
    margin-bottom: 1rem;
    padding: 1rem;
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0;
    font-size: 0.9rem;
}

.summary-item .label {
    color: var(--text-secondary);
}

.summary-item .value {
    font-weight: 500;
}

.positive {
    color: var(--positive-color);
}

.negative {
    color: var(--negative-color);
}

/* Watchlist */
.watchlist-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition-fast);
}

.watchlist-item:hover {
    background-color: var(--bg-secondary);
}

.watchlist-item:last-child {
    border-bottom: none;
}

.symbol-name {
    font-weight: 500;
}

.symbol-price {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Footer */
.app-footer {
    height: var(--footer-height);
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.footer-links {
    display: flex;
    gap: 1rem;
}

.link-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.75rem;
    transition: var(--transition-fast);
}

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

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background-color: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    max-width: 500px;
    width: 90%;
    max-height: 80%;
    overflow-y: auto;
}

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

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

.btn-close {
    width: 32px;
    height: 32px;
    border: none;
    background-color: transparent;
    color: var(--text-secondary);
    border-radius: var(--border-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

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

.modal-body {
    padding: 1.5rem;
}

.voice-status {
    text-align: center;
    margin-bottom: 2rem;
}

.voice-indicator {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    color: white;
    font-size: 2rem;
    animation: pulse-voice 2s infinite;
}

@keyframes pulse-voice {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 10px rgba(59, 130, 246, 0);
    }
}

.voice-examples h4 {
    margin-bottom: 1rem;
    font-size: 1rem;
    color: var(--text-primary);
}

.voice-examples ul {
    list-style: none;
    padding: 0;
}

.voice-examples li {
    padding: 0.5rem 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.voice-examples li:before {
    content: "💬 ";
    margin-right: 0.5rem;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .sidebar-left,
    .sidebar-right {
        width: 250px;
    }
}

@media (max-width: 768px) {
    .app-main {
        flex-direction: column;
    }
    
    .sidebar-left,
    .sidebar-right {
        width: 100%;
        height: auto;
        max-height: 200px;
        order: 2;
    }
    
    .main-content {
        order: 1;
    }
    
    .header-center {
        display: none;
    }
    
    .logo-text {
        display: none;
    }
    
    .chat-messages {
        height: 200px;
    }
    
    .chart-container {
        height: 200px;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 12px;
    }
    
    .app-header {
        padding: 0 0.5rem;
    }
    
    .main-content,
    .sidebar-left,
    .sidebar-right {
        padding: 0.5rem;
    }
    
    .panel-content {
        padding: 0.75rem;
    }
    
    .trade-buttons {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

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

.slide-up {
    animation: slideUp 0.3s ease-out;
}

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

/* Utility Classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.font-bold { font-weight: 600; }
.font-medium { font-weight: 500; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.rounded { border-radius: var(--border-radius); }
.shadow { box-shadow: 0 1px 3px var(--shadow-color); }