/* PaperHive Mobile Optimization */

/* ============================================
   SMALL SCREENS (phones, < 768px)
   ============================================ */
@media (max-width: 768px) {

    /* --- NAV BAR --- */
    .topnav {
        padding: 8px 12px !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
    }
    .topnav img {
        height: 44px !important;
    }
    .topnav-left {
        gap: 8px !important;
        flex: 1 !important;
    }
    .topnav-right {
        display: flex !important;
        gap: 6px !important;
        flex-wrap: wrap !important;
    }
    .topnav a.nav-link,
    .topnav a.logout,
    .back-link {
        padding: 8px 10px !important;
        font-size: 12px !important;
    }
    .topnav .user-badge {
        font-size: 12px !important;
    }
    /* Page title in nav */
    .topnav div[style*="text-align:center"] span {
        font-size: 16px !important;
        letter-spacing: 0 !important;
    }

    /* --- CONTAINER --- */
    .container {
        padding: 16px 12px !important;
    }

    /* --- STAT CARDS --- */
    .stats {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
        margin-bottom: 16px !important;
    }
    .stat-card {
        padding: 12px 14px !important;
    }
    .stat-card .label {
        font-size: 10px !important;
    }
    .stat-card .value {
        font-size: 18px !important;
    }

    /* --- FILTERS --- */
    .filters {
        padding: 12px !important;
        gap: 8px !important;
        margin-bottom: 16px !important;
    }
    .filter-group,
    .filter-group.wide {
        min-width: unset !important;
        flex: unset !important;
        width: 100% !important;
    }
    .filter-group label {
        font-size: 10px !important;
        margin-bottom: 4px !important;
    }
    .filter-group input,
    .filter-group select {
        padding: 10px 12px !important;
        font-size: 15px !important; /* Prevents iOS zoom on focus */
    }
    .btn-search {
        width: 100% !important;
        padding: 12px !important;
        font-size: 15px !important;
    }
    .btn-clear {
        width: 100% !important;
        padding: 12px !important;
        font-size: 15px !important;
        text-align: center !important;
    }

    /* --- BID CARDS --- */
    .bid-list {
        gap: 8px !important;
    }
    .bid-card {
        padding: 14px 16px !important;
    }
    .bid-card .bid-header {
        flex-direction: column !important;
        gap: 6px !important;
        margin-bottom: 8px !important;
    }
    .bid-card .bid-title {
        font-size: 14px !important;
        line-height: 1.3 !important;
    }
    .bid-card .bid-budget {
        font-size: 14px !important;
    }
    .bid-card .bid-meta {
        gap: 6px 12px !important;
        font-size: 11px !important;
    }
    .tag {
        padding: 3px 8px !important;
        font-size: 10px !important;
    }
    .notes-badge {
        font-size: 10px !important;
    }

    /* --- BID DETAIL PAGE --- */
    .bid-title,
    h1 {
        font-size: 20px !important;
        line-height: 1.3 !important;
    }
    .status-banner {
        flex-wrap: wrap !important;
        gap: 6px !important;
        margin-bottom: 16px !important;
    }
    .action-bar {
        flex-direction: column !important;
        gap: 8px !important;
    }
    .action-bar form,
    .action-bar a {
        width: 100% !important;
    }
    .action-bar .btn {
        width: 100% !important;
        justify-content: center !important;
        padding: 12px !important;
    }
    .info-grid {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }
    .info-card {
        padding: 14px 16px !important;
    }
    .info-card .value {
        font-size: 14px !important;
    }
    .info-card .value.highlight,
    .info-card .value.green {
        font-size: 18px !important;
    }
    .description-box,
    .contact-box {
        padding: 14px !important;
        font-size: 13px !important;
    }
    .flag-info {
        padding: 12px !important;
        font-size: 12px !important;
    }

    /* --- TABLES (line items, activity log, admin) --- */
    .line-items-table,
    .items-table,
    .log-table,
    .user-table {
        display: block !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        font-size: 12px !important;
    }
    .line-items-table th,
    .line-items-table td,
    .items-table th,
    .items-table td,
    .log-table th,
    .log-table td,
    .user-table th,
    .user-table td {
        padding: 8px !important;
        white-space: nowrap !important;
    }

    /* --- NOTES SECTION --- */
    .notes-section {
        margin-top: 20px !important;
    }
    .note-card {
        padding: 12px 14px !important;
    }
    .note-header {
        flex-direction: column !important;
        gap: 2px !important;
        font-size: 12px !important;
    }
    .note-content {
        font-size: 13px !important;
    }
    .note-form {
        padding: 14px !important;
    }
    .note-form textarea {
        font-size: 15px !important; /* Prevents iOS zoom */
        min-height: 60px !important;
    }
    .note-form button {
        width: 100% !important;
        padding: 12px !important;
    }

    /* --- RESEARCH PAGE --- */
    .stage-badge {
        font-size: 11px !important;
        margin-bottom: 10px !important;
    }
    .analysis-grid {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }
    .analysis-card {
        padding: 12px !important;
    }
    .analysis-card .value {
        font-size: 16px !important;
    }
    .summary-text {
        padding: 12px !important;
        font-size: 13px !important;
    }
    .list-section li {
        font-size: 13px !important;
        padding: 4px 0 !important;
    }
    .followup-section {
        margin-top: 14px !important;
        padding-top: 14px !important;
    }
    .followup-section div[style*="display:flex"] {
        flex-direction: column !important;
        gap: 8px !important;
    }
    .followup-answer {
        padding: 12px !important;
        font-size: 13px !important;
    }
    .move-section {
        padding: 14px !important;
    }
    .move-buttons {
        flex-direction: column !important;
        gap: 8px !important;
    }
    .move-buttons form {
        width: 100% !important;
    }
    .move-buttons .btn,
    .move-buttons button {
        width: 100% !important;
        text-align: center !important;
    }

    /* --- PIPELINE PAGE --- */
    .stage-tabs {
        gap: 6px !important;
    }
    .stage-tab {
        padding: 8px 12px !important;
        font-size: 12px !important;
    }

    /* --- SETTINGS & ADMIN --- */
    .card {
        padding: 16px !important;
    }
    .card h2 {
        font-size: 15px !important;
    }
    label {
        font-size: 11px !important;
    }
    input[type="text"],
    input[type="email"],
    input[type="password"],
    textarea {
        font-size: 15px !important; /* Prevents iOS zoom on focus */
        padding: 10px 12px !important;
    }
    button,
    .btn-add {
        font-size: 15px !important;
        padding: 12px !important;
    }

    /* --- PIPELINE TILES ON DASHBOARD --- */
    div[style*="grid-template-columns: repeat(auto-fit"] {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
    }
    div[style*="grid-template-columns: repeat(auto-fit"] a {
        padding: 10px 12px !important;
    }
    div[style*="grid-template-columns: repeat(auto-fit"] a div:first-child {
        font-size: 9px !important;
    }
    div[style*="grid-template-columns: repeat(auto-fit"] a div:last-child {
        font-size: 18px !important;
    }

    /* --- LOGIN PAGE --- */
    .login-card {
        padding: 32px 24px !important;
        margin: 12px !important;
    }
    .login-card img {
        width: 240px !important;
    }

    /* --- LAST UPDATED --- */
    .last-updated {
        font-size: 11px !important;
        padding: 16px !important;
    }

    /* --- EMPTY STATE --- */
    .empty-state {
        padding: 40px 16px !important;
    }
    .empty-state .emoji {
        font-size: 36px !important;
    }

    /* --- FLASH MESSAGES --- */
    .flash {
        font-size: 13px !important;
        padding: 10px 14px !important;
    }
}

/* ============================================
   MEDIUM SCREENS (tablets, 769px - 1024px)
   ============================================ */
@media (min-width: 769px) and (max-width: 1024px) {
    .topnav img {
        height: 56px !important;
    }
    .stats {
        grid-template-columns: repeat(3, 1fr) !important;
    }
    .filters {
        flex-wrap: wrap !important;
    }
    .filter-group {
        min-width: 140px !important;
    }
    .info-grid {
        grid-template-columns: 1fr 1fr !important;
    }
}

/* ============================================
   TOUCH IMPROVEMENTS (all touch devices)
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .bid-card {
        padding: 16px 18px !important;
    }
    .tag {
        padding: 5px 10px !important;
    }
    .btn, .btn-sm, .btn-search, .btn-clear, button {
        min-height: 44px !important;
    }
    a.nav-link, a.logout, a.back-link {
        min-height: 44px !important;
        display: inline-flex !important;
        align-items: center !important;
    }
    .stage-tab {
        min-height: 44px !important;
        display: inline-flex !important;
        align-items: center !important;
    }
    /* Remove hover effects that don't work on touch */
    .bid-card:hover {
        transform: none !important;
    }
}
