/* ========================================
   RESPONSIVE UI/UX IMPROVEMENTS
   ======================================== */

/* ========================================
   MOBILE OPTIMIZATIONS (<768px)
   ======================================== */
@media (max-width: 767px) {
    /* Touch Target Optimization */
    .btn {
        min-height: 48px;
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }

    .form-control,
    .form-select {
        min-height: 48px;
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }

    .input-group-text {
        min-height: 48px;
        padding: 0.75rem;
    }

    /* Spacing between interactive elements */
    .form-control + .form-control,
    .btn + .btn {
        margin-top: 8px;
    }

    .mb-3 {
        margin-bottom: 1.25rem !important;
    }

    /* Main content padding */
    main .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* Card padding adjustments */
    .card-body {
        padding: 1.25rem;
    }

    /* Disable hover effects on mobile (touch devices) */
    .card.hover-lift:hover {
        transform: none;
        box-shadow: var(--shadow-sm) !important;
    }

    /* Homepage cards - single column */
    .home-calculator-cards .col-sm-6 {
        margin-bottom: 1rem;
    }

    /* Typography adjustments */
    .display-4 {
        font-size: 2rem;
    }

    .display-6 {
        font-size: 1.75rem;
    }

    .lead {
        font-size: 1.1rem;
    }

    /* Form label adjustments */
    .form-label {
        margin-bottom: 0.5rem;
        font-size: 0.95rem;
    }

    /* Summary cards - stack vertically */
    .summary-card .col-sm-4 {
        border-right: none !important;
        border-bottom: 1px solid var(--gray-300);
        padding-bottom: 1rem;
        margin-bottom: 1rem;
    }

    .summary-card .col-sm-4:last-child {
        border-bottom: none;
        padding-bottom: 0;
        margin-bottom: 0;
    }

    /* Table improvements */
    .table-responsive {
        font-size: 0.85rem;
    }

    .table th,
    .table td {
        padding: 0.5rem 0.25rem;
    }
}

/* ========================================
   TABLET OPTIMIZATIONS (768px - 1024px)
   ======================================== */
@media (min-width: 768px) and (max-width: 1024px) {
    /* Homepage calculator cards - 2 column grid */
    .home-calculator-cards .row {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }

    .home-calculator-cards .col-sm-6,
    .home-calculator-cards .col-md-4,
    .home-calculator-cards .col-xl-3 {
        grid-column: span 1;
    }

    /* Form layouts - 2 columns for related fields */
    .form-row-tablet {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    /* Optimize spacing */
    main .container {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }

    /* Summary cards optimization */
    .summary-card .col-sm-4 {
        padding: 1rem;
    }
}

/* ========================================
   DESKTOP OPTIMIZATIONS (≥992px)
   ======================================== */
@media (min-width: 992px) {
    /* Enable hover effects on desktop */
    .card.hover-lift {
        transition: transform 0.3s ease, box-shadow 0.3s ease;
    }

    .card.hover-lift:hover {
        transform: translateY(-10px);
        box-shadow: var(--shadow-lg) !important;
    }

    /* Homepage cards hover animation */
    .home-calculator-card {
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .home-calculator-card:hover {
        transform: translateY(-8px);
    }
}

/* ========================================
   FLOATING LABELS
   ======================================== */
.form-floating {
    position: relative;
}

.form-floating > .form-control,
.form-floating > .form-select {
    height: calc(3.5rem + 2px);
    line-height: 1.25;
    padding: 1rem 0.75rem;
}

.form-floating > label {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    padding: 1rem 0.75rem;
    pointer-events: none;
    border: 1px solid transparent;
    transform-origin: 0 0;
    transition: opacity 0.1s ease-in-out, transform 0.1s ease-in-out;
    color: var(--secondary);
}

.form-floating > .form-control:focus ~ label,
.form-floating > .form-control:not(:placeholder-shown) ~ label,
.form-floating > .form-select ~ label {
    opacity: 0.65;
    transform: scale(0.85) translateY(-0.5rem) translateX(0.15rem);
}

/* ========================================
   INPUT IMPROVEMENTS
   ======================================== */
/* Currency symbol prefix */
.input-group-currency .input-group-text {
    background-color: var(--gray-200);
    border-right: 0;
    font-weight: 600;
    color: var(--secondary);
}

.input-group-currency .form-control {
    border-left: 0;
}

/* Placeholder styling */
.form-control::placeholder {
    color: var(--gray-400);
    opacity: 0.7;
    font-style: italic;
}

.form-control:focus::placeholder {
    opacity: 0.5;
}

/* ========================================
   LOADING SPINNER
   ======================================== */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading::after {
    content: '';
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1rem;
    height: 1rem;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spinner 0.6s linear infinite;
}

@keyframes spinner {
    to {
        transform: translateY(-50%) rotate(360deg);
    }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */
/* Focus indicators */
*:focus-visible {
    outline: 2px solid var(--green-500);
    outline-offset: 2px;
}

.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible {
    outline: none;
    border-color: var(--green-500);
    box-shadow: 0 0 0 0.25rem rgba(16, 185, 129, 0.25);
}

/* Skip to main content link for screen readers */
.skip-to-main {
    position: absolute;
    left: -9999px;
    z-index: 999;
}

.skip-to-main:focus {
    left: 50%;
    transform: translateX(-50%);
    top: 1rem;
    background: var(--green-500);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.25rem;
    text-decoration: none;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn {
        border-width: 2px;
    }

    .form-control,
    .form-select {
        border-width: 2px;
    }
}

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

    .card.hover-lift:hover {
        transform: none;
    }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */
/* Visual separators */
.section-divider {
    height: 1px;
    background-color: var(--gray-300);
    margin: 2rem 0;
}

/* ========================================
   FORM SECTION STYLING
   ======================================== */
.form-section {
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--gray-200);
}

.form-section:last-child {
    border-bottom: none;
}

.form-section h6 {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--green-500);
    display: inline-block;
}

/* ========================================
   CHART CONTAINER RESPONSIVE
   ======================================== */
@media (max-width: 767px) {
    [id*="Chart"],
    [id*="chart"] {
        height: 300px !important;
    }

    /* Rental summary mini charts - smaller on mobile */
    .rental-mini-chart {
        height: 80px !important;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
    .navbar,
    .footer,
    .cookie-banner,
    .alpha-banner,
    .btn {
        display: none !important;
    }

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

    main .container {
        max-width: 100%;
    }
}
