/* ============================================
   FEYA RESPONSIVE DESIGN SYSTEM
   Comprehensive mobile-first responsive styles
   Breakpoints: xs (<576px), sm (576-767px), md (768-991px), lg (992-1199px), xl (>=1200px)
   ============================================ */

/* ============================================
   CSS CUSTOM PROPERTIES FOR RESPONSIVE DESIGN
   ============================================ */
:root {
    --responsive-gutter-xs: 0.75rem;
    --responsive-gutter-sm: 1rem;
    --responsive-gutter-md: 1.25rem;
    --responsive-gutter-lg: 1.5rem;
    --responsive-gutter-xl: 2rem;
}

/* ============================================
   BASE RESPONSIVE TYPOGRAPHY
   ============================================ */
html {
    font-size: 14px;
}

@media (min-width: 576px) {
    html {
        font-size: 14px;
    }
}

@media (min-width: 768px) {
    html {
        font-size: 15px;
    }
}

@media (min-width: 992px) {
    html {
        font-size: 16px;
    }
}

/* ============================================
   RESPONSIVE CONTAINER ADJUSTMENTS
   ============================================ */
.container,
.container-fluid {
    padding-left: var(--responsive-gutter-xs);
    padding-right: var(--responsive-gutter-xs);
}

@media (min-width: 576px) {
    .container,
    .container-fluid {
        padding-left: var(--responsive-gutter-sm);
        padding-right: var(--responsive-gutter-sm);
    }
}

@media (min-width: 768px) {
    .container,
    .container-fluid {
        padding-left: var(--responsive-gutter-md);
        padding-right: var(--responsive-gutter-md);
    }
}

@media (min-width: 992px) {
    .container,
    .container-fluid {
        padding-left: var(--responsive-gutter-lg);
        padding-right: var(--responsive-gutter-lg);
    }
}

/* ============================================
   RESPONSIVE NAVBAR
   ============================================ */
/* Mobile Navbar Enhancements */
@media (max-width: 991.98px) {
    .feya-navbar .navbar-collapse {
        background: linear-gradient(
            135deg,
            rgba(64, 145, 145, 0.98) 0%,
            rgba(72, 166, 167, 0.98) 50%,
            rgba(95, 180, 180, 0.98) 100%
        );
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        padding: 1rem;
        margin-top: 0.5rem;
        border-radius: 0.75rem;
        border: 1px solid rgba(255, 255, 255, 0.2);
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    }

    .feya-navbar .navbar-nav {
        flex-direction: column;
        gap: 0.25rem;
        width: 100%;
    }

    .feya-navbar .nav-link {
        padding: 0.75rem 1rem !important;
        border-radius: 0.5rem;
        margin: 0.125rem 0;
    }

    .feya-navbar .dropdown-menu {
        position: static !important;
        width: 100%;
        margin-top: 0.5rem;
        border: none;
        box-shadow: none;
        background: rgba(255, 255, 255, 0.1);
        padding: 0.5rem;
    }

    .feya-navbar .dropdown-menu .dropdown-item {
        padding: 0.625rem 1rem;
        margin: 0.125rem 0;
        border-radius: 0.375rem;
    }

    .feya-nav-cta {
        margin-left: 0 !important;
        margin-top: 0.5rem !important;
    }

    /* Mobile navbar toggler enhancement */
    .feya-navbar .navbar-toggler {
        padding: 0.5rem;
        font-size: 1.5rem;
    }
}

/* Admin Navbar Mobile */
@media (max-width: 991.98px) {
    .admin-navbar .navbar-collapse {
        background: linear-gradient(
            135deg,
            rgba(64, 145, 145, 0.98) 0%,
            rgba(72, 166, 167, 0.98) 50%,
            rgba(95, 180, 180, 0.98) 100%
        );
        backdrop-filter: blur(20px);
        padding: 1rem;
        margin-top: 0.5rem;
        border-radius: 0.75rem;
        border: 1px solid rgba(255, 255, 255, 0.2);
        max-height: 80vh;
        overflow-y: auto;
    }

    .admin-navbar .navbar-nav {
        flex-direction: column;
        width: 100%;
    }

    .admin-navbar .nav-link {
        padding: 0.75rem 1rem !important;
        margin: 0.125rem 0;
    }

    .admin-navbar .dropdown-menu {
        position: static !important;
        width: 100%;
        margin-top: 0.25rem;
        background: rgba(255, 255, 255, 0.1) !important;
        border: none !important;
        box-shadow: none !important;
    }
}

