/* AlgoStorm Trading Calculators - Main Stylesheet */

/* Color Variables - AlgoStorm Website Palette */
:root {
    --primary-color: #2e2e2e;
    /* Dark gray for primary elements */
    --secondary-color: #2e2e2e;
    /* Dark gray for accents and highlights */
    --success-color: #2e2e2e;
    /* Dark gray for success states */
    --warning-color: #2e2e2e;
    /* Dark gray for warnings */
    --danger-color: #2e2e2e;
    /* Dark gray for errors */
    --light-color: #f5f5f5;
    /* Light gray for backgrounds */
    --dark-color: #2e2e2e;
    /* Dark gray for text */
    --muted-color: #d5d5d5;
    /* Muted gray for secondary text */
    --border-color: #d5d5d5;
    /* Light gray for borders */
    --shadow-color: rgba(0, 0, 0, 0.05);
    /* Subtle shadow color */
    --hover-transition: all 0.2s ease;
    /* Transition for hover effects */

    /* Text colors for success/error states */
    --text-success: #2e7d32;
    /* Dark green for success text */
    --text-danger: #c62828;
    /* Dark red for error text */
}

/* Global Styles */
body {
    background-color: var(--light-color);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--dark-color);
    line-height: 1.6;
    transition: var(--hover-transition);
}

/* Layout Styles */
.page-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 320px;
    background-color: var(--primary-color);
    color: white;
    box-shadow: 2px 0 5px var(--shadow-color);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1030;
    overflow-y: auto;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), width 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform, width;
}

