/* Material Design Stock Technical Analysis Tool */

/* Font Strategy:
 * - Main UI elements: 'Roboto', sans-serif (Material Design standard)
 * - Code/Data content: 'Roboto Mono', monospace (stock symbols, results)
 * This ensures consistent typography throughout the application
 */

/* Base Setup */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Roboto', sans-serif;
    background-color: #f5f5f5;
    color: #212121;
}

/* Material Design Colors */
:root {
    --mdc-theme-primary: #1976d2;
    --mdc-theme-secondary: #03dac6;
    --mdc-theme-surface: #ffffff;
    --mdc-theme-background: #f5f5f5;
    --mdc-theme-error: #b00020;
    --mdc-theme-on-primary: #ffffff;
    --mdc-theme-on-secondary: #000000;
    --mdc-theme-on-surface: #000000;
    --mdc-theme-on-error: #ffffff;
}

/* Layout */
.mdc-layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Top App Bar Customization */
.mdc-top-app-bar {
    background-color: var(--mdc-theme-primary);
    box-shadow: 0px 2px 4px -1px rgba(0,0,0,0.2), 0px 4px 5px 0px rgba(0,0,0,0.14), 0px 1px 10px 0px rgba(0,0,0,0.12);
}

.mdc-top-app-bar__title {
    font-weight: 500;
    letter-spacing: 0.0125em;
}

/* Hero Section */
.hero-section {
    text-align: center;
    margin: 32px 0 48px 0;
}

.hero-section h1 {
    color: #1976d2;
    margin-bottom: 16px;
    font-weight: 400;
}

.hero-subtitle {
    color: #757575;
    max-width: 600px;
    margin: 0 auto;
}

/* Cards */
.mdc-card {
    margin-bottom: 24px;
    border-radius: 8px;
    box-shadow: 0px 2px 1px -1px rgba(0,0,0,0.2), 0px 1px 1px 0px rgba(0,0,0,0.14), 0px 1px 3px 0px rgba(0,0,0,0.12);
}

.mdc-card__content {
    padding: 24px;
}

/* Section Titles */
.section-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    color: #1976d2;
    font-weight: 500;
}

.section-title .material-icons {
    font-size: 24px;
}

/* Input Section */
.input-card {
    background: var(--mdc-theme-surface);
}

/* Compact Layout: Side-by-Side Configuration and Input */
.input-layout {
    display: grid;
    grid-template-columns: 2fr 3fr;
    gap: 20px;
    align-items: start;
}

/* NEW: Unified Layout - Single Column with Rows */
.unified-input-layout {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Top Row: Three Dropdowns + Stock Symbol Input */
.controls-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 16px;
    align-items: start;
}

/* Middle Row: Checkboxes */
.checkboxes-row {
    display: flex;
    gap: 24px;
    align-items: center;
    justify-content: center;
    padding: 8px 0;
}

/* Bottom Row: Centered Buttons */
.buttons-row {
    display: flex;
    gap: 16px;
    justify-content: center;
    align-items: center;
    padding: 8px 0;
}

.input-left-section {
    display: flex;
    flex-direction: column;
}

.input-right-section {
    display: flex;
    flex-direction: column;
}

.symbol-input {
    width: 100%;
    margin-bottom: 0;
}

.symbol-input .mdc-text-field__input {
    font-size: 16px;
    font-family: 'Roboto Mono', monospace;
    text-transform: uppercase;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.mdc-button {
    font-weight: 500;
    letter-spacing: 0.0892857143em;
}

.mdc-button--raised {
    background-color: var(--mdc-theme-primary);
    color: var(--mdc-theme-on-primary);
}

/* Configuration Section */
.config-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    color: #1976d2;
    font-weight: 500;
}

.config-title .material-icons {
    font-size: 24px;
}

.config-grid {
    display: grid;
    grid-template-columns: max-content max-content max-content;
    grid-template-rows: auto auto;
    gap: 16px 12px;
    align-items: end;
    justify-content: start;
}

/* Make the switch span all three columns below the dropdowns */
.config-grid .mdc-form-field {
    grid-column: 1 / -1;
    justify-self: start;
}

/* Risk Disclaimer Checkbox Styling */
.config-grid .disclaimer-field {
    margin-top: 16px !important;
    padding: 12px;
    background-color: #fff3e0;
    border-radius: 8px;
    border-left: 4px solid #ff9800;
    display: flex !important;
    align-items: flex-start !important;
    gap: 12px;
}

.disclaimer-field label {
    font-size: 14px !important;
    line-height: 1.4 !important;
    color: rgba(0, 0, 0, 0.87) !important;
}

.disclaimer-field a {
    color: #1976d2 !important;
    text-decoration: none !important;
    font-weight: 500 !important;
}

