/* Academic Job Hunter - Mobile-First Styles */
/* Version: 4.6.0 - iPhone 16 Pro Optimized (402 x 874 viewport) */

/* ========================================
   BASE MOBILE STYLES (320px+)
======================================== */

/* Prevent iOS text size adjustment */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Touch-friendly base */
body {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Prevent iOS zoom on form focus */
input, select, textarea {
    font-size: 16px !important;
}

/* ========================================
   BOTTOM NAVIGATION
======================================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: var(--bottom-nav-bg);
    border-top: 1px solid var(--bottom-nav-border);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding-bottom: var(--safe-area-bottom);
    z-index: var(--z-bottom-nav);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--bottom-nav-text);
    padding: var(--space-2);
    min-width: 64px;
    min-height: var(--touch-target-min);
    border-radius: var(--radius-md);
    transition: color var(--transition-fast), background var(--transition-fast);
    background: none;
    border: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item:hover,
.bottom-nav-item:focus {
    color: var(--bottom-nav-active);
    background: var(--color-primary-light);
}

.bottom-nav-item.active {
    color: var(--bottom-nav-active);
}

.bottom-nav-item i {
    font-size: var(--bottom-nav-icon-size);
    margin-bottom: var(--space-1);
}

.bottom-nav-item span {
    font-size: var(--bottom-nav-label-size);
    font-weight: 500;
    line-height: 1;
}

/* Active indicator dot */
.bottom-nav-item.active::after {
    content: '';
    position: absolute;
    bottom: calc(var(--safe-area-bottom) + 4px);
    width: 4px;
    height: 4px;
    background: var(--bottom-nav-active);
    border-radius: 50%;
}

/* ========================================
   MORE MENU (Slide-up)
======================================== */
.more-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: calc(var(--z-bottom-nav) + 1);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-base), visibility var(--transition-base);
}

.more-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

.more-menu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-bg-paper);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: var(--space-4);
    padding-bottom: calc(var(--space-4) + var(--safe-area-bottom));
    z-index: calc(var(--z-bottom-nav) + 2);
    transform: translateY(100%);
    transition: transform var(--transition-slow);
    max-height: 70vh;
    overflow-y: auto;
}

.more-menu.active {
    transform: translateY(0);
}

.more-menu-handle {
    width: 40px;
    height: 4px;
    background: var(--color-border);
    border-radius: var(--radius-full);
    margin: 0 auto var(--space-4);
}

.more-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--color-border);
}

.more-menu-header h3 {
    margin: 0;
    font-size: var(--font-size-lg);
    font-weight: 600;
}

.more-menu-close {
    background: none;
    border: none;
    padding: var(--space-2);
    color: var(--color-text-muted);
    cursor: pointer;
    min-width: var(--touch-target-min);
    min-height: var(--touch-target-min);
    display: flex;
    align-items: center;
    justify-content: center;
}

.more-menu-items {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-3);
}

.more-menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-4) var(--space-2);
    text-decoration: none;
    color: var(--color-text-primary);
    border-radius: var(--radius-lg);
    transition: background var(--transition-fast);
    min-height: var(--touch-target-comfortable);
}

.more-menu-item:hover,
.more-menu-item:focus {
    background: var(--color-bg-default);
}

.more-menu-item i {
    font-size: 1.5rem;
    margin-bottom: var(--space-2);
    color: var(--color-primary);
}

.more-menu-item span {
    font-size: var(--font-size-sm);
    text-align: center;
}

/* User section in more menu */
.more-menu-user {
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-border);
}

.more-menu-user-info {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.more-menu-user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--color-primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
    font-size: 1.25rem;
}

.more-menu-user-email {
    flex: 1;
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    word-break: break-all;
}

/* ========================================
   MOBILE HEADER
======================================== */
.mobile-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--color-bg-paper);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    padding: 0 var(--space-4);
    padding-top: var(--safe-area-top);
    z-index: var(--z-sticky);
    box-shadow: var(--shadow-sm);
}

.mobile-header-title {
    flex: 1;
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin: 0;
    text-align: center;
}