/* ============================================
   RESPONSIVE TABLES
   ============================================ */
/* Make tables scrollable on small screens */
.table-responsive-stack {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 767.98px) {
    /* Card-style tables for mobile */
    .table-responsive-stack table,
    .table-responsive-stack thead,
    .table-responsive-stack tbody,
    .table-responsive-stack th,
    .table-responsive-stack td,
    .table-responsive-stack tr {
        display: block;
    }

    .table-responsive-stack thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    .table-responsive-stack tr {
        margin-bottom: 1rem;
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 0.5rem;
        background: rgba(64, 145, 145, 0.6);
        padding: 0.5rem;
    }

    .table-responsive-stack td {
        border: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        position: relative;
        padding: 0.75rem 0.75rem 0.75rem 45%;
        white-space: normal;
        text-align: right;
    }

    .table-responsive-stack td:last-child {
        border-bottom: none;
    }

    .table-responsive-stack td::before {
        content: attr(data-label);
        position: absolute;
        left: 0.75rem;
        width: 40%;
        padding-right: 0.5rem;
        font-weight: 600;
        text-align: left;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Regular responsive tables */
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-responsive > .table {
        margin-bottom: 0;
        width: max-content;
        min-width: 100%;
    }

    .table th,
    .table td {
        white-space: nowrap;
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }

    /* Hide less important columns on mobile */
    .hide-mobile {
        display: none !important;
    }
}

@media (min-width: 768px) and (max-width: 991.98px) {
    .table th,
    .table td {
        padding: 0.625rem 0.75rem;
        font-size: 0.875rem;
    }

    .hide-tablet {
        display: none !important;
    }
}

/* ============================================
   RESPONSIVE CARDS
   ============================================ */
/* Card grid responsive */
.card-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
}

