/*==============================================
  MOBILE RESPONSIVE STYLES
  Breakpoints:
  - Large tablets: max-width: 1024px
  - Small tablets: max-width: 768px
  - Mobile phones: max-width: 480px
==============================================*/

/* Tablets and smaller devices */
@media screen and (max-width: 1024px) {
    /* Adjust base font sizes for better readability */
    body {
        font-size: 16px;
        line-height: 1.4;
    }

    /* Make headers more compact */
    h1 { font-size: 24px; }
    h2 { font-size: 20px; }
    h3 { font-size: 18px; }
    h4, h5, h6 { font-size: 16px; }

    /* Adjust explanation component */
    #explanationText {
        max-width: 90%;
        margin: 10px auto;
        padding: 15px;
    }

    /* Adjust modal sizes */
    .modal-content {
        width: 90%;
        margin: 5% auto;
        padding: 15px;
    }

    /* Make buttons larger for touch targets */
    .action-button,
    #alertOkButton {
        padding: 12px 20px;
        font-size: 16px;
        margin: 10px 5px;
    }
}

/* Small tablets and large phones */
@media screen and (max-width: 768px) {
    /* Adjust layout for results display */
    .result-row {
        flex-direction: column;
        align-items: flex-start;
        margin-bottom: 15px;
    }

    .label {
        width: 100%;
        margin-bottom: 5px;
    }

    .value {
        width: 100%;
        padding-left: 0;
    }

    /* Adjust calculation results */
    .calculation-result-row {
        flex-direction: column;
        align-items: flex-start;
        margin-bottom: 15px;
    }

    .calculation-result-row .result-value {
        margin-left: 0;
        margin-top: 5px;
    }

    /* Adjust notes section */
    .trade-notes-area {
        width: 100%;
        min-height: 120px;
    }

    /* Modal adjustments */
    .alert-content {
        max-width: 90%;
        margin: 0 10px;
    }
}

/* Mobile phones */
@media screen and (max-width: 480px) {
    /* Further reduce font sizes */
    body {
        font-size: 14px;
    }

    /* Adjust header sizes */
    h1 { font-size: 20px; }
    h2 { font-size: 18px; }
    h3 { font-size: 16px; }
    h4, h5, h6 { font-size: 14px; }

    /* Stack buttons vertically */
    .action-button {
        width: 100%;
        margin: 5px 0;
    }

    /* Adjust modal content */
    .modal-content {
        margin: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    /* Make alert modals full screen */
    .alert-modal {
        padding: 10px;
    }

    .alert-content {
        padding: 15px;
        width: 100%;
    }

    /* Adjust form inputs */
    .date-input {
        width: 100%;
        margin-bottom: 10px;
    }

    /* Adjust explanation text */
    #explanationText {
        margin: 5px;
        padding: 10px;
    }

    #explanationText ol {
        padding-left: 20px;
    }

    /* Adjust list spacing */
    #explanationText ol li {
        margin: 8px 0;
    }
}

/* Handle device orientation */
@media screen and (max-height: 480px) and (orientation: landscape) {
    /* Adjust modal positioning for landscape */
    .modal-content {
        margin: 0;
        max-height: 100vh;
        overflow-y: auto;
    }

    /* Make content scrollable */
    #explanationText {
        max-height: 80vh;
        overflow-y: auto;
    }
}

/* Handle high-DPI devices */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Adjust border widths for retina displays */
    .modal-content,
    .trade-notes-area,
    .date-input {
        border-width: 0.5px;
    }
}

/* iOS-specific adjustments */
@supports (-webkit-touch-callout: none) {
    /* Prevent input zoom on iOS */
    input[type="text"],
    input[type="number"],
    input[type="date"],
    textarea {
        font-size: 16px;
    }

    /* Fix scrolling issues */
    .modal-content,
    #explanationText {
        -webkit-overflow-scrolling: touch;
    }
}

/* Android-specific adjustments */
@supports not (-webkit-touch-callout: none) {
    /* Adjust button tap highlight color */
    .action-button {
        -webkit-tap-highlight-color: rgba(0,0,0,0);
    }
}

/* Additional accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    /* Reduce or remove animations */
    .notes-container,
    .action-button {
        transition: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .modal-content,
    .alert-content {
        background-color: #0d2541;
        color: #F5E8D9;
    }

    .date-input,
    .trade-notes-area {
        background-color: #1a3152;
        color: #F5E8D9;
        border-color: #2a4162;
    }
}