.mobile-header-action {
    min-width: var(--touch-target-min);
    min-height: var(--touch-target-min);
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--color-text-primary);
    cursor: pointer;
    border-radius: var(--radius-md);
}

.mobile-header-action:hover {
    background: var(--color-bg-default);
}

/* ========================================
   MOBILE CONTENT SPACING
======================================== */
/* Add padding for fixed bottom nav */
.main-content-mobile {
    padding-bottom: calc(var(--bottom-nav-height) + var(--space-4) + var(--safe-area-bottom));
}

/* When mobile header is present */
.has-mobile-header .main-content {
    padding-top: calc(56px + var(--safe-area-top) + var(--space-4));
}

/* ========================================
   TOUCH-FRIENDLY BUTTONS
======================================== */
.btn-mobile {
    min-height: var(--touch-target-comfortable);
    padding: var(--space-3) var(--space-6);
    font-size: var(--font-size-base);
    border-radius: var(--radius-lg);
}

.btn-mobile-sm {
    min-height: var(--touch-target-min);
    padding: var(--space-2) var(--space-4);
    font-size: var(--font-size-sm);
}

.btn-mobile-lg {
    min-height: var(--touch-target-large);
    padding: var(--space-4) var(--space-8);
    font-size: var(--font-size-lg);
}

.btn-mobile-block {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}

/* Icon buttons */
.btn-icon-mobile {
    width: var(--touch-target-comfortable);
    height: var(--touch-target-comfortable);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: none;
    border: none;
    color: var(--color-text-primary);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.btn-icon-mobile:hover,
.btn-icon-mobile:focus {
    background: var(--color-bg-default);
}

/* ========================================
   MOBILE CARDS
======================================== */
.card-mobile {
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-3);
    overflow: hidden;
}

.card-mobile .card-body {
    padding: var(--space-4);
}

/* Job card mobile specific */
.job-card-mobile {
    display: flex;
    flex-direction: column;
}

.job-card-mobile-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.job-card-mobile-badges {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.job-card-mobile-score {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--color-primary);
    min-width: 44px;
    text-align: right;
}

.job-card-mobile-title {
    font-size: var(--font-size-base);
    font-weight: 600;
    margin-bottom: var(--space-1);
    line-height: var(--line-height-tight);
}

.job-card-mobile-employer {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-3);
}

.job-card-mobile-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-4);
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--space-4);
}

.job-card-mobile-meta-item {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.job-card-mobile-actions {
    display: flex;
    gap: var(--space-2);
    padding-top: var(--space-3);
    border-top: 1px solid var(--color-border);
}

.job-card-mobile-actions .btn {
    flex: 1;
    min-height: var(--touch-target-min);
}

/* ========================================
   MOBILE TYPOGRAPHY
======================================== */
@media (max-width: 575.98px) {
    h1 { font-size: var(--font-size-2xl); }
    h2 { font-size: var(--font-size-xl); }
    h3 { font-size: var(--font-size-lg); }
    h4 { font-size: var(--font-size-base); }

    .display-4 {
        font-size: var(--font-size-3xl);
    }

    .lead {
        font-size: var(--font-size-base);
    }
}

/* ========================================
   RESPONSIVE TABLES (Card Layout)
======================================== */
.table-mobile-cards {
    display: none;
}

@media (max-width: 767.98px) {
    .table-responsive-mobile {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 calc(-1 * var(--space-4));
        padding: 0 var(--space-4);
    }

    /* Option: Hide table and show cards */
    .table-hide-mobile {
        display: none !important;
    }

    .table-mobile-cards {
        display: block;
    }

    .table-mobile-card {
        background: var(--color-bg-paper);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-lg);
        padding: var(--space-4);
        margin-bottom: var(--space-3);
    }

    .table-mobile-card-row {
        display: flex;
        justify-content: space-between;
        padding: var(--space-2) 0;
        border-bottom: 1px solid var(--color-border);
    }

    .table-mobile-card-row:last-child {
        border-bottom: none;
    }

    .table-mobile-card-label {
        font-size: var(--font-size-sm);
        color: var(--color-text-muted);
    }

    .table-mobile-card-value {
        font-size: var(--font-size-sm);
        font-weight: 500;
        text-align: right;
    }
}

