/**
 * Portfolio Optimization Tool Styles
 */

/* Hero Section */
.portfolio-optimizer .hero-section {
    padding: 80px 0;
    background: linear-gradient(135deg, #0066cc 0%, #004499 100%);
    position: relative;
    overflow: hidden;
}

.portfolio-optimizer .hero-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E") repeat;
}

.portfolio-optimizer .hero-section h1 {
    color: #ffffff;
    font-weight: 700;
    font-size: 3rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.portfolio-optimizer .hero-section .lead {
    color: rgba(255,255,255,0.9);
    font-size: 1.25rem;
}

/* Ticker Suggestions Dropdown */
.ticker-suggestions {
    position: absolute;
    top: calc(100% - 1px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ced4da;
    border-top: none;
    border-radius: 0 0 0.375rem 0.375rem;
    max-height: 300px;
    overflow-y: auto;
    z-index: 9999;
    display: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.ticker-suggestion {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s;
}

.ticker-suggestion:hover,
.ticker-suggestion.highlighted {
    background-color: #f8f9fa;
}

.ticker-suggestion.highlighted {
    background-color: #e3f2fd;
    outline: 2px solid #0066cc;
    outline-offset: -2px;
}

.ticker-suggestion:last-child {
    border-bottom: none;
}

.ticker-suggestion strong {
    color: #0066cc;
    font-weight: 600;
}

.ticker-suggestion small {
    color: #6c757d;
}

/* Portfolio Table */
#portfolio-table {
    margin-bottom: 0;
}

#portfolio-table th {
    background-color: #212529;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    color: #ffffff;
    border-bottom: 2px solid #212529;
    white-space: nowrap;
    min-width: 80px;
    padding: 1rem 0.75rem;
}

#portfolio-table td {
    vertical-align: middle;
}

.weight-input {
    text-align: right;
}

/* Total Weight Badge */
#total-weight {
    font-size: 1rem;
    padding: 0.375rem 0.75rem;
}

/* Custom metrics inputs */
.custom-return, .custom-volatility {
    max-width: 100px;
    font-size: 0.875rem;
}

#portfolio-table .input-group-sm {
    width: auto;
    display: inline-flex;
}

#portfolio-table td {
    white-space: nowrap;
}

/* Remove Button */
.remove-security {
    opacity: 0.8;
    transition: all 0.2s;
    background-color: #dc3545;
    border-color: #dc3545;
}

.remove-security:hover {
    opacity: 1;
    background-color: #c82333;
    border-color: #bd2130;
    transform: scale(1.05);
}

/* Danger button styling */
.portfolio-optimizer .btn-danger {
    background-color: #dc3545;
    border-color: #dc3545;
}

.portfolio-optimizer .btn-danger:hover {
    background-color: #c82333;
    border-color: #bd2130;
}

/* Empty State */
#empty-state {
    color: #6c757d;
}

#empty-state i {
    opacity: 0.3;
}

/* Action Buttons */
#calculate-btn,
#optimize-btn {
    min-width: 200px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#calculate-btn:disabled,
#optimize-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Cards */
.portfolio-optimizer .card {
    border: none;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.08);
    margin-bottom: 2rem;
    border-radius: 0.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.portfolio-optimizer .card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.75rem 1.5rem rgba(0, 0, 0, 0.12);
}

.portfolio-optimizer .card-header {
    background-color: #f8f9fa;
    border-bottom: 3px solid #212529;
    padding: 1.25rem 1.5rem;
    border-radius: 0.5rem 0.5rem 0 0;
}

.portfolio-optimizer .card-header h3 {
    color: #212529;
    font-size: 1.35rem;
    font-weight: 600;
    margin: 0;
}

.portfolio-optimizer .card-header h4 {
    margin: 0;
}

.portfolio-optimizer .card-body {
    padding: 2rem;
}

/* Input Groups */
.portfolio-optimizer .input-group-lg .form-control {
    font-size: 1.125rem;
}

/* Lookback Period Select */
#lookback-period {
    background-color: #f8f9fa;
}

/* Results Section (for future phases) */
#results-section .spinner-border {
    width: 3rem;
    height: 3rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .portfolio-optimizer .hero-section {
        padding: 40px 0;
    }
    
    .portfolio-optimizer .hero-section h1 {
        font-size: 2rem;
    }
    
    #calculate-btn,
    #optimize-btn {
        min-width: auto;
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .table-responsive {
        font-size: 0.875rem;
    }
    
    .weight-input {
        max-width: 100px !important;
    }
    
    /* Smaller font in weight inputs on mobile */
    .weight-input.form-control {
        font-size: 0.875rem;
        padding: 0.25rem 0.5rem;
    }
    
    /* Center align lookback period on mobile */
    #lookback-period {
        text-align: center;
        text-align-last: center;
    }
    
    #lookback-period + .form-text {
        text-align: center;
    }
}

/* Buttons */
.portfolio-optimizer .btn {
    transition: all 0.3s ease;
    font-weight: 500;
    padding: 0.5rem 1.5rem;
    border-radius: 0.375rem;
}

