/*
 * MOBILE CRITICAL FIXES CSS
 * Date: September 25, 2025
 * Purpose: Corrections critiques pour trade_new.html et dompage.html sur mobile/tablette
 */

/* =============================================================
   CUSTOM TOUCH-FRIENDLY CHECKBOXES (TRADE FLOW)
   ============================================================= */

.dw-checkbox {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.9rem;
    margin-bottom: 0.5rem;
    border: 2px solid #e0e7ef;
    border-radius: 12px;
    background: #ffffff;
    min-height: 48px;
    width: 100%;
    box-sizing: border-box;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    -webkit-tap-highlight-color: rgba(0,0,0,0);
}

/* Mobile alignment: multi-line labels look better top-aligned */
@media (max-width: 768px) {
    .dw-checkbox {
        align-items: flex-start;
    }

    .dw-checkbox-box {
        margin-top: 2px;
    }
}

.dw-checkbox:hover {
    border-color: #0099ff;
    box-shadow: 0 4px 12px rgba(0,153,255,0.15);
}

.dw-checkbox.dw-checkbox-inline {
    display: inline-flex;
    margin-right: 0.75rem;
}

.dw-checkbox-input {
    position: absolute;
    /* Keep the input accessible but don't let it hijack scroll gestures */
    top: 0;
    left: 0;
    width: 1px;
    height: 1px;
    opacity: 0;
    margin: 0;
    cursor: pointer;
    pointer-events: auto;
}

.dw-checkbox-box {
    position: relative;
    display: inline-block;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 2px solid #0099ff;
    flex-shrink: 0;
    background: #ffffff;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
    transition: background 0.2s ease, border-color 0.2s ease;
}

/* Draft picks: make the checkbox box very visible */
.trade-picks-box .dw-checkbox-box {
    width: 34px;
    height: 34px;
    border-width: 3px;
    background: var(--bg-secondary);
    box-shadow:
        inset 0 0 0 1px rgba(0,0,0,0.10),
        0 1px 0 rgba(0,0,0,0.08);
}

[data-theme="dark"] .trade-picks-box .dw-checkbox-box {
    background: var(--bg-tertiary) !important;
    box-shadow:
        inset 0 0 0 1px rgba(255,255,255,0.18),
        0 1px 0 rgba(0,0,0,0.35);
}

.dw-checkbox-box::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 8px;
    width: 8px;
    height: 16px;
    border: solid #ffffff;
    border-width: 0 3px 3px 0;
    transform: rotate(45deg);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.dw-checkbox-input:checked + .dw-checkbox-box {
    background: linear-gradient(135deg, #0099ff 0%, #0066cc 100%);
    border-color: transparent;
}

.dw-checkbox-input:checked + .dw-checkbox-box::after {
    opacity: 1;
}

.dw-checkbox-input:checked ~ .dw-checkbox-content .dw-checkbox-title {
    color: #0066cc;
}

.dw-checkbox-input:focus-visible + .dw-checkbox-box,
.dw-checkbox-input:focus-visible ~ .dw-checkbox-content {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0,153,255,0.35);
}

.dw-checkbox-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.3;
    font-size: 0.95rem;
    color: #212529;
}

.dw-checkbox-title {
    font-weight: 600;
    word-break: break-word;
}

.dw-checkbox-meta {
    font-size: 0.85rem;
}

/* =============================================================
   DARK MODE (trade flow checkboxes)
   ============================================================= */

[data-theme="dark"] .dw-checkbox {
    background: var(--card-bg) !important;
    border-color: var(--border-color) !important;
}

[data-theme="dark"] .dw-checkbox:hover {
    border-color: var(--accent-primary) !important;
}

