/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI Variable', 'Segoe UI', system-ui, ui-sans-serif, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    color: #374151;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    background: #f7f8f9;
}

/* Container */
.container {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Top Navigation Bar */
.top-nav {
    background: white;
    border-bottom: 1px solid #e5e7eb;
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.nav-left {
    display: flex;
    align-items: center;
}

.app-logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.app-logo {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.app-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
}

.bot-text {
    color: #10b981;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.feedback-btn {
    background: #10b981;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

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

.feedback-btn:active {
    transform: translateY(0);
}

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

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 24px 0 24px;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 24px;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #1f2937;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #6b7280;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: #f3f4f6;
    color: #374151;
}

.feedback-form {
    padding: 0 24px 24px 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-weight: 500;
    color: #374151;
    font-size: 14px;
    margin-bottom: 6px;
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s ease;
    background: white;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.5;
}

.form-textarea::placeholder,
.form-input::placeholder {
    color: #9ca3af;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

.btn-secondary {
    background: white;
    color: #374151;
    border: 1px solid #d1d5db;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

.btn-primary {
    background: #10b981;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-primary:hover {
    background: #059669;
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-primary .loading-spinner {
    display: none;
}

.btn-primary.loading .loading-spinner {
    display: block;
}

.btn-primary.loading .btn-text {
    display: none;
}

/* Main content container with horizontal padding */
.main-content-container {
    padding-left: 20px;
    padding-right: 20px;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    background: #f7f8f9;
    border-radius: 12px;
    margin-left: 170px;
    margin-right: 170px;
    margin-top: 40px;
    margin-bottom: 40px;
    gap: 2rem;
}

/* Unified Input Container */
.unified-input-container {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
}

/* Controls Section */
.controls-section {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    align-items: end;
}

/* Results Container */
.results-container {
    background: white;
    border-radius: 8px;
    padding: 0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border: 2px solid #000000;
    overflow: hidden;
}

/* Header Section */
.header-section {
    padding: 24px 32px;
    border-bottom: 1px solid #e5e7eb;
}

.header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
}

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

.header-right {
    display: flex;
    align-items: center;
    gap: 24px;
}

.ticker-group,
.date-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-label {
    font-weight: 500;
    color: #374151;
    font-size: 14px;
    white-space: nowrap;
}

.ticker-select,
.date-input {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    transition: all 0.2s ease;
}

.ticker-select {
    width: 200px;
    cursor: pointer;
}

.date-input {
    width: 140px;
    cursor: pointer;
}

.ticker-select:focus,
.date-input:focus {
    outline: none;
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Main Content Area */
.main-content-area {
    flex: 1;
    padding: 32px;
    display: flex;
    flex-direction: column;
}

.strategy-form {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.strategy-input-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.strategy-textarea {
    flex: 1;
    padding: 20px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.6;
    resize: none;
    transition: all 0.2s ease;
    background: #fafafa;
    min-height: 200px;
}

.strategy-textarea:focus {
    outline: none;
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
    background: white;
}

.strategy-textarea::placeholder {
    color: #9ca3af;
    line-height: 1.6;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 16px;
}

.paste-btn {
    background: white;
    border: 1px solid #d1d5db;
    color: #374151;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.paste-btn:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

.sample-btn {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.sample-btn:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.backtest-btn {
    background: #10b981;
    color: white;
    border: none;
    padding: 12px 32px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 120px;
    justify-content: center;
}

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

.backtest-btn:active {
    transform: translateY(0);
}

.backtest-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Loading spinner */
.loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
    display: none;
}

.loading .loading-spinner {
    display: block;
}

.loading .btn-text {
    display: none;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Results Section */
.results-section {
    padding: 2rem;
}



/* Error Section */
.error-section, .error-container {
    margin-top: 24px;
    padding: 16px 24px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    display: none; /* Hidden by default */
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.error-container.show {
    display: block !important;
}

.error-message {
    color: #dc2626;
    font-weight: 500;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.error-message i {
    color: #dc2626;
    font-size: 16px;
}

/* Full width plot section */
.full-width-plot {
    width: 100%;
    background: white;
    border: 0;
    margin-top: 1rem;
    box-shadow: none;
    border-radius: 8px;
    overflow: hidden;
}

/* Plot container should match GridPlot height and take full width */
#plot-container {
    height: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden !important;
}

/* Ensure GridPlot takes its natural height and full width */
.bk-GridPlot {
    height: 80% !important;
    width: 100% !important;
    max-width: 100% !important;
    border: 2px solid #10b981 !important;
    border-radius: 6px !important;
    overflow: hidden !important;
}

/* Ensure all Bokeh plot elements stretch to full width but don't overflow */
.bk-root, .bk-plotdiv {
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden !important;
}

/* Ensure Bokeh figures are responsive */
.bk-root .bk-layout-fixed {
    width: 100% !important;
    max-width: 100% !important;
}

/* Success animation */
@keyframes successPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

.success {
    animation: successPulse 2s;
    background: #10b981 !important;
}

/* Responsive design */
@media (max-width: 768px) {
    .top-nav {
        padding: 12px 16px;
    }
    
    .app-logo {
        width: 28px;
        height: 28px;
    }
    
    .app-title {
        font-size: 1.25rem;
    }
    
    .feedback-btn {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .main-content-container {
        padding-left: 0px;
        padding-right: 0px;
        margin: 10px;
        height: auto;
        min-height: 600px;
    }
    
    .unified-input-container {
        padding: 1.5rem;
    }
    
    .controls-section {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .results-container {
        padding: 1.5rem;
    }
    
    .header-section {
        padding: 16px 20px;
    }
    
    .header-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }
    
    .header-left,
    .header-right {
        width: 100%;
    }
    
    .header-right {
        flex-direction: column;
        gap: 12px;
    }
    
    .ticker-group,
    .date-group {
        justify-content: space-between;
    }
    
    .ticker-select {
        width: 150px;
    }
    
    .date-input {
        width: 120px;
    }
    
    .main-content-area {
        padding: 20px;
    }
    
    .action-buttons {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
}

@media (max-width: 480px) {
    .main-content-container {
        padding-left: 16px;
        padding-right: 16px;
        margin: 5px;
    }
    
    .unified-input-container {
        padding: 1rem;
    }
    
    .results-container {
        padding: 1rem;
    }
    
    .header-section {
        padding: 12px 16px;
    }
    
    .main-content-area {
        padding: 16px;
    }
    
    .ticker-input {
        width: 120px;
    }
}