@media (min-width: 576px) {
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 992px) {
    .card-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1200px) {
    .card-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Card responsive padding */
@media (max-width: 575.98px) {
    .card {
        margin-left: 0;
        margin-right: 0;
    }

    .card-body {
        padding: 1rem;
    }

    .card-header,
    .card-footer {
        padding: 0.75rem 1rem;
    }

    .feya-card .card-body,
    .admin-card .card-body {
        padding: 1rem;
    }
}

/* Stat cards responsive */
@media (max-width: 575.98px) {
    .feya-stat-card,
    .admin-stat-card {
        padding: 1rem;
    }

    .feya-stat-value,
    .admin-stat-content h3 {
        font-size: 1.75rem;
    }

    .feya-stat-label,
    .admin-stat-content p {
        font-size: 0.75rem;
    }

    .admin-stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
}

/* ============================================
   RESPONSIVE WISH CARDS
   ============================================ */
@media (max-width: 575.98px) {
    .feya-wish-card {
        padding: 1rem;
        margin: 0.5rem 0;
    }

    .feya-wish-card::before,
    .feya-wish-card::after {
        width: 25px;
        height: 25px;
    }

    .feya-wish-card .wish-title {
        font-size: 1rem;
    }

    .feya-wish-card .wish-text {
        font-size: 0.875rem;
    }
}

/* ============================================
   RESPONSIVE HERO SECTIONS
   ============================================ */
@media (max-width: 575.98px) {
    .feya-hero {
        padding: 2rem 1rem;
    }

    .feya-hero-title {
        font-size: 1.75rem;
    }

    .feya-hero-subtitle {
        font-size: 0.9rem;
    }

    .feya-hero-icon {
        font-size: 2rem;
    }
}

@media (min-width: 576px) and (max-width: 767.98px) {
    .feya-hero {
        padding: 2.5rem 1.5rem;
    }

    .feya-hero-title {
        font-size: 2.25rem;
    }
}

/* ============================================
   RESPONSIVE BUTTONS
   ============================================ */
@media (max-width: 575.98px) {
    .feya-btn,
    .admin-btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }

    .feya-btn-lg,
    .admin-btn-lg {
        padding: 0.625rem 1.25rem;
        font-size: 0.9375rem;
    }

    .feya-btn-xl {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }

    /* Stack buttons on mobile */
    .btn-group-responsive {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .btn-group-responsive .btn,
    .btn-group-responsive .feya-btn,
    .btn-group-responsive .admin-btn {
        width: 100%;
    }
}

/* ============================================
   RESPONSIVE FORMS
   ============================================ */
@media (max-width: 575.98px) {
    .feya-form-control,
    .admin-form-control,
    .form-control {
        padding: 0.625rem 0.75rem;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .feya-form-group,
    .admin-form-group,
    .mb-3 {
        margin-bottom: 1rem;
    }

    /* Stack form fields on mobile */
    .row .col-md-6,
    .row .col-lg-4 {
        margin-bottom: 0.75rem;
    }

    /* Inline form responsive */
    .form-inline {
        flex-direction: column;
        align-items: stretch;
    }

    .form-inline .form-control,
    .form-inline .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

/* ============================================
   RESPONSIVE MODALS
   ============================================ */
@media (max-width: 575.98px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    .modal-content {
        border-radius: 0.75rem;
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-footer {
        padding: 0.75rem 1rem;
        flex-direction: column;
        gap: 0.5rem;
    }

    .modal-footer .btn {
        width: 100%;
        margin: 0;
    }
}

@media (min-width: 576px) and (max-width: 767.98px) {
    .modal-dialog {
        margin: 1rem auto;
        max-width: 90%;
    }
}

/* ============================================
   RESPONSIVE BADGES
   ============================================ */
@media (max-width: 575.98px) {
    .badge,
    .feya-badge,
    .admin-badge {
        font-size: 0.6875rem;
        padding: 0.2rem 0.5rem;
    }

    .feya-badge-status,
    .admin-badge-lg {
        font-size: 0.75rem;
        padding: 0.25rem 0.625rem;
    }
}

/* ============================================
   RESPONSIVE PAGINATION
   ============================================ */
@media (max-width: 575.98px) {
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.25rem;
    }

    .pagination .page-link,
    .admin-pagination .page-link {
        min-width: 2rem;
        height: 2rem;
        padding: 0 0.5rem;
        font-size: 0.8125rem;
    }

    /* Hide some page numbers on mobile */
    .pagination .page-item:not(:first-child):not(:last-child):not(.active):not(:nth-child(2)):not(:nth-last-child(2)) {
        display: none;
    }
}

/* ============================================
   RESPONSIVE FOOTER
   ============================================ */
@media (max-width: 767.98px) {
    .feya-footer {
        text-align: center;
        padding: 1.5rem 0;
    }

    .feya-footer .row {
        gap: 1rem;
    }

    .feya-footer-brand {
        justify-content: center;
        margin-bottom: 1rem;
    }

    .feya-social-links {
        justify-content: center;
    }

    .feya-footer-text {
        font-size: 0.8125rem;
    }
}

/* ============================================
   RESPONSIVE FLOATING ELEMENTS
   ============================================ */
@media (max-width: 575.98px) {
    .feya-role-indicator {
        bottom: 10px;
        left: 10px;
    }

    .feya-role-indicator .feya-badge {
        padding: 0.375rem 0.75rem;
        font-size: 0.75rem;
    }

    .feya-fab {
        bottom: 10px;
        right: 10px;
        padding: 0.5rem 1rem;
        font-size: 0.8125rem;
    }
}

/* ============================================
   RESPONSIVE AUTH PAGES
   ============================================ */
@media (max-width: 575.98px) {
    .feya-auth-container {
        padding: 1rem;
        min-height: auto;
    }

    .feya-auth-card {
        padding: 1.5rem;
        border-radius: 1rem;
    }

    .feya-auth-title {
        font-size: 2rem;
    }

    .feya-auth-subtitle {
        font-size: 0.9375rem;
    }

    .feya-auth-btn {
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }
}

/* ============================================
   RESPONSIVE LEADERBOARD
   ============================================ */
@media (max-width: 575.98px) {
    .feya-leaderboard-item {
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .feya-leaderboard-rank {
        width: 32px;
        height: 32px;
        font-size: 0.75rem;
    }

    .feya-leaderboard-name {
        font-size: 0.875rem;
    }

    .feya-leaderboard-score {
        font-size: 0.875rem;
    }
}

/* ============================================
   RESPONSIVE AVATARS
   ============================================ */
@media (max-width: 575.98px) {
    .feya-avatar,
    .admin-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.75rem;
    }

    .feya-avatar-lg,
    .admin-avatar-lg {
        width: 44px;
        height: 44px;
        font-size: 1rem;
    }

    .feya-avatar-xl {
        width: 60px;
        height: 60px;
        font-size: 1.25rem;
    }
}

/* ============================================
   RESPONSIVE TIMELINE
   ============================================ */
@media (max-width: 575.98px) {
    .admin-timeline {
        padding-left: 1.5rem;
    }

    .admin-timeline-marker {
        left: -1.25rem;
        width: 0.75rem;
        height: 0.75rem;
    }

    .admin-timeline-content {
        padding: 0.625rem 0.75rem;
    }

    .admin-timeline-title {
        font-size: 0.875rem;
    }

    .admin-timeline-subtitle {
        font-size: 0.75rem;
    }
}

/* ============================================
   RESPONSIVE FILTERS
   ============================================ */
@media (max-width: 767.98px) {
    .admin-filters {
        flex-direction: column;
        gap: 0.5rem;
    }

    .admin-filters .form-control,
    .admin-filters .form-select,
    .admin-filters .admin-form-control,
    .admin-filters .admin-form-select {
        width: 100%;
    }

    .admin-filters .btn {
        width: 100%;
    }
}

/* ============================================
   RESPONSIVE PAGE HEADERS
   ============================================ */
@media (max-width: 767.98px) {
    .admin-page-header,
    .d-flex.justify-content-between.align-items-center {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1rem;
    }

    .admin-page-header h1,
    .admin-page-header .page-title,
    h1, h2 {
        font-size: 1.5rem;
    }

    .feya-page-title {
        font-size: 1.75rem;
    }

    .feya-section-title {
        font-size: 1.25rem;
    }
}

/* ============================================
   RESPONSIVE EMPTY STATES
   ============================================ */
@media (max-width: 575.98px) {
    .feya-empty-state,
    .admin-empty-state {
        padding: 2rem 1rem;
    }

    .feya-empty-state-icon,
    .admin-empty-state-icon {
        font-size: 3rem;
    }

    .feya-empty-state h3,
    .admin-empty-state h3 {
        font-size: 1rem;
    }
}

/* ============================================
   RESPONSIVE ALERTS
   ============================================ */
@media (max-width: 575.98px) {
    .alert,
    .feya-alert,
    .admin-alert {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }

    .alert-icon,
    .feya-alert-icon,
    .admin-alert-icon {
        font-size: 1rem;
    }
}

/* ============================================
   RESPONSIVE UTILITY CLASSES
   ============================================ */
/* Text alignment */
@media (max-width: 575.98px) {
    .text-center-xs { text-align: center !important; }
    .text-start-xs { text-align: left !important; }
    .text-end-xs { text-align: right !important; }
}

@media (min-width: 576px) and (max-width: 767.98px) {
    .text-center-sm { text-align: center !important; }
    .text-start-sm { text-align: left !important; }
    .text-end-sm { text-align: right !important; }
}

/* Display utilities */
@media (max-width: 575.98px) {
    .d-none-xs { display: none !important; }
    .d-block-xs { display: block !important; }
    .d-flex-xs { display: flex !important; }
}

@media (min-width: 576px) and (max-width: 767.98px) {
    .d-none-sm-only { display: none !important; }
}

/* Spacing utilities for mobile */
@media (max-width: 575.98px) {
    .p-xs-2 { padding: 0.5rem !important; }
    .p-xs-3 { padding: 1rem !important; }
    .px-xs-2 { padding-left: 0.5rem !important; padding-right: 0.5rem !important; }
    .py-xs-2 { padding-top: 0.5rem !important; padding-bottom: 0.5rem !important; }
    .m-xs-0 { margin: 0 !important; }
    .mb-xs-2 { margin-bottom: 0.5rem !important; }
    .mb-xs-3 { margin-bottom: 1rem !important; }
    .mt-xs-3 { margin-top: 1rem !important; }
    .gap-xs-2 { gap: 0.5rem !important; }
}

/* Width utilities */
@media (max-width: 575.98px) {
    .w-xs-100 { width: 100% !important; }
    .w-xs-auto { width: auto !important; }
}

/* Flex utilities */
@media (max-width: 575.98px) {
    .flex-column-xs { flex-direction: column !important; }
    .flex-wrap-xs { flex-wrap: wrap !important; }
    .justify-content-center-xs { justify-content: center !important; }
    .align-items-stretch-xs { align-items: stretch !important; }
}

/* ============================================
   RESPONSIVE SCROLLING
   ============================================ */
/* Smooth scrolling behavior */
@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

/* Custom scrollbar for mobile */
@media (max-width: 767.98px) {
    ::-webkit-scrollbar {
        width: 4px;
        height: 4px;
    }
}

/* ============================================
   RESPONSIVE IMAGES
   ============================================ */
img {
    max-width: 100%;
    height: auto;
}

/* Responsive image containers */
.img-container-responsive {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.img-container-responsive img {
    width: 100%;
    height: auto;
    object-fit: cover;
}

/* ============================================
   RESPONSIVE PROGRESS BARS
   ============================================ */
@media (max-width: 575.98px) {
    .progress {
        height: 0.5rem;
    }

    .progress-bar {
        font-size: 0.625rem;
    }
}

/* ============================================
   TOUCH DEVICE OPTIMIZATIONS
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .btn,
    .feya-btn,
    .admin-btn,
    .nav-link,
    .dropdown-item,
    .page-link {
        min-height: 44px;
        min-width: 44px;
    }

    /* Remove hover effects that don't work well on touch */
    .feya-card:hover,
    .admin-card:hover,
    .feya-wish-card:hover,
    .feya-stat-card:hover,
    .admin-stat-card:hover {
        transform: none;
    }

    /* Add active states for touch feedback */
    .btn:active,
    .feya-btn:active,
    .admin-btn:active {
        transform: scale(0.98);
    }
}

/* ============================================
   PRINT RESPONSIVE STYLES
   ============================================ */
@media print {
    /* Hide non-essential elements */
    .feya-navbar,
    .admin-navbar,
    .feya-footer,
    .feya-fab,
    .feya-role-indicator,
    .btn,
    .feya-btn,
    .admin-btn,
    .pagination,
    .modal {
        display: none !important;
    }

    /* Full width for print */
    body,
    .container,
    .container-fluid {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Remove backgrounds for better printing */
    body {
        background: white !important;
        color: black !important;
    }

    .card,
    .feya-card,
    .admin-card {
        background: white !important;
        border: 1px solid #ddd !important;
        box-shadow: none !important;
    }

    /* Force page breaks */
    .page-break-before { page-break-before: always; }
    .page-break-after { page-break-after: always; }
    .page-break-avoid { page-break-inside: avoid; }
}

/* ============================================
   LANDSCAPE ORIENTATION ADJUSTMENTS
   ============================================ */
@media (max-width: 767.98px) and (orientation: landscape) {
    .feya-hero {
        padding: 1.5rem 1rem;
    }

    .feya-hero-title {
        font-size: 1.5rem;
    }

    .modal-dialog {
        max-height: 90vh;
        overflow-y: auto;
    }

    .feya-navbar .navbar-collapse {
        max-height: 70vh;
        overflow-y: auto;
    }
}

/* ============================================
   HIGH DPI / RETINA DISPLAY SUPPORT
   ============================================ */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .feya-card,
    .admin-card,
    .card {
        border-width: 0.5px;
    }
}

/* ============================================
   SAFE AREA INSETS (for notched phones)
   ============================================ */
@supports (padding: env(safe-area-inset-bottom)) {
    .feya-footer,
    footer {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    }

    .feya-fab,
    .feya-role-indicator {
        bottom: calc(10px + env(safe-area-inset-bottom));
    }

    .feya-navbar {
        padding-top: env(safe-area-inset-top);
    }
}

/* ============================================
   DARK MODE RESPONSIVE ADJUSTMENTS
   ============================================ */
@media (prefers-color-scheme: dark) {
    /* Ensure consistent dark mode experience */
    .feya-card,
    .admin-card {
        background: rgba(64, 145, 145, 0.9);
    }
}
