/**
 * GCF2 Mobile UX Improvements
 * Enhanced responsive design and accessibility
 */

/* ========================================
   ACCORDION IMPROVEMENTS
   ======================================== */

/* Smooth transitions for accordion expand/collapse */
.accordian-body {
    transition: all 0.3s ease-in-out;
    overflow: hidden;
}

/* Accordion toggle rows - improved touch targets */
.accordion-toggle {
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    position: relative;
}

.accordion-toggle:hover {
    background-color: #f5f5f5 !important;
}

.accordion-toggle:active {
    transform: scale(0.98);
}

/* Add chevron indicator for expand/collapse state */
.accordion-toggle td:first-child::before {
    content: '\f078'; /* FontAwesome chevron-down */
    font-family: 'FontAwesome';
    margin-right: 8px;
    font-size: 12px;
    color: #337ab7;
    transition: transform 0.3s ease;
    display: inline-block;
}

/* Rotate chevron when expanded */
.accordion-toggle.expanded td:first-child::before {
    transform: rotate(-180deg);
}

/* Touch-friendly minimum height for tap targets */
.accordion-toggle td {
    min-height: 44px;
    padding: 12px 8px !important;
    vertical-align: middle;
}

/* Visual feedback for keyboard focus */
.accordion-toggle:focus {
    outline: 2px solid #337ab7;
    outline-offset: -2px;
}

/* ========================================
   RESPONSIVE CARD LAYOUT FOR MOBILE
   ======================================== */

@media (max-width: 767px) {
    /* Hide table headers on mobile */
    .table thead {
        display: none;
    }

    /* Transform table rows into cards */
    .table tbody tr.accordion-toggle {
        display: block;
        margin-bottom: 0px;
        border: 1px solid #ddd;
        border-radius: 8px;
        background: #fff;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        overflow: hidden;
    }

    .table tbody tr.accordion-toggle td {
        display: block;
        border: none;
        padding: 8px 15px !important;
        text-align: left !important;
    }

    /* Card header with ID and date - more distinct color */
    .table tbody tr.accordion-toggle td:first-child {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: #ffffff;
        font-weight: 600;
        font-size: 14px;
        border-bottom: 2px solid #5568d3;
        padding: 12px 15px !important;
        box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
    }

    .table tbody tr.accordion-toggle td:first-child::after {
        content: attr(data-date);
        float: right;
        font-weight: 400;
        color: #e8eaf6;
        font-size: 13px;
    }

    /* Name and Location on same line with flexbox */
    .table tbody tr.accordion-toggle td:nth-child(2) {
        font-size: 18px;
        font-weight: 500;
        padding: 12px 8px 12px 15px !important;
        display: inline-block;
        width: auto;
        max-width: 45%;
        vertical-align: middle;
    }

    .table tbody tr.accordion-toggle td:nth-child(2)::before {
        content: '';
        display: none;
    }

    /* Location field with icon - aligned to the right */
    .table tbody tr.accordion-toggle td:nth-child(3) {
        color: #6c757d;
        font-size: 14px;
        padding: 12px 15px 12px 4px !important;
        display: block;
        width: auto;
        max-width: 52%;
        float: right;
        text-align: right;
    }

    .table tbody tr.accordion-toggle td:nth-child(3)::before {
        content: '\f041'; /* FontAwesome map-marker */
        font-family: 'FontAwesome';
        margin-right: 6px;
        color: #dc3545;
    }

    /* Hide the date column (already shown in header) */
    .table tbody tr.accordion-toggle td:nth-child(4) {
        display: none;
    }

    /* Expanded content row - minimum gap */
    .table tbody tr:not(.accordion-toggle) {
        display: block;
        margin-bottom: 8px;
        margin-top: 0;
    }

    .table tbody tr:not(.accordion-toggle) td {
        display: block;
        border: none;
        padding: 0 !important;
    }

    /* Style the accordion body inside the content */
    .table tbody tr:not(.accordion-toggle) td .accordian-body {
        margin-top: 0;
        border-radius: 0 0 8px 8px;
        border: 1px solid #ddd;
        border-top: none;
    }

    /* Remove table styling completely on mobile */
    .table {
        border: none;
    }

    .table tbody {
        display: block;
    }
}