.portfolio-optimizer .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.portfolio-optimizer .btn-primary {
    background: linear-gradient(135deg, #0066cc 0%, #004499 100%);
    border: none;
}

.portfolio-optimizer .btn-primary:hover {
    background: linear-gradient(135deg, #0052a3 0%, #003366 100%);
}

.portfolio-optimizer .btn-lg {
    padding: 0.75rem 2rem;
    font-size: 1.125rem;
}

/* Form Controls */
.portfolio-optimizer .form-control:focus,
.portfolio-optimizer .form-select:focus {
    border-color: #0066cc;
    box-shadow: 0 0 0 0.2rem rgba(0, 102, 204, 0.25);
}

/* Tables */
.portfolio-optimizer .table {
    margin-bottom: 0;
}

.portfolio-optimizer .table th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    color: #6c757d;
}

/* Loading States (for future phases) */
.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    margin: -10px 0 0 -10px;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Alert Styling */
.portfolio-optimizer .alert {
    border: none;
    border-radius: 0.5rem;
    padding: 1.25rem;
}

.portfolio-optimizer .alert-info {
    background-color: #e7f3ff;
    color: #0066cc;
    border-left: 4px solid #0066cc;
}

.portfolio-optimizer .alert-warning {
    background-color: #fff3cd;
    color: #856404;
    border-left: 4px solid #ffc107;
}

.portfolio-optimizer .alert h5 {
    font-weight: 600;
    margin-bottom: 0.75rem;
}

/* Empty State */
#empty-state {
    padding: 4rem 2rem;
}

#empty-state i {
    color: #dee2e6;
    margin-bottom: 1rem;
}

#empty-state p {
    color: #6c757d;
    font-size: 1.125rem;
}

/* Metrics Display */
#portfolio-table th.text-end,
#portfolio-table td.text-end {
    text-align: right;
}

.text-success {
    color: #28a745 !important;
    font-weight: 600;
}

.text-danger {
    color: #dc3545 !important;
    font-weight: 600;
}

/* Results Section */
#optimization-results .card-header {
    background: linear-gradient(135deg, #0066cc 0%, #004499 100%);
    color: white;
    border: none;
}

#optimization-results h5 {
    color: #212529;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e9ecef;
}

#optimization-results .table-sm td {
    padding: 0.5rem;
    white-space: nowrap;
}

#optimization-results .table-sm td:last-child {
    min-width: 180px;
}

#optimization-results .table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(0, 0, 0, 0.02);
}

/* Hoverable table sections */
.results-table-wrapper {
    padding: 1rem;
    border-radius: 0.5rem;
    transition: all 0.3s ease;
    cursor: default;
}

.results-table-wrapper:hover {
    background-color: #f8f9fa;
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.results-table-wrapper table {
    margin-bottom: 0;
}

/* Individual Security Analysis table hover */
.security-analysis-wrapper {
    transition: all 0.3s ease;
    border-radius: 0.5rem;
    overflow: hidden;
}

.security-analysis-wrapper:hover {
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.security-analysis-wrapper:hover table {
    background-color: #fafbfc;
}

/* Portfolio comparison hover effects */
.portfolio-comparison-col {
    padding: 1rem;
    border-radius: 0.5rem;
    transition: all 0.3s ease;
}

.portfolio-comparison-col:hover {
    background-color: #f8f9fa;
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* Smooth Transitions */
.portfolio-optimizer * {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Chart Container */
#efficient-frontier-chart {
    max-width: 100%;
    height: 400px;
}

.chart-container {
    background-color: #ffffff;
    border-radius: 0.5rem;
    padding: 1rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.portfolio-row {
    opacity: 0;
}

.portfolio-row.animate-in {
    animation: fadeInUp 0.3s ease forwards;
}

/* Toast Styling */
.toast {
    border: none;
    border-radius: 0.5rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.toast-body {
    border-radius: 0.5rem;
    padding: 1rem 1.5rem;
}

/* Loading State Improvements */
.modal-content {
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.175);
}

.spinner-border {
    border-width: 0.2em;
}

/* Risk-free rate display */
#risk-free-rate-display .alert {
    margin-bottom: 0;
}

/* Risk-free Rate and Weight Constraints */
.portfolio-optimizer .card.border-secondary {
    border-color: #dee2e6 !important;
    background-color: #f8f9fa;
}

.portfolio-optimizer .card.border-secondary .card-body {
    background-color: #f8f9fa;
}

#current-rf-rate {
    font-weight: 600;
}

#custom-rf-rate {
    max-width: 100px;
}

#min-weight, #max-weight {
    max-width: 80px;
    text-align: center;
}

#weight-constraint-error {
    font-size: 0.875rem;
}

/* Responsive metrics table */
@media (max-width: 768px) {
    #portfolio-table {
        font-size: 0.8rem;
    }
    
    #portfolio-table th,
    #portfolio-table td {
        padding: 0.5rem 0.25rem;
    }
    
    /* Stack weight constraints on mobile */
    .portfolio-optimizer .card.border-secondary .row > .col-md-6 {
        margin-bottom: 1rem;
    }
}