/* Mobile-First Form Responsive Styles */

/* Base mobile styles for smartphones (320px - 767px) */
@media (max-width: 767px) {
    /* Form Body and Container - Maintain original light theme */
    .form-body {
        background: linear-gradient(135deg, #f5f7fa 0%, #f0f4f8 100%) !important;
        padding-top: 0;
        overflow-x: hidden;
        min-height: 100vh;
    }

    .form-main {
        padding: 0.75rem 0.5rem 5rem 0.5rem;
        min-height: calc(100vh - 120px);
    }

    .form-container {
        max-width: 100%;
        padding: 0 0.75rem;
    }

    /* Navigation Bar Mobile Optimization */
    .form-navbar {
        background: white;
        padding: 0.75rem 0;
        position: sticky;
        top: 0;
        width: 100%;
        z-index: 1000;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    }

    .form-nav-container {
        padding: 0 1rem;
        gap: 0.5rem;
    }

    .form-nav-logo {
        font-size: 1rem;
        gap: 0.5rem;
        color: #111827;
    }

    .form-nav-logo svg {
        width: 24px;
        height: 24px;
    }

    .form-nav-logo span {
        display: none;
    }

    .form-nav-actions {
        gap: 0.5rem;
    }

    .btn-exit {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
        color: #6b7280;
        background: white;
        border: 1px solid #e5e7eb;
    }

    .btn-login {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
        background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
        color: white;
    }

    .btn-login svg {
        width: 16px;
        height: 16px;
    }

    #authButtonText {
        display: inline;
    }

    /* Progress Bar Mobile */
    .progress-container {
        padding: 0.75rem 0;
        background: white;
        border-bottom: 1px solid #e5e7eb;
        position: sticky;
        top: 56px;
        z-index: 99;
    }

    .progress-bar {
        margin: 0 1rem 0.5rem;
        height: 6px;
        background: #e5e7eb;
    }

    .progress-fill {
        background: linear-gradient(90deg, #1e3a8a 0%, #2563eb 100%);
    }

    .progress-text {
        padding: 0 1rem;
        font-size: 0.75rem;
        color: #6b7280;
    }

    /* Step Header Mobile - Compact Design */
    .step-header {
        flex-direction: row;
        align-items: center;
        gap: 0.75rem;
        margin-bottom: 1rem;
        padding: 0 0.5rem;
    }

    .step-number {
        width: 36px;
        height: 36px;
        background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
        flex-shrink: 0;
    }

    .step-number span {
        font-size: 1rem;
        color: white;
    }

    .step-info {
        flex: 1;
    }

    .step-info h2 {
        font-size: 1.25rem;
        line-height: 1.3;
        margin-bottom: 0.25rem;
        color: #111827;
    }

    .step-info p {
        font-size: 0.875rem;
        line-height: 1.4;
        color: #6b7280;
    }

    /* Options Container Mobile - Optimized for visibility */
    .options-container {
        display: flex !important;
        flex-direction: column;
        gap: 0.625rem;
        margin-bottom: 1rem;
        padding: 0;
    }

    .options-container.two-column {
        display: flex !important;
        flex-direction: column;
        gap: 0.625rem;
    }

    /* Option Cards Mobile - Ultra compact for no-scroll experience */
    .option-card {
        background: white;
        border: 2px solid #e5e7eb;
        padding: 0.875rem;
        border-radius: 0.625rem;
        min-height: auto;
        height: auto;
        display: flex;
        align-items: center;
        gap: 0.75rem;
        position: relative;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .option-card.large {
        padding: 0.875rem;
    }

    .option-card:active {
        transform: scale(0.98);
    }

    .option-card.selected {
        border-color: #1e3a8a;
        background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
        box-shadow: 0 2px 8px rgba(30, 58, 138, 0.15);
    }

    .option-icon {
        margin-bottom: 0;
        flex-shrink: 0;
    }

    .option-icon svg {
        width: 36px;
        height: 36px;
    }

    .option-card h3 {
        font-size: 0.9375rem;
        margin: 0;
        color: #111827;
        font-weight: 600;
        line-height: 1.2;
    }

    .option-card p {
        font-size: 0.6875rem;
        line-height: 1.2;
        color: #6b7280;
        margin: 0;
        opacity: 0.9;
    }

    /* Rearrange option card content for horizontal layout */
    .option-card {
        flex-direction: row;
        text-align: left;
    }

    /* Create wrapper for text content */
    .option-content,
    .option-card > div:not(.option-icon):not(.option-check) {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 0.125rem;
    }

    .option-check {
        position: absolute;
        top: 50%;
        right: 1rem;
        transform: translateY(-50%);
        opacity: 0;
    }

    .option-card.selected .option-check {
        opacity: 1;
    }

    .option-check svg {
        width: 20px;
        height: 20px;
    }

    /* Form Actions Mobile - Fixed at bottom */
    .form-actions {
        display: flex;
        flex-direction: row;
        gap: 0.75rem;
        padding: 1rem;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid #e5e7eb;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
        z-index: 100;
    }

    .form-actions button,
    .btn-primary,
    .btn-secondary {
        flex: 1;
        padding: 0.75rem;
        font-size: 0.875rem;
        border-radius: 0.5rem;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
    }

    .btn-secondary {
        background: white;
        color: #6b7280;
        border: 1px solid #e5e7eb;
    }

    .btn-primary {
        background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
        color: white;
        border: none;
    }

    /* Hide disabled back button on first step */
    #step1 .btn-secondary:disabled {
        display: none;
    }

    /* Make primary button full width when alone */
    #step1 .btn-primary {
        flex: 1;
        width: 100%;
    }

    /* Input Fields Mobile */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    input[type="date"],
    select,
    textarea {
        width: 100% !important;
        padding: 0.875rem !important;
        font-size: 16px !important; /* Prevents zoom on iOS */
        border: 1px solid #e5e7eb !important;
        border-radius: 0.5rem !important;
        -webkit-appearance: none;
        appearance: none;
    }

    select {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23374151' d='M6 8L2 4h8z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 0.875rem center;
        padding-right: 2.5rem !important;
    }

    label {
        display: block;
        margin-bottom: 0.375rem;
        color: #374151;
        font-size: 0.875rem;
        font-weight: 500;
    }

    /* Form Grid Layouts Mobile */
    div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    /* Two-column date inputs */
    #customTaxYearInputs > div {
        grid-template-columns: 1fr !important;
        gap: 0.75rem;
    }

    /* Help Button Mobile - Hide or reposition to avoid interference */
    .help-button {
        bottom: 4.5rem;
        right: 1rem;
        width: 44px;
        height: 44px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
        background: white;
        border: 2px solid #e5e7eb;
        color: #6b7280;
        opacity: 0.95;
    }

    .help-button:hover {
        background: #1e3a8a;
        border-color: #1e3a8a;
        color: white;
    }

    .help-button svg {
        width: 20px;
        height: 20px;
    }

    /* Info Tooltips Mobile */
    .info-icon-container {
        position: relative;
    }

    .info-tooltip {
        width: 250px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        font-size: 0.8125rem !important;
        padding: 0.625rem !important;
        max-width: calc(100vw - 2rem);
    }

    /* Part 1 Steps Mobile */
    .part1-step {
        padding: 0 0.5rem;
    }

    .part1-step h3 {
        font-size: 1.125rem;
        line-height: 1.3;
        margin-bottom: 0.75rem;
    }

    .part1-step p {
        font-size: 0.875rem;
        line-height: 1.4;
        margin-bottom: 0.75rem;
    }

    /* Coming Soon Section Mobile */
    .coming-soon {
        padding: 2rem 1rem;
        margin: 0 0.5rem;
        border-radius: 0.75rem;
    }

    .coming-soon h3 {
        font-size: 1.25rem;
    }

    .coming-soon p {
        font-size: 0.875rem;
    }

    /* Loading Animation Mobile */
    .loading {
        width: 16px;
        height: 16px;
        border-width: 2px;
    }

    /* Modals Mobile */
    .modal,
    [class*="modal"] {
        padding: 1rem !important;
    }

    .modal-content,
    [class*="modal-content"] {
        width: 95% !important;
        max-width: 100% !important;
        margin: 1rem auto !important;
        padding: 1.5rem !important;
        border-radius: 0.75rem !important;
    }

    /* Notification Mobile */
    div[style*="position: fixed"][style*="top: 20px"] {
        top: 70px !important;
        right: 10px !important;
        left: 10px !important;
        padding: 0.875rem 1rem !important;
        font-size: 0.875rem !important;
    }

    /* Smooth Scrolling */
    .form-step {
        scroll-margin-top: 140px;
    }

    /* Touch Optimization */
    button,
    .option-card,
    input,
    select,
    textarea,
    a {
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    /* Prevent horizontal scroll */
    * {
        max-width: 100vw;
        overflow-x: hidden;
    }

    /* Responsive Text */
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.125rem; }
    p { font-size: 0.875rem; }
}