.disclaimer-field a:hover {
    text-decoration: underline !important;
}

/* Material Select Customization */
.mdc-select {
    width: 100%;
}

.mdc-select--outlined .mdc-select__anchor {
    height: 56px;
}

/* Text Field Alignment with Select Dropdowns */
.mdc-text-field--outlined {
    height: 56px;
}

.mdc-text-field--outlined .mdc-text-field__input {
    height: 56px;
    padding-top: 14px;
    padding-bottom: 14px;
}

/* Individual dropdown width optimization */
.mdc-select.risk-profile-select {
    max-width: 148px; /* Fits "Conservative" comfortably */
}

.mdc-select.market-volatility-select {
    max-width: 138px; /* Fits "Medium" with some padding */
}

.mdc-select.position-size-select {
    max-width: 160px; /* Fits "Medium (3-7%)" comfortably */
}

/* Optimize text sizing for compact dropdowns */
.risk-profile-select .mdc-select__selected-text,
.market-volatility-select .mdc-select__selected-text {
    font-size: 14px;
}

.position-size-select .mdc-select__selected-text {
    font-size: 13px; /* Slightly smaller for longer text */
}

/* Optimize label sizes for compact dropdowns */
.risk-profile-select .mdc-floating-label,
.market-volatility-select .mdc-floating-label {
    font-size: 15px;
}

.position-size-select .mdc-floating-label {
    font-size: 14px; /* Smaller label for the widest dropdown */
}

/* Ensure select text doesn't overflow in compact width */
.mdc-select__selected-text {
    font-size: 14px;
}

/* Larger font size for dropdown labels */
.mdc-select .mdc-floating-label {
    font-size: 16px;
    font-weight: 200;
}

/* Switch and Checkbox Styling - Consistent Layout */
.mdc-form-field {
    display: flex;
    align-items: center;
    gap: 0px;
    margin: 0px; /* 8/9/2025 Reduced from 8px to 4px for tighter spacing */
    min-height: 15px; /* 8/9/2025 Reduced from 40px to 15px for more compact layout */
}

.mdc-form-field label {
    font-family: 'Roboto', sans-serif;
    font-size: 16px;
    font-weight: 400;
    color: rgba(0, 0, 0, 0.87);
    line-height: 1.5;
}

/* Ensure switch and checkbox have consistent sizing */
.mdc-switch {
    margin-right: 8px;
    flex-shrink: 0;
}

.mdc-checkbox {
    margin-right: 8px;
    flex-shrink: 0;
}

/* Make checkbox and switch the same visual size */
.mdc-checkbox .mdc-checkbox__background {
    width: 18px;
    height: 18px;
}

.mdc-switch .mdc-switch__thumb {
    width: 18px;
    height: 18px;
}

/* Checkbox container to match switch structure */
.checkbox-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px; /* Reduced from 40px to match new min-height */
    height: 36px; /* Reduced from 40px to match new min-height */
    margin-right: 8px;
    flex-shrink: 0;
}

/* Style the simple HTML checkbox to match Material Design */
.checkbox-container input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    flex-shrink: 0;
    accent-color: #1976d2;
    cursor: pointer;
}

/* Ensure checkbox label is clickable and properly aligned */
.mdc-form-field .checkbox-container + label {
    cursor: pointer;
    display: flex;
    align-items: center;
    line-height: 1.4;
}