.sidebar.collapsed {
    width: 60px;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-brand-container {
    display: flex;
    align-items: center;
    flex: 1;
}

.sidebar-logo {
    width: 32px;
    height: 32px;
    margin-right: 0.75rem;
}

.sidebar-controls {
    display: flex;
    align-items: center;
}

.sidebar.collapsed .sidebar-header {
    padding: 1rem 0.5rem;
    justify-content: center;
}

.sidebar-brand {
    font-weight: 600;
    font-size: 1.1rem;
    color: white;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar.collapsed .sidebar-brand {
    display: none;
}

.sidebar.collapsed .sidebar-logo {
    margin-right: 0;
}

.sidebar-brand:hover {
    color: rgba(255, 255, 255, 0.9);
    transform: translateX(2px);
    will-change: color, transform, box-shadow;
    transition: color 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
    margin-left: 0.5rem;
    transition: color 0.2s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: color, background-color;
}

.sidebar-collapse-toggle {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
    margin-left: 0.5rem;
    transition: color 0.2s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: color, background-color;
}

.sidebar-close:hover,
.sidebar-collapse-toggle:hover {
    color: rgba(255, 255, 255, 0.8);
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    transition: color 0.2s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: color, background-color, box-shadow;
}

.sidebar.collapsed .sidebar-collapse-toggle {
    margin-left: 0;
}

.sidebar-body {
    padding: 0.5rem 0;
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav-item {
    margin-bottom: 0;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border-left: 3px solid transparent;
    white-space: nowrap;
    font-size: 0.9rem;
    will-change: background-color, color, border-left-color, transform;
}

.sidebar.collapsed .sidebar-nav-link {
    padding: 0.75rem 0;
    justify-content: center;
}

.sidebar-nav-link:hover {
    color: white;
    background-color: rgba(255, 255, 255, 0.15);
    border-left-color: rgba(255, 255, 255, 0.5);
    transform: translateX(2px);
    will-change: background-color, color, border-left-color, transform, box-shadow;
}

.sidebar-nav-link.active {
    color: white;
    background-color: rgba(255, 255, 255, 0.15);
    border-left-color: white;
    transform: translateX(2px);
    will-change: background-color, color, border-left-color, transform, box-shadow;
}

.sidebar-nav-link i {
    margin-right: 0.5rem;
    font-size: 1rem;
    min-width: 1.25rem;
    text-align: center;
}

.sidebar.collapsed .sidebar-nav-link i {
    margin-right: 0;
}

.sidebar-nav-link span {
    transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: opacity;
}

.sidebar.collapsed .sidebar-nav-link span {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar-divider {
    height: 1px;
    background-color: rgba(255, 255, 255, 0.1);
    margin: 0.5rem 1rem;
}

.sidebar.collapsed .sidebar-divider {
    margin: 0.5rem 0.5rem;
}

.content-wrapper {
    flex: 1;
    margin-left: 320px;
    padding-left: 1.5rem;
    padding-top: 1.5rem;
    padding-right: 1.5rem;
    transition: margin-left 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 100%;
    will-change: margin-left;
}

.sidebar.collapsed~.content-wrapper {
    margin-left: 80px;
}

.top-navbar {
    background-color: white;
    box-shadow: 0 2px 5px var(--shadow-color);
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-toggle-container {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 100;
}

.content-container {
    padding: 1rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--primary-color);
    margin: 0;
}

.sidebar-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--primary-color);
    font-size: 1.5rem;
    cursor: pointer;
}

.sidebar-toggle-container .sidebar-toggle {
    display: flex;
    background-color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    box-shadow: 0 2px 5px var(--shadow-color);
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: background-color, box-shadow, transform;
}

.sidebar-toggle-container .sidebar-toggle:hover {
    background-color: var(--light-color);
    box-shadow: 0 4px 8px var(--shadow-color);
    transform: scale(1.05);
    transition: background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: background-color, box-shadow, transform;
}

/* Mobile Navigation */
/* Responsive Styles */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        width: 260px;
    }

    .sidebar.collapsed {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
        box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
        z-index: 1050;
        will-change: transform, box-shadow;
    }

    .sidebar-close {
        display: block;
    }

    .content-wrapper {
        margin-left: 0 !important;
        padding: 1rem;
    }

    .sidebar-toggle {
        display: block;
    }

    .top-navbar {
        padding: 0.75rem 1rem;
        margin-bottom: 1rem;
    }

    .page-title {
        font-size: 1.25rem;
    }

    .card {
        margin-bottom: 1rem;
    }

    .card-header {
        padding: 0.75rem 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    /* Fix for narrow layout */
    .row {
        display: flex;
        flex-wrap: wrap;
    }

    .row>.col {
        flex: 0 0 100%;
        max-width: 100%;
        margin-bottom: 1rem;
    }
}

@media (max-width: 768px) {

    .container-fluid,
    .container {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 0.5rem;
    }

    .row {
        margin-left: 0;
        margin-right: 0;
        display: flex;
        flex-direction: column;
    }

    .col,
    .col-1,
    .col-2,
    .col-3,
    .col-4,
    .col-5,
    .col-6,
    .col-7,
    .col-8,
    .col-9,
    .col-10,
    .col-11,
    .col-12,
    .col-md-4,
    .col-md-6,
    .col-md-8,
    .col-lg-4,
    .col-lg-6,
    .col-lg-8 {
        flex: 0 0 100%;
        max-width: 100%;
        padding-left: 0;
        padding-right: 0;
        margin-bottom: 1rem;
        width: 100%;
    }

    .card {
        width: 100%;
    }

    .card-body {
        padding: 1rem;
    }

    .input-group {
        flex-wrap: wrap;
        width: 100%;
    }

    .input-group>.form-control {
        flex: 1 1 100%;
        width: 100%;
        border-radius: 0.375rem !important;
        margin-bottom: 0.5rem;
    }

    .input-group>.input-group-text {
        border-radius: 0.375rem !important;
        margin-bottom: 0.5rem;
    }

    .input-group>.btn {
        flex: 1 1 auto;
        width: auto;
        border-radius: 0.375rem !important;
    }

    .input-group>*:not(:first-child) {
        margin-left: 0;
    }

    .content-container {
        padding: 0.5rem;
    }
}

@media (max-width: 576px) {
    .sidebar {
        width: 100%;
    }

    .sidebar-brand {
        font-size: 1.1rem;
    }

    .sidebar-nav-link {
        padding: 0.6rem 1rem;
    }

    .sidebar-close {
        display: block;
    }

    .sidebar-collapse-toggle {
        display: none;
    }

    .btn {
        padding: 0.5rem 1rem;
    }

    .form-label {
        margin-bottom: 0.25rem;
    }
}

/* Card Styles */
.card {
    box-shadow: 0 2px 8px var(--shadow-color);
    border-radius: 0.375rem;
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    transition: var(--hover-transition);
    overflow: hidden;
    will-change: box-shadow;
}

.card:hover {
    box-shadow: 0 4px 12px var(--shadow-color);
}

.card-header {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.card-body {
    padding: 1.5rem;
    background-color: white;
}

/* Form Styles */
.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--dark-color);
}

.input-group {
    margin-bottom: 1.25rem;
    border-radius: 0.375rem;
    overflow: hidden;
    width: 100%;
}

.form-control {
    border: 1px solid var(--border-color);
    padding: 0.625rem 0.75rem;
    transition: var(--hover-transition);
    width: 100%;
    will-change: border-color, box-shadow;
}

.form-control:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 0.2rem rgba(46, 46, 46, 0.25);
}

.input-group-text {
    background-color: var(--primary-color);
    color: white;
    border: none;
    font-weight: 500;
}