/* ========================================
   IMPROVED COLOR CONTRAST & VISUAL HIERARCHY
   ======================================== */

/* Better contrast for expanded ad details */
.accordian-body {
    background-color: #f8f9fa !important; /* Changed from #EFF0DA for better contrast */
    padding: 15px;
    border-radius: 4px;
    margin-top: 10px;
}

/* Highlighted ads - premium styling */
.accordion-toggle.highlighted {
    border-left: 4px solid #ffc107 !important;
    background-color: #fffbf0 !important;
}

.accordion-toggle.highlighted::after {
    content: '\f005'; /* FontAwesome star */
    font-family: 'FontAwesome';
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #ffc107;
    font-size: 18px;
}

/* ========================================
   ENHANCED BUTTONS & TOUCH TARGETS
   ======================================== */

/* Larger reply buttons */
.btn-xs {
    padding: 6px 12px;
    font-size: 14px;
    line-height: 1.5;
    border-radius: 4px;
    min-width: 100px;
    min-height: 36px;
}

/* Mobile-specific button sizing */
@media (max-width: 767px) {
    .btn-xs,
    .btn-sm {
        padding: 10px 20px;
        font-size: 16px;
        min-height: 44px;
        width: 100%;
        display: block;
        margin-top: 10px;
    }
}

/* Better phone and Telegram link styling */
.phone-link,
.telegram-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background-color: #e9ecef;
    border-radius: 4px;
    text-decoration: none;
    color: #212529;
    transition: background-color 0.2s ease;
    margin: 5px 0;
}

.phone-link:hover,
.telegram-link:hover {
    background-color: #dee2e6;
    text-decoration: none;
}

.phone-link i,
.telegram-link img {
    flex-shrink: 0;
}

/* Mobile phone link - make it a prominent call button */
@media (max-width: 767px) {
    .phone-link {
        background-color: #28a745;
        color: white;
        font-size: 16px;
        padding: 12px 16px;
        border-radius: 8px;
        width: 100%;
        justify-content: center;
        margin: 10px 0;
    }

    .phone-link:hover {
        background-color: #218838;
        color: white;
    }
}

/* ========================================
   NAVIGATION IMPROVEMENTS
   ======================================== */

/* Touch-friendly navigation pills */
.nav-pills > li > a {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 15px;
}

@media (max-width: 767px) {
    .nav-pills > li > a {
        padding: 12px 10px;
    }

    .nav-pills .fa-2x {
        font-size: 1.5em; /* Slightly smaller icons on mobile */
    }
}

/* ========================================
   CONTENT FORMATTING
   ======================================== */

/* Structured detail rows */
.ad-detail-row {
    display: flex;
    gap: 10px;
    margin: 8px 0;
    padding: 8px 0;
    border-bottom: 1px solid #e9ecef;
}

.ad-detail-row:last-child {
    border-bottom: none;
}

.ad-detail-label {
    font-weight: 600;
    min-width: 120px;
    color: #495057;
}

.ad-detail-value {
    flex: 1;
    color: #212529;
}

/* Intention/purpose badge */
.ad-intention {
    display: inline-block;
    padding: 4px 10px;
    background-color: #e7f3ff;
    border: 1px solid #b3d9ff;
    border-radius: 4px;
    font-weight: 600;
    color: #004085;
    margin-bottom: 10px;
}

/* ========================================
   ACCESSIBILITY IMPROVEMENTS
   ======================================== */

/* Screen reader only text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus visible for keyboard navigation */
a:focus,
button:focus,
.accordion-toggle:focus {
    outline: 2px solid #337ab7;
    outline-offset: 2px;
}

