/**
 * MigroStack Mobile Migration Pages CSS
 * Responsive styles for all migration tool pages
 * Optimized for mobile, tablet, and desktop screens
 */

/* ==================== BASE MIGRATION PAGE STYLES ==================== */

.migration-page-header {
    background: var(--bg-elevated);
    border-bottom: 3px solid var(--primary-blue);
    padding: 1.5rem 2rem;
    box-shadow: var(--shadow-md);
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.back-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: 2px solid var(--primary-blue);
    color: var(--primary-blue);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
    white-space: nowrap;
}

.back-button:hover {
    background: var(--primary-blue);
    color: white;
    text-decoration: none;
}

.wizard-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #0066FF 0%, #7C3AED 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 102, 255, 0.3);
    white-space: nowrap;
}

.wizard-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 102, 255, 0.4);
}

.header-title {
    text-align: center;
    flex: 1;
    padding: 0 2rem;
}

/* Migration form styles */
.migration-form-container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
}

.migration-form {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
}

.form-section {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

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

.form-section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Migration status cards */
.migration-status-card {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.migration-progress {
    margin-top: 1rem;
}

.progress-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-blue), var(--primary-blue-light));
    transition: width 0.3s ease;
}

/* Migration actions */
.migration-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
}

/* ==================== MOBILE RESPONSIVE (0-767px) ==================== */
@media (max-width: 767px) {
    /* Header adjustments */
    .migration-page-header {
        padding: 1rem;
    }

    .header-container {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .back-button {
        order: 1;
        width: 100%;
        justify-content: center;
        padding: 0.875rem 1rem;
        font-size: 1rem;
    }

    .wizard-button {
        order: 3;
        width: 100%;
        justify-content: center;
        padding: 0.875rem 1rem;
        font-size: 1rem;
    }

    .header-title {
        order: 2;
        padding: 0;
        text-align: center;
    }

    .header-title h1 {
        font-size: 1.5rem !important;
        flex-direction: column;
        gap: 0.5rem;
    }

    .header-title h1 span:first-child {
        font-size: 2.5rem !important;
    }

    .header-title p {
        font-size: 0.875rem !important;
    }

    /* User info - stack vertically on mobile */
    #user-info-container {
        order: 4;
        flex-direction: column;
        width: 100%;
        gap: 0.5rem !important;
    }

    #user-info-container > div {
        text-align: center !important;
        width: 100%;
    }

    #user-info-container button {
        width: 100%;
        padding: 0.875rem 1rem !important;
    }

    /* Theme toggle - full width */
    .theme-toggle-btn {
        width: 100%;
    }

    /* Form container */
    .migration-form-container {
        margin: 1rem auto;
        padding: 0 1rem;
    }

    .migration-form {
        padding: 1rem;
    }

    .form-section {
        margin-bottom: 1.5rem;
        padding-bottom: 1.5rem;
    }

    .form-section-title {
        font-size: 1.125rem;
    }

    /* Form inputs - full width */
    .form-group {
        margin-bottom: 1rem;
    }

    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="url"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px !important; /* Prevent iOS zoom */
        padding: 0.875rem 0.75rem;
        width: 100%;
    }

    /* Buttons - full width on mobile */
    button:not(.back-button):not(.wizard-button):not(.theme-toggle) {
        width: 100%;
        padding: 0.875rem 1rem;
        font-size: 1rem;
        min-height: 44px;
    }

    .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    /* Migration actions - stack */
    .migration-actions {
        flex-direction: column-reverse;
        gap: 0.75rem;
    }

    .migration-actions button {
        width: 100%;
    }

    /* Status cards */
    .migration-status-card {
        padding: 1rem;
    }

    /* Tables - horizontal scroll */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -1rem;
        padding: 0 1rem;
    }

    table {
        min-width: 600px;
        font-size: 0.875rem;
    }

    th, td {
        padding: 0.75rem 0.5rem;
        white-space: nowrap;
    }

    /* Cards grid - single column */
    .cards-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }

    /* Hide desktop-only elements */
    .desktop-only {
        display: none !important;
    }

    /* Show mobile-only elements */
    .mobile-only {
        display: block !important;
    }

    /* Wizard steps - vertical on mobile */
    .wizard-steps {
        flex-direction: column;
        gap: 0.5rem;
    }

    .wizard-step {
        width: 100%;
    }

    /* File upload area */
    .file-upload-area {
        padding: 2rem 1rem;
        min-height: 150px;
    }

    /* Connection status indicators */
    .connection-status {
        flex-direction: column;
        gap: 0.75rem;
    }

    /* Source/Destination panels */
    .source-destination-panels {
        grid-template-columns: 1fr !important;
    }

    /* Mapping table */
    .mapping-table {
        overflow-x: auto;
    }

    /* Progress indicators */
    .progress-stats {
        grid-template-columns: 1fr !important;
        gap: 0.75rem;
    }

    /* Modal content */
    .modal-content {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }

    /* Alert messages */
    .alert {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
        margin: 0 -1rem 1rem -1rem;
        border-radius: 0;
    }

    /* Tabs - scrollable */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -1rem;
        padding: 0 1rem;
    }

    .tab-list {
        display: flex;
        gap: 0.5rem;
        white-space: nowrap;
        min-width: min-content;
    }

    .tab {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
        min-width: 100px;
    }
}