[data-theme="dark"] .dw-checkbox-content {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .dw-checkbox-meta,
[data-theme="dark"] .dw-checkbox-meta.text-muted {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .dw-checkbox-box {
    background: var(--bg-secondary) !important;
    border-color: var(--accent-primary) !important;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.14);
}

[data-theme="dark"] .dw-checkbox-input:checked ~ .dw-checkbox-content .dw-checkbox-title {
    color: var(--accent-primary) !important;
}

@supports (-webkit-touch-callout: none) {
    .dw-checkbox {
        min-height: 56px;
    }

    .dw-checkbox-box {
        width: 34px;
        height: 34px;
    }
}

/* =============================================================
   TRADE SECTIONS - SCROLL & TYPOGRAPHY
   ============================================================= */

.trade-players-box,
.trade-picks-box {
    -webkit-overflow-scrolling: touch;
    scroll-padding: 1rem;
    max-height: 360px;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
}

.trade-players-box {
    padding-bottom: 0.5rem;
    display: block;
}

.trade-players-box .dw-checkbox {
    margin-bottom: 0.5rem;
}

.trade-players-box .dw-checkbox:last-child {
    margin-bottom: 0;
}

/* trade/new: when columns stack on mobile, add spacing between "Mes joueurs" and "Joueurs de …" */
@media (max-width: 768px) {
    .trade-new-page .trade-players-section .col-12.col-md-6 + .col-12.col-md-6 {
        margin-top: 1rem;
    }
}

/* Give the scroll boxes a little top separation from the headings */
.trade-new-page .trade-players-section .trade-players-box {
    margin-top: 0.5rem;
}

.trade-picks-box {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.5rem;
    align-items: stretch;
}

.trade-picks-box .dw-checkbox-inline {
    min-width: 140px;
    margin-right: 0;
    margin-bottom: 0;
    width: 100%;
    display: flex;
}

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

.trade-form textarea {
    min-height: 72px;
}

@media (max-width: 768px) {
    .trade-players-box,
    .trade-picks-box {
        max-height: 260px;
    }

    .trade-picks-box .dw-checkbox-inline {
        display: block;
        margin-right: 0;
        width: 100%;
    }

    .trade-picks-box {
        grid-template-columns: 1fr;
    }
}

/* Fix for trade form buttons and inputs */
.trade-form .form-control-sm {
    min-height: 44px !important;
    font-size: 1rem !important;
}

.trade-form .btn {
    min-height: 44px !important;
    padding: 0.75rem 1rem !important;
    font-size: 1rem !important;
}

/* =============================================================
   TRADES.HTML - Counter-proposal checkboxes fix  
   ============================================================= */

/* Fix the overflow containers in trades.html */
form[action*="trade_action"] div[style*="max-height:110px;overflow:auto"] {
    max-height: 200px !important; /* Increase from 110px */
    padding: 0.75rem !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 6px !important;
}

/* Target form-check divs inside counter proposal forms */
form[action*="trade_action"] .form-check {
    min-height: 44px !important;
    margin-bottom: 0.5rem !important;
    display: flex !important;
    align-items: flex-start !important; /* Change to flex-start for better alignment */
    padding: 0.25rem 0;
    border-bottom: 1px solid #f0f0f0;
}

/* Last item should not have border */
form[action*="trade_action"] .form-check:last-child {
    border-bottom: none;
}

/* Fix checkbox inputs in trades counter-proposals - PROPER ALIGNMENT */
form[action*="trade_action"] .form-check-input {
    margin-right: 8px !important;
    margin-top: 0.2rem !important; /* Small top margin for alignment */
    transform: none !important;
    position: static !important;
    -webkit-appearance: checkbox;
    appearance: checkbox;
    flex-shrink: 0; /* Prevent shrinking */
}

/* Fix labels in trades counter-proposals */
form[action*="trade_action"] .form-check-label {
    font-size: 0.95rem !important;
    font-weight: normal !important;
    line-height: 1.4 !important;
    margin-left: 0;
    cursor: pointer;
    display: flex;
    align-items: flex-start;
    width: 100%;
}

/* Specific fixes for picks checkboxes in trades.html - NORMAL SIZE */
form[action*="trade_action"] label[class*="mr-3"] {
    margin-right: 1rem !important;
    margin-bottom: 0.5rem !important;
    min-height: 40px;
    display: inline-flex !important;
    align-items: flex-start !important; /* Change to flex-start */
    font-size: 0.95rem !important;
    font-weight: normal !important;
    padding: 0.25rem 0;
}

form[action*="trade_action"] label[class*="mr-3"] input[type="checkbox"] {
    margin-right: 5px !important;
    margin-top: 0.2rem !important; /* Small top margin for alignment */
    transform: none !important;
}

/* Mobile specific adjustments for trades */
@media (max-width: 768px) {
    form[action*="trade_action"] div[style*="max-height"] {
        max-height: 150px !important;
    }
    
    form[action*="trade_action"] label[class*="mr-3"] {
        display: block !important;
        margin-right: 0 !important;
        margin-bottom: 1rem !important;
    }
}

/* =============================================================
   TRADE_ADMIN_EDIT.HTML - Admin trade modification fix  
   ============================================================= */

/* Fix the overflow containers in trade_admin_edit.html */
div.border.p-2[style*="max-height:200px;overflow:auto"] {
    max-height: 300px !important; /* Increase from 200px */
    padding: 1rem !important;
}

/* Fix form-check elements in trade admin edit - NORMAL SIZE */
div.border.p-2 .form-check.small {
    min-height: 44px !important;
    margin-bottom: 0.5rem !important;
    display: flex !important;
    align-items: flex-start !important; /* Change to flex-start for better alignment */
    padding: 0.25rem 0;
    border-bottom: 1px solid #f0f0f0;
}

div.border.p-2 .form-check.small:last-child {
    border-bottom: none;
}

div.border.p-2 .form-check.small .form-check-input {
    margin-right: 8px !important;
    margin-top: 0.2rem !important; /* Small top margin for alignment */
    transform: none !important;
    position: static !important;
}

div.border.p-2 .form-check.small .form-check-label {
    font-size: 0.875rem !important; /* Keep small but readable */
    font-weight: normal !important;
    line-height: 1.3 !important;
    cursor: pointer;
    display: flex;
    align-items: flex-start;
    width: 100%;
    margin-left: 0;
}

/* =============================================================
   MOBILE NAVIGATION ICONS FIX
   ============================================================= */

/* Styles par défaut pour desktop - Messagerie */
#messages-container {
    height: 500px;
    overflow-y: auto;
}

