/**
 * Responsive CSS for DAE/APR Calculator
 * Breakpoints:
 * - Mobile (Smallest): 320px - 480px
 * - Mobile (Large): 481px - 767px
 * - Tablet (Portrait): 768px - 1023px
 * - Tablet/Small Desktop (Landscape/Laptop): 1024px - 1279px
 * - Desktop (Large): 1280px - 1919px
 * - Desktop (Extra Large): 1920px+
 */

/* ==========================================================================
   BASE RESPONSIVE UTILITIES
   ========================================================================== */

/* Ensure box-sizing consistency */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* Prevent horizontal scroll on mobile */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* Container adjustments */
.container-fluid {
    padding-left: 15px;
    padding-right: 15px;
}

/* ==========================================================================
   MOBILE SMALLEST (320px - 480px)
   ========================================================================== */
@media screen and (max-width: 480px) {
    /* Typography */
    body {
        font-size: 14px;
        line-height: 1.5;
    }

    h1, .articleHeading h1 {
        font-size: 22px !important;
        line-height: 1.3;
    }

    h2 {
        font-size: 18px !important;
    }

    h3 {
        font-size: 16px !important;
    }

    h4, h5 {
        font-size: 15px !important;
    }

    .heading {
        font-size: 18px;
        line-height: 1.4;
    }

    /* Layout - Full width columns */
    .col-md-6,
    .col-md-5,
    .col-md-7,
    .col-md-4,
    .col-md-3,
    .col-md-8,
    .col-md-9,
    .col-md-12 {
        flex: 0 0 100%;
        max-width: 100%;
        width: 100%;
        padding-left: 10px;
        padding-right: 10px;
    }

    .row {
        margin-left: -10px;
        margin-right: -10px;
    }

    /* Form elements */
    .form-control,
    select.form-control,
    input[type="text"],
    input[type="number"],
    input[type="email"],
    textarea {
        font-size: 16px !important; /* Prevents iOS zoom */
        height: 44px;
        padding: 10px 12px;
    }

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

    .input-group .form-control {
        min-width: 0;
        flex: 1 1 auto;
    }

    .input-group-text,
    .input-group-addon {
        width: auto !important;
        min-width: 50px;
        padding: 8px 10px;
        font-size: 14px;
    }

    /* Buttons */
    .btn {
        width: 100%;
        min-width: unset !important;
        max-width: 100%;
        height: auto;
        min-height: 44px;
        padding: 12px 16px;
        font-size: 14px;
        margin: 5px 0;
        border-radius: 6px;
    }

    .btn-primary,
    .btn-danger,
    .btn-reset,
    .btn-outline-secondary {
        display: block;
        width: 100%;
    }

    /* Accordion */
    .category-heading.accordion {
        font-size: 15px;
        padding: 12px 40px 12px 12px;
        line-height: 1.4;
    }

    .category-heading.accordion:after {
        right: 12px;
        font-size: 22px;
    }

    .accordion-body,
    .panel-body {
        padding: 12px;
    }

    /* Panel rows */
    .panel.p-3.row {
        padding: 10px !important;
        margin-bottom: 10px;
    }

    .panel.p-3.row .col-md-7,
    .panel.p-3.row .col-md-5 {
        padding: 0;
        margin-bottom: 10px;
    }

    .panel.p-3.row .col-md-5 {
        margin-bottom: 0;
    }

    /* Labels in panels */
    .label.label-color {
        width: 22px !important;
        height: 22px !important;
        line-height: 22px;
        font-size: 12px;
        margin-right: 8px;
    }

    /* Tables */
    .table-responsive {
        margin: 0 -10px;
        padding: 0;
        width: calc(100% + 20px);
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 500px;
    }

    th, td {
        padding: 8px 6px;
        font-size: 12px;
    }

    /* Costs table - better mobile experience */
    .costs .form-control {
        min-width: 80px;
        font-size: 12px;
        padding: 4px 6px;
        height: 32px;
    }

    .costs select.form-control {
        min-width: 120px;
    }

    .costs .checkbox label {
        font-size: 12px;
    }

    /* Results section */
    .rezultate-sectiune {
        padding-top: 15px;
    }

    .rezultate-col {
        border-right: none;
        border-bottom: 1px dotted #aaa;
        padding-bottom: 15px;
        margin-bottom: 15px;
    }

    .rezultate-col:last-child {
        border-bottom: none;
        margin-bottom: 0;
        padding-bottom: 0;
    }

    .rezultate-item {
        font-size: 13px;
    }

    .highlight-red {
        padding: 8px;
    }

    /* Cards */
    .card {
        padding: 12px;
        margin-bottom: 10px;
    }

    /* Modal */
    .modal-dialog {
        margin: 10px;
        max-width: calc(100% - 20px);
    }

    .modal-body {
        padding: 15px;
    }

    .modal-footer {
        padding: 10px 15px;
        flex-direction: column;
    }

    .modal-footer .btn {
        width: 100%;
        margin: 5px 0;
    }

    /* Footer */
    .disclaimer_footer {
        flex-direction: column;
        text-align: center;
        padding: 15px;
    }

    .disclaimer_footer .copyright-logo {
        margin-right: 0;
        margin-bottom: 15px;
    }

    .disclaimer_footer .copyright-logo img {
        max-height: 100px;
    }

    .disclaimer_footer p {
        text-align: center;
        font-size: 13px;
    }

    /* Navbar */
    .navbar li a {
        padding: 15px 12px;
        font-size: 16px;
    }

    /* Fixed height overrides */
    .row-flex,
    .row-flex-nodesrc {
        height: auto !important;
        min-height: auto !important;
    }

    /* Info popover positioning */
    .info-popover {
        display: inline-block;
        margin-left: 5px;
    }

    .popover {
        max-width: 280px;
    }

    /* Share section */
    .share {
        text-align: center;
    }

    /* Foreign currency options */
    #foreign-currency-options .fc-row {
        flex-direction: column;
        align-items: flex-start;
    }

    #foreign-currency-options .fc-label {
        flex: 0 0 100%;
        max-width: 100%;
        margin-bottom: 5px;
    }

    #foreign-currency-options .fc-field {
        width: 100%;
    }

    #foreign-currency-options .fc-help {
        margin-left: 0;
    }

    /* Example selector */
    #example-selector-panel {
        padding: 10px;
    }

    #example-selector-panel .form-control {
        margin-bottom: 10px;
    }

    /* Costs table */
    .costs thead th {
        font-size: 11px;
        padding: 6px 4px;
    }

    /* Loan info boxes */
    .loan-info {
        padding: 12px;
        margin-bottom: 10px;
    }

    .loan-info p {
        font-size: 16px;
    }

    /* Bootstrap select override */
    .bootstrap-select:not([class*=col-]):not([class*=form-control]):not(.input-group-btn) {
        width: 100% !important;
    }

    /* Two levels interest note */
    #apr_two_levels_note {
        font-size: 12px;
        padding: 8px;
    }
}