/* ==================== TABLET RESPONSIVE (768px - 1023px) ==================== */
@media (min-width: 768px) and (max-width: 1023px) {
    /* Header */
    .migration-page-header {
        padding: 1.25rem 1.5rem;
    }

    .header-container {
        gap: 1.5rem;
    }

    .header-title {
        padding: 0 1rem;
    }

    .header-title h1 {
        font-size: 1.5rem !important;
    }

    /* Form */
    .migration-form-container {
        padding: 0 1.5rem;
    }

    .migration-form {
        padding: 1.5rem;
    }

    /* Buttons - normal width */
    .btn {
        width: auto;
    }

    /* Cards grid - 2 columns */
    .cards-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Source/Destination panels - 2 columns */
    .source-destination-panels {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Progress stats - 2 columns */
    .progress-stats {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Modal */
    .modal-content {
        max-width: 90%;
        border-radius: var(--radius-lg);
    }

    /* Tables - smaller font */
    table {
        font-size: 0.875rem;
    }
}

/* ==================== LANDSCAPE ORIENTATION ==================== */
@media (max-width: 926px) and (orientation: landscape) {
    .migration-page-header {
        padding: 0.75rem 1rem;
    }

    .header-container {
        gap: 0.75rem;
    }

    .header-title h1 {
        font-size: 1.25rem !important;
    }

    .header-title p {
        font-size: 0.875rem !important;
    }

    .migration-form-container {
        margin: 1rem auto;
    }

    .modal-content {
        max-height: 90vh;
        overflow-y: auto;
    }
}

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

    /* Remove hover effects on touch */
    .back-button:hover,
    .wizard-button:hover,
    .migration-status-card:hover {
        transform: none;
    }

    /* Disable tap highlight */
    button,
    .btn,
    a {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        -webkit-user-select: none; /* Safari 3+ */
        user-select: none;
    }

    /* Larger form controls */
    input[type="checkbox"],
    input[type="radio"] {
        width: 20px;
        height: 20px;
    }

    select {
        padding: 0.875rem !important;
    }
}

/* ==================== DESKTOP (1024px+) ==================== */
@media (min-width: 1024px) {
    /* Hide mobile elements */
    .mobile-only {
        display: none !important;
    }

    .desktop-only {
        display: block !important;
    }

    /* Restore desktop layout */
    .header-container {
        flex-direction: row;
    }

    .header-title {
        text-align: center;
    }

    #user-info-container {
        flex-direction: row;
    }

    /* Form buttons normal width */
    .migration-actions button {
        width: auto;
        min-width: 120px;
    }
}

/* ==================== UTILITIES ==================== */

/* Mobile stack utility */
.mobile-stack {
    display: flex;
}

@media (max-width: 767px) {
    .mobile-stack {
        flex-direction: column !important;
    }
}

/* Text truncate on mobile */
@media (max-width: 767px) {
    .mobile-truncate {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 200px;
    }
}

/* Responsive text sizes */
@media (max-width: 767px) {
    .responsive-text-lg {
        font-size: 1rem !important;
    }

    .responsive-text-xl {
        font-size: 1.25rem !important;
    }

    .responsive-text-2xl {
        font-size: 1.5rem !important;
    }
}

/* Wizard specific mobile styles */
@media (max-width: 767px) {
    .wizard-container {
        padding: 1rem;
    }

    .wizard-step-indicator {
        flex-direction: column;
        gap: 0.5rem;
    }

    .wizard-step-number {
        margin-right: 0 !important;
        margin-bottom: 0.25rem;
    }

    .wizard-nav-buttons {
        flex-direction: column-reverse;
        gap: 0.75rem;
    }

    .wizard-nav-buttons button {
        width: 100%;
    }
}

/* Connection test results */
@media (max-width: 767px) {
    .connection-test-results {
        padding: 1rem;
    }

    .connection-test-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

/* Migration history table */
@media (max-width: 767px) {
    .migration-history-table {
        display: block;
        overflow-x: auto;
    }

    .migration-history-row {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.5rem;
        padding: 1rem;
        border-bottom: 1px solid var(--border-color);
    }

    .migration-history-row > * {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .migration-history-row > *::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-secondary);
    }
}