/* Results Section */
.results-card {
    background: var(--mdc-theme-surface);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.results-card .mdc-card__content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

/* Status Chip */
.mdc-chip {
    background-color: #e8f5e8;
    color: #2e7d32;
    border: 1px solid #4caf50;
}

.mdc-chip--ready {
    background-color: #e3f2fd;
    color: #1976d2;
    border: 1px solid #2196f3;
}

.mdc-chip--loading {
    background-color: #fff3e0;
    color: #f57c00;
    border: 1px solid #ff9800;
}

.mdc-chip--error {
    background-color: #ffebee;
    color: #c62828;
    border: 1px solid #f44336;
}

.mdc-chip--success {
    background-color: #e8f5e8;
    color: #2e7d32;
    border: 1px solid #4caf50;
}

.mdc-chip__icon {
    font-size: 18px;
}

/* Results Container */
.results-container {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fafafa;
    min-height: 300px;
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.results-content {
    padding: 20px;
    font-family: 'Roboto Mono', monospace;
    font-size: 16px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-y: auto;
    margin: 0;
    background: transparent;
    border: none;
    flex: 1;
    height: 100%;
}

.results-content.empty {
    color: #757575;
    font-style: italic;
    text-align: center;
    padding-top: 100px;
    font-family: 'Roboto', sans-serif;
}

.results-content.html-content {
    font-family: 'Roboto', sans-serif;
    background: white;
    border-radius: 8px;
}

/* Loading Animation */
.loading-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(25, 118, 210, 0.3);
    border-radius: 50%;
    border-top-color: #1976d2;
    animation: spin 1s ease-in-out infinite;
    margin-right: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 16px 8px;
    }
    
    .mdc-card__content {
        padding: 16px;
    }
    
    /* Stack layout vertically on mobile */
    .input-layout {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    
    /* NEW: Unified layout responsive - Stack controls vertically on tablet */
    .controls-row {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    
    .checkboxes-row {
        flex-direction: column;
        align-items: center;
        gap: 16px;
    }
    
    .buttons-row {
        flex-direction: column;
        gap: 12px;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    /* Stack config dropdowns vertically on mobile */
    .config-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    /* Reset dropdown widths on mobile for full width */
    .mdc-select.risk-profile-select,
    .mdc-select.market-volatility-select,
    .mdc-select.position-size-select {
        max-width: none;
    }
    
    .config-grid .mdc-form-field {
        grid-column: 1;
    }
    
    .results-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .mdc-chip-set {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .hero-section h1 {
        font-size: 1.5rem;
    }
    
    .section-title {
        font-size: 1.1rem;
    }
    
    .input-layout {
        gap: 16px;
    }
    
    /* NEW: Mobile-first unified layout - Single column */
    .controls-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .checkboxes-row {
        flex-direction: column;
        align-items: center;
        gap: 12px;
    }
    
    .buttons-row {
        flex-direction: column;
        width: 100%;
    }
    
    .buttons-row .mdc-button {
        width: 100%;
    }
}

/* Enhanced Material Elevation */
.input-card:hover {
    box-shadow: 0px 3px 3px -2px rgba(0,0,0,0.2), 0px 3px 4px 0px rgba(0,0,0,0.14), 0px 1px 8px 0px rgba(0,0,0,0.12);
    transition: box-shadow 280ms cubic-bezier(0.4, 0, 0.2, 1);
}

.results-card:hover {
    box-shadow: 0px 3px 3px -2px rgba(0,0,0,0.2), 0px 3px 4px 0px rgba(0,0,0,0.14), 0px 1px 8px 0px rgba(0,0,0,0.12);
    transition: box-shadow 280ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Focus States */
.mdc-text-field--focused .mdc-floating-label {
    color: var(--mdc-theme-primary);
}

.mdc-text-field--focused .mdc-notched-outline__leading,
.mdc-text-field--focused .mdc-notched-outline__notch,
.mdc-text-field--focused .mdc-notched-outline__trailing {
    border-color: var(--mdc-theme-primary);
    border-width: 2px;
}

/* Ensure Material Design Typography uses consistent Roboto font */
.mdc-typography--headline6,
.mdc-typography--body1,
.mdc-typography--body2,
.mdc-button__label {
    font-family: 'Roboto', sans-serif;
}

/* Custom Alert Dialog Styles */
.custom-alert-overlay {
    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;
    animation: fadeIn 0.2s ease-out;
}

.custom-alert-dialog {
    background: white;
    border-radius: 8px;
    max-width: 400px;
    width: 90%;
    margin: 16px;
    box-shadow: 0px 11px 15px -7px rgba(0,0,0,0.2), 0px 24px 38px 3px rgba(0,0,0,0.14), 0px 9px 46px 8px rgba(0,0,0,0.12);
    animation: slideIn 0.3s ease-out;
}

.custom-alert-content {
    padding: 24px 24px 16px 24px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.custom-alert-icon {
    flex-shrink: 0;
    color: #1976d2;
}

.custom-alert-icon .material-icons {
    font-size: 24px;
}

.custom-alert-message {
    font-family: 'Roboto', sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: rgba(0, 0, 0, 0.87);
}

.custom-alert-actions {
    padding: 8px 24px 24px 24px;
    display: flex;
    justify-content: flex-end;
}

.custom-alert-ok {
    background-color: var(--mdc-theme-primary) !important;
    color: white !important;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { 
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Common Material Design Utility Classes - Migrated from Python */
.mdc-flex-row {
    display: flex;
    align-items: center;
    gap: 0.5em;
}

.mdc-icon--primary {
    color: #1976d2;
}

.mdc-icon--success {
    color: #43a047;
}

.mdc-icon--error {
    color: #e53935;
}

.mdc-icon--warning {
    color: #f57f17;
}

.mdc-icon--small {
    font-size: 1em;
    vertical-align: middle;
}

.mdc-card--spaced {
    margin-bottom: 1.5em;
}

.mdc-list--nested {
    margin-left: 1.5em;
}

.mdc-list--indented {
    margin-left: 1em;
}

.mdc-text--hint {
    margin-top: 1em;
}