#messages-list .d-inline-block {
    max-width: 70%;
}

/* Reduce icon size in mobile hamburger menu */
@media (max-width: 768px) {
    .navbar-collapse .nav-link i.fas,
    .navbar-collapse .nav-link i.far {
        font-size: 0.875rem !important; /* Plus petit: 0.875rem au lieu de 1rem */
        vertical-align: middle;
        margin-right: 0.5rem !important;
    }
    
    /* Ensure nav-link text is also readable on mobile */
    .navbar-collapse .nav-link {
        padding: 0.5rem 1rem !important; /* Moins de padding */
        font-size: 0.9rem !important;
    }
    
    /* Reduce SVG icons in messaging templates */
    svg.w-5, svg.w-3 {
        width: 1rem !important;
        height: 1rem !important;
    }
    
    /* Make buttons more compact on mobile */
    .btn-lg {
        padding: 0.5rem 1rem !important;
        font-size: 1rem !important;
    }
    
    .btn i.fas {
        font-size: 0.875rem !important;
    }
    
    /* Réduire tous les icônes FontAwesome sur mobile */
    .fas, .far, .fab, .fal {
        font-size: 0.875rem !important;
    }
    
    /* Liste d'utilisateurs dans les formulaires */
    .form-control-lg {
        font-size: 1rem !important;
        padding: 0.5rem 0.75rem !important;
    }
    
    /* Messagerie mobile - style compact */
    #messages-container {
        height: 400px !important; /* Plus petit sur mobile */
    }
    
    #messages-list .mb-3 {
        margin-bottom: 0.5rem !important;
    }
    
    #messages-list .d-inline-block {
        max-width: 85% !important; /* Plus large sur mobile */
    }
    
    #messages-list .p-2 {
        padding: 0.5rem !important; /* Moins de padding */
    }
    
    #messages-list .small,
    #messages-list strong {
        font-size: 0.75rem !important;
    }
    
    #messages-list p {
        font-size: 0.875rem !important;
        margin-bottom: 0.25rem !important;
    }
    
    #message-input {
        font-size: 1rem !important;
    }
    
    /* Formulaire d'envoi compact */
    #message-form .btn {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.875rem !important;
    }
}