/* Ensure no-scroll experience on all mobile sizes */
@media (max-width: 767px) and (max-height: 750px) {
    /* Extra compact for smaller screens */
    .step-header {
        margin-bottom: 0.75rem;
    }

    .step-number {
        width: 32px;
        height: 32px;
    }

    .step-info h2 {
        font-size: 1.125rem;
    }

    .step-info p {
        font-size: 0.8125rem;
    }

    .option-card {
        padding: 0.75rem;
    }

    .options-container {
        gap: 0.5rem;
    }

    .option-icon svg {
        width: 30px;
        height: 30px;
    }
}

/* Small tablets and large phones (576px - 767px) */
@media (min-width: 576px) and (max-width: 767px) {
    .form-container {
        padding: 0 1rem;
    }

    .option-card {
        padding: 1rem;
    }

    .form-actions button {
        width: auto;
        flex: 1;
    }

    /* Two-column layout for some options on larger phones */
    .options-container.two-column {
        grid-template-columns: 1fr 1fr !important;
        gap: 1rem;
    }
}

/* iPad and tablets (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    .form-container {
        max-width: 720px;
        padding: 0 1.5rem;
    }

    .options-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }

    .option-card {
        padding: 2rem 1.5rem;
    }

    .step-info h2 {
        font-size: 1.75rem;
    }

    /* Keep form inputs readable on tablets */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    input[type="date"],
    select,
    textarea {
        font-size: 16px !important;
        padding: 0.75rem !important;
    }
}