/* ==========================================================================
   MOBILE LARGE (481px - 767px)
   ========================================================================== */
@media screen and (min-width: 481px) and (max-width: 767px) {
    body {
        font-size: 14px;
    }

    h1, .articleHeading h1 {
        font-size: 26px;
    }

    /* Layout - Still mostly full width */
    .col-md-6,
    .col-md-5,
    .col-md-7 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .col-md-4,
    .col-md-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    /* Rezultate borders - remove on mobile */
    .rezultate-col {
        border-right: none;
        border-bottom: 1px dotted #aaa;
        padding-bottom: 15px;
        margin-bottom: 15px;
    }

    .rezultate-col:last-child {
        border-bottom: none;
        margin-bottom: 0;
        padding-bottom: 0;
    }

    /* Buttons - Allow side by side */
    .btn {
        min-width: unset !important;
        height: auto;
        min-height: 44px;
        padding: 10px 16px;
        margin: 5px;
    }

    /* Form elements */
    .form-control {
        font-size: 15px !important;
        height: 42px;
    }

    /* Modal */
    .modal-dialog {
        margin: 20px auto;
        max-width: 90%;
    }

    /* Panel rows */
    .panel.p-3.row .col-md-7,
    .panel.p-3.row .col-md-5 {
        flex: 0 0 100%;
        max-width: 100%;
        padding: 5px 0;
    }

    /* Tables */
    .table-responsive {
        overflow-x: auto;
    }

    table {
        min-width: 450px;
    }

    /* Fixed heights */
    .row-flex,
    .row-flex-nodesrc {
        height: auto !important;
    }

    /* Footer */
    .disclaimer_footer {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .disclaimer_footer .copyright-logo img {
        max-height: 120px;
    }
}

/* ==========================================================================
   TABLET PORTRAIT (768px - 1023px)
   ========================================================================== */
@media screen and (min-width: 768px) and (max-width: 1023px) {
    body {
        font-size: 15px;
    }

    h1, .articleHeading h1 {
        font-size: 28px;
    }

    /* Layout - Two column where appropriate */
    .col-md-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    .col-md-5 {
        flex: 0 0 41.666667%;
        max-width: 41.666667%;
    }

    .col-md-7 {
        flex: 0 0 58.333333%;
        max-width: 58.333333%;
    }

    .col-md-4 {
        flex: 0 0 33.333333%;
        max-width: 33.333333%;
    }

    /* Panel rows - keep side by side */
    .panel.p-3.row .col-md-7,
    .panel.p-3.row .col-md-5 {
        padding: 5px 10px;
    }

    /* Buttons */
    .btn {
        min-width: 150px !important;
        height: 42px;
        padding: 10px 20px;
        margin: 5px;
    }

    /* Form elements */
    .form-control {
        height: 40px;
    }

    /* Modal */
    .modal-dialog {
        max-width: 700px;
    }

    /* Tables */
    table {
        min-width: auto;
    }

    th, td {
        padding: 10px 8px;
        font-size: 14px;
    }

    /* Container */
    .container-fluid {
        max-width: 100%;
        padding-left: 20px;
        padding-right: 20px;
    }

    /* Fixed heights - auto for flexibility */
    .row-flex {
        height: auto !important;
        min-height: 400px !important;
    }

    .row-flex-nodesrc {
        height: auto !important;
        min-height: 300px !important;
    }

    /* Results section */
    .rezultate-col {
        border-right: 1px dotted #aaa;
    }

    .rezultate-col:last-child {
        border-right: none;
    }

    /* Side menu toggle */
    .side-menu-toggle {
        display: block;
    }

    /* Footer */
    .disclaimer_footer .copyright-logo img {
        max-height: 150px;
    }
}

/* ==========================================================================
   TABLET LANDSCAPE / SMALL DESKTOP (1024px - 1279px)
   ========================================================================== */
@media screen and (min-width: 1024px) and (max-width: 1279px) {
    body {
        font-size: 15px;
    }

    /* Container */
    .container-fluid {
        max-width: 1024px;
        padding-left: 25px;
        padding-right: 25px;
    }

    /* Layout - Standard Bootstrap behavior */
    .col-md-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    .col-md-5 {
        flex: 0 0 41.666667%;
        max-width: 41.666667%;
    }

    .col-md-7 {
        flex: 0 0 58.333333%;
        max-width: 58.333333%;
    }

    /* Panel rows */
    .panel.p-3.row .col-md-7,
    .panel.p-3.row .col-md-5 {
        padding: 5px 12px;
    }

    /* Buttons */
    .btn {
        min-width: 160px !important;
        height: 44px;
    }

    /* Fixed heights */
    .row-flex {
        height: 480px !important;
    }

    .row-flex-nodesrc {
        height: 380px !important;
    }

    /* Tables */
    th, td {
        padding: 10px;
        font-size: 14px;
    }
}

/* ==========================================================================
   DESKTOP LARGE (1280px - 1919px)
   ========================================================================== */
@media screen and (min-width: 1280px) and (max-width: 1919px) {
    /* Container */
    .container-fluid {
        max-width: 1258px;
    }

    /* Fixed heights - as designed */
    .row-flex {
        height: 510px !important;
    }

    .row-flex-nodesrc {
        height: 400px !important;
    }

    /* Buttons */
    .btn {
        min-width: 173px !important;
    }
}

/* ==========================================================================
   DESKTOP EXTRA LARGE (1920px+)
   ========================================================================== */
@media screen and (min-width: 1920px) {
    /* Container - can be wider on very large screens */
    .container-fluid {
        max-width: 1440px;
    }

    body {
        font-size: 16px;
    }

    /* Typography */
    h1, .articleHeading h1 {
        font-size: 34px;
    }

    /* Form elements */
    .form-control {
        height: 44px;
    }

    /* Tables */
    th, td {
        padding: 12px;
        font-size: 15px;
    }
}

/* ==========================================================================
   TOUCH DEVICE OPTIMIZATIONS
   ========================================================================== */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .btn,
    button,
    a.btn {
        min-height: 44px;
    }

    .form-control,
    select {
        min-height: 44px;
    }

    /* Disable hover effects that don't work on touch */
    .category-heading.accordion:hover {
        background-color: #ffffff;
        color: #333;
        border-color: #c9c9c9;
    }

    .category-heading.accordion:hover:after {
        color: #777;
    }

    /* Active states for touch */
    .category-heading.accordion:active {
        background-color: #ab1515;
        color: #fff;
        border-color: #ab1515;
    }

    .category-heading.accordion:active:after {
        color: #fff;
    }

    .btn:active {
        transform: scale(0.98);
    }

    /* Info popovers - larger touch area */
    .info-popover {
        padding: 5px;
    }
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */
@media print {
    body {
        font-size: 12pt;
        background: white;
        color: black;
    }

    .btn,
    .side-menu-toggle,
    .navbar,
    .share,
    .info-popover {
        display: none !important;
    }

    .container-fluid {
        max-width: 100%;
        padding: 0;
    }

    .col-md-6,
    .col-md-5,
    .col-md-7 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    .accordion,
    .collapse {
        display: block !important;
        height: auto !important;
        max-height: none !important;
    }

    table {
        page-break-inside: avoid;
    }
}

/* ==========================================================================
   LANDSCAPE ORIENTATION SPECIFIC
   ========================================================================== */
@media screen and (max-height: 500px) and (orientation: landscape) {
    /* Reduce vertical spacing for landscape mobile */
    .panel.p-3.row {
        padding: 8px !important;
        margin-bottom: 8px;
    }

    .category-heading.accordion {
        padding: 10px 40px 10px 12px;
    }

    .panel-body,
    .accordion-body {
        padding: 10px;
    }

    /* Modal adjustments */
    .modal-body {
        max-height: 60vh;
        overflow-y: auto;
    }
}

/* ==========================================================================
   SAFE AREA INSETS (iPhone X+ notch support)
   ========================================================================== */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }

    .container-fluid {
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
    }
}

/* ==========================================================================
   HIGH CONTRAST / ACCESSIBILITY
   ========================================================================== */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor;
    }

    .form-control {
        border: 2px solid #333;
    }

    .category-heading.accordion {
        border: 2px solid #333;
    }
}

/* ==========================================================================
   REDUCED MOTION
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .accordion_panel,
    .collapse {
        transition: none !important;
    }
}