/* Settings panels */
@media (max-width: 767px) {
    .settings-panel {
        padding: 1rem;
    }

    .settings-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .settings-row label {
        width: 100%;
    }

    .settings-row input,
    .settings-row select {
        width: 100%;
    }
}

/* Error/Success messages */
.message-banner {
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

@media (max-width: 767px) {
    .message-banner {
        flex-direction: column;
        text-align: center;
        padding: 0.875rem 1rem;
    }
}

/* Loading states */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    gap: 1rem;
}

@media (max-width: 767px) {
    .loading-container {
        padding: 2rem 1rem;
    }

    .loading-spinner {
        width: 40px;
        height: 40px;
    }
}

/* ==================== CONFIGURATION PROFILES MOBILE STYLES ==================== */

/* Base styles for config profiles section */
.config-profiles-section {
    background: var(--bg-elevated);
    border: 2px solid var(--primary-blue);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 16px;
}

/* Mobile responsive styles for configuration profiles (0-767px) */
@media (max-width: 767px) {
    .config-profiles-section {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    /* Make the header stack on mobile */
    .config-profiles-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.5rem !important;
    }

    /* Hide subtitle on very small screens */
    .config-profiles-subtitle {
        display: none;
    }

    /* Single column layout for mobile - VERTICAL EXPANSION */
    .config-profiles-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 1.5rem !important;
        grid-template-columns: 1fr !important;
    }

    /* Sections expand vertically with clear separation */
    .config-profiles-load-section,
    .config-profiles-save-section {
        display: flex !important;
        flex-direction: column !important;
        gap: 1rem !important;
        width: 100% !important;
        background: var(--bg-card);
        padding: 1rem;
        border-radius: 8px;
        border: 1px solid var(--border-color);
    }

    /* Load Profile section */
    .config-profiles-load-section label,
    .config-profiles-save-section label {
        font-size: 0.95rem !important;
        margin-bottom: 0.5rem !important;
        display: block !important;
    }

    /* Button containers - stack buttons horizontally on mobile (side by side) */
    .config-profiles-button-group {
        display: flex !important;
        flex-direction: row !important;
        gap: 0.5rem !important;
        width: 100% !important;
    }

    /* Dropdown select - full width */
    .config-profiles-section select {
        width: 100% !important;
        flex: none !important;
        padding: 0.875rem !important;
        font-size: 16px !important; /* Prevent iOS zoom */
        min-height: 48px !important;
        border-radius: 8px !important;
    }

    /* Input field - full width */
    .config-profiles-section input[type="text"] {
        width: 100% !important;
        flex: none !important;
        padding: 0.875rem !important;
        font-size: 16px !important; /* Prevent iOS zoom */
        min-height: 48px !important;
        border-radius: 8px !important;
    }

    /* Checkbox input */
    .config-profiles-section input[type="checkbox"] {
        width: 20px !important;
        height: 20px !important;
        min-height: auto !important;
    }

    /* All buttons - touch-friendly but allow flexible width for side-by-side layout */
    .config-profiles-btn {
        padding: 0.75rem 1rem !important;
        font-size: 0.9rem !important;
        min-height: 44px !important;
        border-radius: 8px !important;
        white-space: nowrap !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 0.35rem !important;
        margin-bottom: 0 !important;
        flex-shrink: 0 !important;
    }

    /* Load button should grow, delete button stays compact */
    .config-profiles-button-group > .btn-primary {
        flex: 1 !important;
    }

    .config-profiles-button-group > .btn-danger {
        flex: 0 0 auto !important;
        min-width: 44px !important;
    }

    /* Checkbox label - better touch target */
    .config-profiles-checkbox-label {
        padding: 0.75rem !important;
        font-size: 0.9rem !important;
        display: flex !important;
        align-items: center !important;
        gap: 0.75rem !important;
        margin-top: 0.5rem !important;
    }

    /* Status message container */
    .config-profiles-section #configProfileStatus > div {
        padding: 1rem !important;
        font-size: 0.85rem !important;
        flex-direction: column !important;
        text-align: center !important;
        gap: 0.5rem !important;
    }

    .config-profiles-section #configProfileStatus span:first-child {
        font-size: 1.5rem !important;
    }
}

/* Tablet styles (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
    .config-profiles-section {
        padding: 1.25rem;
    }

    /* Show subtitle on tablet */
    .config-profiles-subtitle {
        display: inline;
    }

    /* Keep 2-column grid on tablet */
    .config-profiles-grid {
        gap: 1rem !important;
    }

    /* Slightly larger touch targets */
    .config-profiles-btn {
        min-height: 44px !important;
        padding: 0.75rem 1rem !important;
    }

    .config-profiles-section select,
    .config-profiles-section input[type="text"] {
        min-height: 44px !important;
        font-size: 16px !important; /* Prevent iOS zoom on iPad */
    }
}