/* Skip to content link */
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: #337ab7;
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 0 0 4px 0;
    z-index: 100;
}

.skip-to-content:focus {
    top: 0;
}

/* ========================================
   TABLET BREAKPOINT (768px - 991px)
   ======================================== */

@media (min-width: 768px) and (max-width: 991px) {
    /* Reduce font sizes slightly for tablet */
    .table tbody tr.accordion-toggle td {
        font-size: 14px;
        padding: 10px 8px !important;
    }

    /* Compact navigation on tablet */
    .nav-pills > li > a {
        padding: 8px 12px;
    }
}

/* ========================================
   LOADING STATES
   ======================================== */

/* Spinner overlay */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #337ab7;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.spinner-overlay p {
    margin-top: 20px;
    font-size: 16px;
    color: #495057;
}

/* ========================================
   ADDITIONAL TOUCH IMPROVEMENTS
   ======================================== */

/* Prevent text selection during tap */
.accordion-toggle {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    -webkit-touch-callout: none;
    user-select: none;
}

/* Allow text selection in expanded content */
.accordian-body {
    user-select: text;
    -webkit-touch-callout: default;
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

/* Better line height for readability */
.accordian-body {
    line-height: 1.6;
}

/* ========================================
   TOGGLE BUTTON STYLING
   ======================================== */

/* Mobile responsive toggle button - ensure text is visible and properly sized */
@media (max-width: 767px) {
    .nav-pills > li > a {
        font-size: 14px !important;
    }

    /* Make toggle button text smaller on very small screens */
    @media (max-width: 400px) {
        .nav-pills > li > a span {
            font-size: 13px !important;
        }
    }
}

/* Smooth animation for bulk expand/collapse */
.accordian-body {
    transition: max-height 0.3s ease-in-out, padding 0.3s ease-in-out;
}

.accordion-toggle {
    transition: background-color 0.2s ease;
}

/* ========================================
   GCF2ADD FORM ENHANCEMENTS
   ======================================== */

/* Form container spacing */
.form-horizontal {
    padding: 0 15px;
}

/* Form group spacing - remove inline styles */
.form-horizontal .form-group {
    margin-bottom: 20px;
}

/* Responsive form layout */
@media (max-width: 767px) {
    .form-horizontal .row {
        margin-left: 0;
        margin-right: 0;
    }

    .form-horizontal .col-xs-12 {
        padding-left: 0;
        padding-right: 0;
    }

    /* Full width inputs on mobile */
    .form-horizontal .form-control {
        width: 100%;
    }

    /* Larger touch targets for mobile */
    .form-horizontal select.form-control,
    .form-horizontal input.form-control {
        min-height: 44px;
        font-size: 16px;
    }

    /* Prevent iOS zoom on focus */
    .form-horizontal input[type="text"],
    .form-horizontal input[type="email"],
    .form-horizontal input[type="number"],
    .form-horizontal textarea,
    .form-horizontal select {
        font-size: 16px;
    }
}

/* Alert box enhancements */
.alert {
    border-radius: 6px;
    margin-bottom: 15px;
}

.alert-heading {
    margin-top: 0;
    margin-bottom: 10px;
}

.alert .fa {
    margin-right: 8px;
}

/* Submit button group */
.form-horizontal .btn {
    min-width: 120px;
    margin-right: 10px;
}

@media (max-width: 767px) {
    .form-horizontal .btn {
        width: 100%;
        margin-right: 0;
        margin-bottom: 10px;
    }
}

/* Checkbox styling for better UX */
.form-horizontal .checkbox label {
    padding-left: 5px;
    font-weight: normal;
}

.form-horizontal input[type="checkbox"] {
    margin-right: 8px;
    width: 20px;
    height: 20px;
    vertical-align: middle;
}

/* Telegram button */
.btn-telegram {
    margin-top: 10px;
}

@media (max-width: 767px) {
    .btn-telegram {
        width: 100%;
    }
}