/* Output field styles (disabled/readonly input) - Match regular input fields */
.form-control:disabled,
.form-control[readonly],
.result-field {
    background-color: #f8f9fa;
    opacity: 1;
    cursor: not-allowed;
    box-shadow: none;
    border-color: var(--border-color);
    height: auto;
    min-height: calc(1.5em + 1.25rem + 2px);
    padding: 0.625rem 0.75rem;
}

/* Fix for calculator forms */
.card-body .form-group {
    width: 100%;
}

.card-body .row {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
}

/* Button Styles */
.btn {
    font-weight: 500;
    padding: 0.625rem 1.25rem;
    border-radius: 0.25rem;
    transition: var(--hover-transition);
    position: relative;
    border-width: 1px;
    margin: 0.25rem;
    will-change: background-color, border-color, box-shadow;
}

.btn-outline-dark {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-outline-dark:hover {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 2px 4px var(--shadow-color);
}

.btn-outline-light {
    border-color: white;
    color: white;
}

.btn-outline-light:hover {
    background-color: white;
    color: var(--primary-color);
    box-shadow: 0 2px 4px var(--shadow-color);
}

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

.btn-primary:hover {
    background-color: #1e1e1e;
    border-color: #1e1e1e;
    box-shadow: 0 2px 4px var(--shadow-color);
}

.btn-success {
    background-color: var(--text-success);
    border-color: var(--text-success);
    color: white;
}

.btn-success:hover {
    background-color: #1b5e20;
    border-color: #1b5e20;
    box-shadow: 0 2px 4px var(--shadow-color);
}

.btn-danger {
    background-color: var(--text-danger);
    border-color: var(--text-danger);
    color: white;
}

.btn-danger:hover {
    background-color: #b71c1c;
    border-color: #b71c1c;
    box-shadow: 0 2px 4px var(--shadow-color);
}

.btn-block {
    width: calc(100% - 0.5rem);
    display: block;
}

.btn-group {
    display: flex;
    flex-wrap: wrap;
    margin: -0.25rem;
}

.btn-group .btn {
    flex: 1;
    min-width: 120px;
}

/* Spacing Utilities */
.mb-3 {
    margin-bottom: 1rem;
}

.mt-3 {
    margin-top: 1rem;
}

.mb-5 {
    margin-bottom: 3rem;
}

.mt-5 {
    margin-top: 3rem;
}

/* Form Validation Styles */
.form-control.is-valid {
    border-color: var(--border-color);
    box-shadow: 0 0 0 1px rgba(46, 125, 50, 0.25);
    /* No checkmark icon for a more subtle approach */
}

.form-control.is-invalid {
    border-color: var(--text-danger);
    box-shadow: 0 0 0 1px rgba(198, 40, 40, 0.25);
    /* Simplified error indicator */
}

.invalid-feedback {
    display: none;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875em;
    color: var(--text-danger);
}

.valid-feedback {
    display: none;
    /* We're not using valid feedback messages */
}

.was-validated .form-control:invalid~.invalid-feedback,
.form-control.is-invalid~.invalid-feedback {
    display: block;
}

/* Text color classes */
.text-success {
    color: var(--text-success) !important;
}

.text-danger {
    color: var(--text-danger) !important;
}

/* Loading Indicator Styles */
.loading-spinner {
    display: inline-block;
    width: 1.5rem;
    height: 1.5rem;
    vertical-align: text-bottom;
    border: 0.2em solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinner-border .75s linear infinite;
}

@keyframes spinner-border {
    to {
        transform: rotate(360deg);
    }
}

.btn .loading-spinner {
    margin-right: 0.5rem;
}

/* Home Page Styles */
#calculator-tabs .nav-link {
    color: var(--dark-color);
}

#calculator-tabs .nav-link.active {
    background-color: var(--dark-color) !important;
    color: white !important;
    border-color: var(--dark-color) !important;
}

#calculator-tabs .nav-link:hover:not(.active) {
    background-color: rgba(46, 46, 46, 0.1);
    color: var(--dark-color);
}

/* Remove Bootstrap's default bg-dark class from the active tab */
#calculator-tabs .nav-link.active.bg-dark {
    background-color: var(--dark-color) !important;
}

.icon-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--dark-color);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.5rem;
}

/* PnL Calculator Styles */
#trade_log_table tbody tr {
    height: 29px;
    /* Set row height to fit 12 rows in the container */
}

#trade_log_table {
    margin-bottom: 0;
}

/* Tooltip Styles */
.tooltip-container {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 5px;
    vertical-align: middle;
    z-index: 100;
}

.tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: var(--muted-color);
    color: white;
    font-size: 10px;
    font-weight: bold;
    cursor: pointer;
    position: relative;
    z-index: 101;
    flex-shrink: 0;
}

.tooltip-text {
    visibility: hidden;
    width: 200px;
    background-color: var(--dark-color);
    color: white;
    text-align: center;
    border-radius: 6px;
    padding: 0.5rem;
    position: absolute;
    z-index: 1000;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.2s ease;
    font-size: 0.875rem;
    box-shadow: 0 4px 8px var(--shadow-color);
    pointer-events: none;
    will-change: opacity;
}

.tooltip-container:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* Ensure tooltips don't break layout in form groups */
.form-group .tooltip-container {
    display: inline-flex;
    vertical-align: middle;
    margin-left: 5px;
}

/* For labels with tooltips, ensure they stay inline */
.form-label + .tooltip-container {
    display: inline-flex;
    vertical-align: middle;
}

/* Calculator-specific Styles */
.calculator-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

.result-highlight {
    background-color: rgba(52, 152, 219, 0.05);
    border-left: 4px solid var(--secondary-color);
    padding: 1rem;
    border-radius: 0.25rem;
    margin-bottom: 1rem;
    transition: background-color 0.2s ease;
    will-change: background-color;
}


.bg-pulse {
    animation: pulse-animation 0.8s ease-in-out;
    will-change: background-color;
}

@keyframes pulse-animation {
    0% {
        background-color: rgba(52, 152, 219, 0.05);
    }

    50% {
        background-color: rgba(52, 152, 219, 0.2);
    }

    100% {
        background-color: rgba(52, 152, 219, 0.05);
    }
}

/* Stat Cards */
.stat-card {
    padding: 0.5rem;
    border-radius: 0.375rem;
    background-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    height: 100%;
    transition: box-shadow 0.2s ease;
    will-change: box-shadow;
}

.stat-card:hover {
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.stat-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.25rem;
}

/* Compact form styles */
.form-control-sm {
    height: calc(1.5em + 0.5rem + 2px);
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.input-group-sm>.form-control,
.input-group-sm>.input-group-text {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.export-section {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* Log Styles */
.log-container {
    position: relative;
    max-height: 400px;
    overflow: auto;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 0.375rem;
}

.log-area {
    border: none;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    background-color: #f8f9fa;
    color: #212529;
    resize: none;
}

.log-area:focus {
    box-shadow: none;
    outline: none;
}

/* Chart Styles */
#chart-container {
    position: relative;
    margin-top: 1rem;
    border-radius: 0.375rem;
    overflow: hidden;
    background-color: rgba(255, 255, 255, 0.5);
    width: 100% !important;
    height: 400px !important;
}

canvas {
    width: 100% !important;
    max-width: 100%;
}

/* Print Styles */
@media print {

    .sidebar,
    .top-navbar,
    .btn,
    .form-text,
    .export-section {
        display: none !important;
    }

    .content-wrapper {
        margin-left: 0 !important;
        padding: 0 !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }

    .card-header {
        background-color: #f8f9fa !important;
        color: #000 !important;
    }

    .result-highlight {
        background-color: transparent !important;
        border-left: none !important;
    }

    .stat-card {
        box-shadow: none !important;
        padding: 0 !important;
    }

    .container,
    .row,
    .col,
    .col-md-4 {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    body {
        font-size: 12pt;
    }

    h1,
    h2,
    h3 {
        page-break-after: avoid;
    }

    canvas {
        max-width: 100% !important;
        height: auto !important;
    }
}

/* Accessibility Improvements */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus Styles for Accessibility */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--secondary-color);
    outline-offset: 2px;
}

/* Responsive Adjustments */
@media (max-width: 992px) {
    .container.col-6 {
        width: 100%;
        max-width: 100%;
    }

    .navbar h1.fs-2 {
        font-size: 1.5rem !important;
    }

    .card {
        margin-bottom: 1rem;
    }

    .input-group {
        flex-direction: column;
    }

    .input-group>* {
        width: 100%;
        margin-right: 0;
        border-radius: 0.375rem !important;
    }

    .input-group-text {
        border-radius: 0.375rem 0.375rem 0 0 !important;
    }

    .input-group .form-control:not(:first-child) {
        border-radius: 0 0 0.375rem 0.375rem !important;
    }
}

@media (max-width: 576px) {
    .navbar .container-fluid {
        flex-direction: column;
        align-items: center;
    }

    .navbar-brand,
    .navbar h1,
    .navbar .btn {
        margin: 0.5rem 0;
    }

    .card-body {
        padding: 1rem;
    }

    .btn {
        padding: 0.5rem 1rem;
    }
}