/* Desktop styles (1024px+) - ensure normal behavior */
@media (min-width: 1024px) {
    .config-profiles-section {
        padding: 14px;
    }

    /* Show subtitle on desktop */
    .config-profiles-subtitle {
        display: inline;
    }

    /* Ensure grid stays as 2 columns */
    .config-profiles-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 14px !important;
    }
}

/* Touch device optimizations for config profiles */
@media (hover: none) and (pointer: coarse) {
    .config-profiles-btn {
        min-height: 48px !important;
        min-width: 48px !important;
    }

    .config-profiles-section select,
    .config-profiles-section input[type="text"] {
        min-height: 48px !important;
        padding: 0.875rem !important;
    }

    .config-profiles-section input[type="checkbox"] {
        min-width: 20px !important;
        min-height: 20px !important;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 767px) and (orientation: landscape) {
    .config-profiles-section {
        padding: 0.875rem;
    }

    .config-profiles-section button {
        padding: 0.875rem 1rem !important;
        min-height: 44px !important;
    }
}

/* Very small screens (iPhone SE, etc.) */
@media (max-width: 375px) {
    .config-profiles-section {
        padding: 0.75rem;
    }

    .config-profiles-section h3 {
        font-size: 1rem !important;
    }

    .config-profiles-section label {
        font-size: 0.85rem !important;
    }

    .config-profiles-section button {
        padding: 0.875rem 1rem !important;
        font-size: 0.9rem !important;
    }
}

/* ==================== CUSTOM INLINE CONFIG PROFILES (Mailbox, Azure VM pages) ==================== */

/* Mobile styles for pages using Tailwind grid-cols-2 for config profiles */
@media (max-width: 767px) {
    /* Make 2-column grid single column on mobile - VERTICAL EXPANSION */
    .step-container .grid-cols-2,
    .step-body .grid-cols-2 {
        grid-template-columns: 1fr !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 1.5rem !important;
    }

    /* Each child section within the grid - add visual separation */
    .step-body .grid-cols-2 > div,
    .step-body .grid > div {
        display: flex !important;
        flex-direction: column !important;
        gap: 1rem !important;
        width: 100% !important;
    }

    /* Buttons in config profile sections - each on own row */
    .step-body .btn {
        width: 100% !important;
        padding: 1rem !important;
        font-size: 1rem !important;
        min-height: 48px !important;
        margin-bottom: 0 !important; /* Remove default margin */
        display: block !important;
    }

    /* Button groups in config profiles - stack vertically with clear spacing */
    .step-body .flex.gap-1 {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.75rem !important;
        width: 100% !important;
    }

    /* Ensure each button in the group is on its own row */
    .step-body .flex.gap-1 > .btn {
        width: 100% !important;
        display: block !important;
    }

    /* Dropdowns and inputs - full width, clear vertical spacing */
    .step-body select,
    .step-body input[type="text"] {
        width: 100% !important;
        flex: none !important;
        padding: 0.875rem !important;
        font-size: 16px !important; /* Prevent iOS zoom */
        min-height: 48px !important;
        display: block !important;
        margin-bottom: 0.75rem;
    }

    /* Last input in a group - no bottom margin */
    .step-body .flex.gap-1 > select:last-child,
    .step-body .flex.gap-1 > input[type="text"]:last-child {
        margin-bottom: 0;
    }

    /* Step containers */
    .step-container {
        margin-bottom: 1rem;
        border-radius: 8px;
    }

    .step-header {
        padding: 1rem !important;
        cursor: pointer;
    }

    .step-body {
        padding: 1rem !important;
    }

    /* Config profile cards */
    .step-body > .grid > div {
        padding: 1rem !important;
        margin-bottom: 1rem;
    }

    /* Status messages */
    #profileStatus .success-box,
    #profileStatus .error-box,
    #configStatus .success-box,
    #configStatus .error-box {
        padding: 1rem !important;
        font-size: 0.9rem !important;
        margin-top: 1rem;
        border-radius: 8px;
    }
}

/* Tablet styles for inline config profiles */
@media (min-width: 768px) and (max-width: 1023px) {
    .step-body .btn {
        min-height: 44px !important;
        padding: 0.75rem 1rem !important;
    }

    .step-body select,
    .step-body input[type="text"] {
        min-height: 44px !important;
        font-size: 16px !important; /* Prevent iOS zoom on iPad */
    }
}