/* ========================================
   MOBILE FORMS
======================================== */
.form-mobile .form-control,
.form-mobile .form-select {
    min-height: var(--touch-target-comfortable);
    font-size: 16px; /* Prevent iOS zoom */
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg);
}

.form-mobile .form-label {
    font-weight: 600;
    margin-bottom: var(--space-2);
}

.form-mobile .form-group {
    margin-bottom: var(--space-4);
}

/* Search input with icon */
.search-mobile {
    position: relative;
}

.search-mobile .form-control {
    padding-left: calc(var(--space-4) + 24px);
}

.search-mobile .search-icon {
    position: absolute;
    left: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-muted);
    pointer-events: none;
}

/* ========================================
   FILTER BOTTOM SHEET
======================================== */
.filter-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-bg-paper);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: var(--space-4);
    padding-bottom: calc(var(--space-4) + var(--safe-area-bottom));
    z-index: calc(var(--z-modal) + 1);
    transform: translateY(100%);
    transition: transform var(--transition-slow);
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
}

.filter-sheet.active {
    transform: translateY(0);
}

.filter-sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--color-border);
    border-radius: var(--radius-full);
    margin: 0 auto var(--space-4);
}

.filter-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
}

.filter-sheet-header h3 {
    margin: 0;
    font-size: var(--font-size-lg);
}

.filter-sheet-body {
    margin-bottom: var(--space-4);
}

.filter-sheet-section {
    margin-bottom: var(--space-5);
}

.filter-sheet-section-title {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: var(--space-3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Filter chips */
.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    padding: var(--space-2) var(--space-4);
    background: var(--color-bg-default);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: var(--touch-target-min);
}

.filter-chip:hover,
.filter-chip:focus {
    border-color: var(--color-primary);
}

.filter-chip.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}

.filter-sheet-footer {
    display: flex;
    gap: var(--space-3);
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-border);
}

.filter-sheet-footer .btn {
    flex: 1;
    min-height: var(--touch-target-comfortable);
}

/* ========================================
   MOBILE STAT CARDS
======================================== */
.stats-grid-mobile {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
}

.stat-card-mobile {
    background: var(--color-bg-paper);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    text-align: center;
}

.stat-card-mobile-value {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1;
    margin-bottom: var(--space-1);
}

.stat-card-mobile-label {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ========================================
   UTILITY CLASSES
======================================== */
/* Hide on mobile */
.hide-mobile {
    display: none !important;
}

/* Show only on mobile (hidden by default, shown via media query) */
.show-mobile {
    display: block !important;
}

.show-mobile-flex {
    display: flex !important;
}

.show-mobile-grid {
    display: grid !important;
}

/* Touch scroll */
.scroll-touch {
    -webkit-overflow-scrolling: touch;
    overflow-x: auto;
}

/* Safe area padding */
.safe-area-top {
    padding-top: var(--safe-area-top);
}

.safe-area-bottom {
    padding-bottom: var(--safe-area-bottom);
}

.safe-area-left {
    padding-left: var(--safe-area-left);
}

.safe-area-right {
    padding-right: var(--safe-area-right);
}

/* Truncation */
.truncate-1 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.truncate-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ========================================
   DESKTOP OVERRIDES (768px+)
======================================== */
@media (min-width: 768px) {
    /* Hide mobile-only elements */
    .bottom-nav,
    .more-menu,
    .more-menu-overlay,
    .mobile-header,
    .show-mobile,
    .show-mobile-flex,
    .show-mobile-grid {
        display: none !important;
    }

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

    .hide-mobile-flex {
        display: flex !important;
    }

    /* Reset mobile content padding */
    .main-content-mobile {
        padding-bottom: var(--space-4);
    }
}

/* ========================================
   iPHONE 16 PRO OPTIMIZATION (390px+)
======================================== */
@media (min-width: 390px) {
    /* Slightly larger text for bigger phones */
    .job-card-mobile-title {
        font-size: var(--font-size-lg);
    }

    /* More comfortable spacing */
    .stats-grid-mobile {
        gap: var(--space-4);
    }

    /* Larger filter chips */
    .filter-chip {
        padding: var(--space-3) var(--space-5);
    }
}