/* Landscape mode optimizations */
@media (max-height: 500px) and (orientation: landscape) {
    .form-navbar {
        padding: 0.5rem 0;
    }

    .progress-container {
        padding: 0.5rem 0;
        margin-top: 50px;
    }

    .step-header {
        margin-bottom: 1rem;
    }

    .form-actions {
        padding: 1rem 0.5rem;
    }

    .help-button {
        display: none;
    }
}

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

    .option-card.selected {
        border-color: #1e3a8a;
        outline: 2px solid #1e3a8a;
        outline-offset: 2px;
    }

    input:focus,
    select:focus,
    textarea:focus {
        outline: 3px solid #1e3a8a;
        outline-offset: 2px;
    }
}

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

/* Remove dark mode for consistent light theme */

/* Accessibility improvements for mobile */
@media (max-width: 767px) {
    /* Increase tap target sizes */
    button,
    .option-card,
    a {
        min-height: 44px;
        min-width: 44px;
    }

    /* Focus visible styles */
    *:focus-visible {
        outline: 3px solid #3b82f6;
        outline-offset: 2px;
    }

    /* Skip link for keyboard navigation */
    .skip-link {
        position: absolute;
        top: -40px;
        left: 0;
        background: #1e3a8a;
        color: white;
        padding: 0.5rem 1rem;
        text-decoration: none;
        z-index: 100;
    }

    .skip-link:focus {
        top: 0;
    }
}

/* Print styles for mobile */
@media print and (max-width: 767px) {
    .form-navbar,
    .progress-container,
    .help-button,
    .form-actions {
        display: none !important;
    }

    .form-body {
        background: white !important;
    }

    .form-step {
        page-break-inside: avoid;
    }
}