/* ============================================================================
   COMPREHENSIVE RESPONSIVE DESIGN FIXES
   Tec-Members-Admin Dashboard
   ============================================================================ */

/* =============================================================================
   MOBILE FIRST APPROACH - Base Styles (Mobile)
   ============================================================================= */

/* Search Input Responsive */
input[type="text"].form-control {
    max-width: min(400px, 100%) !important;
}

/* Container Responsive Padding - safe area only, respects per-page padding classes */
.container-fluid {
    padding-left: max(var(--bs-gutter-x, 1.5rem), env(safe-area-inset-left));
    padding-right: max(var(--bs-gutter-x, 1.5rem), env(safe-area-inset-right));
}

/* Responsive Typography */
h1 {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
}

h2 {
    font-size: clamp(1.25rem, 3.5vw, 2rem);
}

h3 {
    font-size: clamp(1.125rem, 3vw, 1.75rem);
}

h4, h5, h6 {
    font-size: clamp(1rem, 2.5vw, 1.25rem);
}

/* Scrollable Containers - Responsive Height */
div[style*="overflow-y: auto"],
div[style*="overflow-y:auto"] {
    max-height: min(300px, 35vh) !important;
}

/* Badge and Icon Responsive Sizing */
.badge {
    font-size: clamp(0.75rem, 1.5vw, 0.875rem);
    padding: 0.35rem 0.65rem;
}

/* Modal Responsive Padding */
.modal-content {
    padding: clamp(0.5rem, 2vw, 1rem);
}

.modal-header {
    padding: clamp(0.75rem, 1.5vw, 1rem);
}

.modal-body {
    padding: clamp(0.75rem, 1.5vw, 1rem);
}

.modal-footer {
    padding: clamp(0.5rem, 1.5vw, 0.75rem);
}

/* Form Fields Responsive */
.form-label {
    font-size: clamp(0.875rem, 1.5vw, 1rem);
    margin-bottom: clamp(0.25rem, 1vw, 0.5rem);
}

.form-control, .form-select {
    font-size: clamp(0.875rem, 1.5vw, 1rem);
    padding: clamp(0.375rem, 1vw, 0.75rem) clamp(0.5rem, 1.5vw, 1rem);
    border-radius: clamp(0.25rem, 1vw, 0.5rem);
}

/* Button Responsive */
.btn {
    font-size: clamp(0.875rem, 1.5vw, 1rem);
    padding: clamp(0.375rem, 1vw, 0.75rem) clamp(0.75rem, 2vw, 1.5rem);
    border-radius: clamp(0.25rem, 1vw, 0.5rem);
}

.btn-sm {
    font-size: clamp(0.75rem, 1.25vw, 0.875rem);
    padding: clamp(0.25rem, 0.5vw, 0.5rem) clamp(0.5rem, 1.5vw, 1rem);
}

/* Card Responsive Padding */
.card {
    border-radius: clamp(0.5rem, 1.5vw, 1rem);
}

.card-body {
    padding: clamp(0.75rem, 2vw, 1.5rem);
}

/* Circular Elements - Dashboard Icons */
.rounded-circle {
    border-radius: 50% !important;
}

.d-flex.rounded-circle {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Dashboard Icons using ::before pseudo-elements */
.dashboard-icon::before {
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 1.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dashboard-icon-members::before {
    content: '\f0c0';
    color: var(--tec-primary);
}

.dashboard-icon-users::before {
    content: '\f007';
    color: #28a745;
}

.dashboard-icon-categories::before {
    content: '\f07b';
    color: #ffc107;
}

/* =============================================================================
   TABLET & SMALL DEVICES (sm breakpoint)
   ============================================================================= */

@media (min-width: 576px) {
    .container-fluid {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }

    /* Tab Responsive */
    .tab-content {
        padding: clamp(1rem, 2vw, 1.5rem);
    }
}

/* =============================================================================
   TABLET DEVICES (md breakpoint - 768px)
   ============================================================================= */

@media (min-width: 768px) {
    /* Member Detail Header Stack on Tablet */
    .member-detail-header {
        flex-wrap: nowrap;
        align-items: flex-start;
    }

    /* Member Detail Logo Tablet */
    .member-detail-logo {
        width: min(180px, 25vw);
    }

    /* Container Padding Tablet */
    .member-detail-container {
        padding: 1.5rem;
    }

    /* Dashboard Cards - 2 per row on tablet */
    .col-sm-6 {
        flex: 0 0 calc(50% - 0.5rem);
    }

    /* Form Grid on Tablet */
    .col-md-6 {
        flex: 0 0 50%;
    }

    .col-md-4 {
        flex: 0 0 calc(33.3333% - 0.75rem);
    }

    .col-md-5 {
        flex: 0 0 calc(41.6667% - 0.75rem);
    }

    .col-md-7 {
        flex: 0 0 calc(58.3333% - 0.75rem);
    }

    /* Table Responsive Adjustments */
    .table {
        font-size: clamp(0.875rem, 1.25vw, 1rem);
    }

    .table th,
    .table td {
        padding: clamp(0.5rem, 1vw, 0.75rem);
    }

    /* Detail Item Layout on Tablet */
    .member-detail-item {
        justify-content: flex-start;
    }

    .member-detail-label {
        flex: 0 0 auto;
        min-width: auto;
    }
}

/* =============================================================================
   DESKTOP DEVICES (lg breakpoint - 992px)
   ============================================================================= */

@media (min-width: 992px) {
    /* Full width layout */
    .container {
        max-width: 960px;
    }

    .container-lg {
        max-width: 1140px;
    }

    /* Member Detail Container Desktop */
    .member-detail-container {
        padding: 2rem;
    }

    .member-detail-header {
        gap: 2rem;
        align-items: flex-start;
    }

    .member-detail-logo {
        width: 200px;
    }

    /* Dashboard Cards - 3 per row on desktop */
    .col-lg-4 {
        flex: 0 0 calc(33.3333% - 1rem);
    }

    /* Form Columns */
    .col-lg-6 {
        flex: 0 0 50%;
    }

    /* Detail Items */
    .member-detail-item {
        flex-wrap: nowrap;
    }

    .member-detail-label {
        min-width: 100px;
    }
}

/* =============================================================================
   LARGE DESKTOP (xl breakpoint - 1200px)
   ============================================================================= */

@media (min-width: 1200px) {
    .container-xl {
        max-width: 1320px;
    }

    /* Optimal spacing for large screens */
    .member-detail-container {
        padding: 2rem;
    }

    .member-detail-header {
        gap: 2.5rem;
    }
}

/* =============================================================================
   SPECIFIC COMPONENT RESPONSIVE FIXES
   ============================================================================= */

/* Member Detail Components */
@media (max-width: 640px) {
    .member-detail-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 1rem;
    }

    .member-detail-logo {
        width: min(120px, 35vw);
        height: auto;
        padding: 0.75rem;
    }

    .member-detail-info {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

    .member-detail-item {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 1rem;
        width: 100%;
        padding: 0.5rem 0;
        border-bottom: 1px solid #f0f0f0;
    }

    .member-detail-item:last-child {
        border-bottom: none;
    }

    .member-detail-label {
        flex: 0 0 auto;
        font-weight: 600;
        color: var(--tec-text-primary);
    }

    .member-detail-value {
        flex: 1;
        text-align: right;
        color: var(--tec-text-secondary);
    }

    .member-detail-name {
        margin-bottom: 1.5rem !important;
        font-size: clamp(1.125rem, 2.5vw, 1.5rem);
    }

    .member-detail-social-links {
        justify-content: center;
    }
}

/* Dashboard Wrapper - Consistent alignment for all sections */
.dashboard-wrapper {
    padding: 1.5rem 2rem;
    max-width: 100%;
    box-sizing: border-box;
}

@media (min-width: 1200px) {
    .dashboard-wrapper {
        padding: 1.5rem 2.5rem;
    }
}

@media (max-width: 768px) {
    .dashboard-wrapper {
        padding: 1rem 1rem;
    }
}

/* Home Dashboard - Loading Spinner Responsive */
.spinner {
    min-height: clamp(200px, 30vh, 400px) !important;
}

/* Responsive Flex Containers */
@media (max-width: 640px) {
    .d-flex.flex-md-row {
        flex-direction: column !important;
    }

    .flex-column.flex-md-row {
        flex-direction: column !important;
    }

    /* Flex items should take full width on mobile */
    .d-flex.gap-4 > [class*='col-'] {
        width: 100%;
    }

    /* Status icon responsive on mobile */
    [style*="width: min(120px"] {
        width: min(100px, 20vw) !important;
    }
}

/* Responsive Grid System Fixes */
@media (max-width: 576px) {
    /* All columns full width on small mobile */
    [class*='col-'] {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    .col-12 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Tables become scrollable on mobile */
    .table-responsive {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .table {
        margin-bottom: 0;
        width: 100%;
    }

    .table thead,
    .table tbody,
    .table tr {
        display: table;
        width: 100%;
    }

    /* Card stacking on mobile */
    .row.g-4 {
        gap: 1rem !important;
    }

    .row.g-2 {
        gap: 0.5rem !important;
    }

    .row.g-3 {
        gap: 1rem !important;
    }
}

/* =============================================================================
   ACCESSIBILITY & TOUCH OPTIMIZATION
   ============================================================================= */

/* Touch-friendly button sizing */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
        min-width: 44px;
        padding: 0.75rem 1.25rem;
    }

    .btn-sm {
        min-height: 36px;
        min-width: 36px;
    }

    /* Increase clickable area for navigation */
    .nav-item {
        padding: 0.875rem 1rem;
        min-height: 44px;
    }

    /* Increase form input height for mobile */
    .form-control,
    .form-select {
        min-height: 44px;
    }

    /* Larger spacing between list items */
    .list-group-item {
        padding: 1rem;
    }
}

/* =============================================================================
   LANDSCAPE ORIENTATION (Tablets & Phones)
   ============================================================================= */

@media (max-height: 500px) and (orientation: landscape) {
    /* Reduce padding in landscape mode for short screens */
    .member-detail-container {
        padding: 0.75rem;
    }

    .card-body {
        padding: clamp(0.5rem, 1.5vw, 1rem) !important;
    }

    .modal-content {
        max-height: 90vh;
        overflow-y: auto;
    }

    /* Reduce height of loading spinners in landscape */
    .d-flex.justify-content-center.align-items-center[style*="min-height"] {
        min-height: clamp(100px, 20vh, 200px) !important;
    }

    /* Reduce gap in flex containers */
    .gap-4 {
        gap: 0.5rem !important;
    }

    .gap-3 {
        gap: 0.5rem !important;
    }

    .gap-2 {
        gap: 0.25rem !important;
    }
}

/* =============================================================================
   HIGH RESOLUTION DISPLAYS (3x pixel density)
   ============================================================================= */

@media (-webkit-min-device-pixel-ratio: 3), (min-resolution: 3dppx) {
    /* Slightly reduce font sizes on high DPI screens for better readability */
    body {
        -webkit-text-size-adjust: 100%;
    }

    /* SVG icons scale better */
    svg {
        shape-rendering: crispEdges;
    }
}

/* =============================================================================
   PRINT STYLES
   ============================================================================= */

@media print {
    .sidebar,
    .mobile-toggle,
    .btn-outline-primary,
    .btn-danger,
    .btn-outline-secondary,
    .back-button,
    .sidebar-backdrop,
    [role="button"] {
        display: none !important;
    }

    .member-detail-container,
    .card {
        page-break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .member-detail-header {
        page-break-inside: avoid;
    }

    body {
        font-size: 12pt;
        color: #000;
    }

    a {
        text-decoration: underline;
    }

    .member-detail-container {
        padding: 0;
        max-width: 100%;
    }
}

/* =============================================================================
   DARK MODE SUPPORT (Future Enhancement)
   ============================================================================= */

@media (prefers-color-scheme: dark) {
    /* Implement dark mode here when ready */
    /* Currently using light theme only */
}

/* =============================================================================
   REDUCED MOTION (Accessibility)
   ============================================================================= */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .toast-item {
        animation: none !important;
    }

    .member-card {
        transition: none;
    }

    .member-card:hover {
        transform: none;
    }
}

/* =============================================================================
   UTILITY CLASSES FOR RESPONSIVE ADJUSTMENTS
   ============================================================================= */

/* Responsive display utilities */
@media (max-width: 640px) {
    .d-none-mobile {
        display: none !important;
    }

    .d-block-mobile {
        display: block !important;
    }

    .w-100-mobile {
        width:100%;
    }
}

@media (min-width: 641px) and (max-width: 768px) {
    .d-none-tablet {
        display: none !important;
    }

    .d-block-tablet {
        display: block !important;
    }
}

@media (min-width: 769px) {
    .d-none-desktop {
        display: none !important;
    }

    .d-block-desktop {
        display: block !important;
    }
}

/* Responsive spacing utilities */
@media (max-width: 640px) {
    .px-mobile-0 {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .px-mobile-1 {
        padding-left: 0.25rem !important;
        padding-right: 0.25rem !important;
    }

    .px-mobile-2 {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }

    .py-mobile-1 {
        padding-top: 0.25rem !important;
        padding-bottom: 0.25rem !important;
    }

    .py-mobile-2 {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }

    .gap-mobile-1 {
        gap: 0.25rem !important;
    }

    .gap-mobile-2 {
        gap: 0.5rem !important;
    }
}

/* Responsive Button Groups - Stack buttons on mobile */
.btn-group-responsive {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Mobile: 2x2 button layout */
@media (max-width: 640px) {
    .btn-group-responsive .btn {
        flex: 0 1 calc(50% - 0.25rem);
        min-width: 0;
        word-break: break-word;
    }
}

/* Tablet: All buttons in one row with wrap */
@media (min-width: 641px) and (max-width: 768px) {
    .btn-group-responsive .btn {
        flex: 0 1 auto;
        white-space: nowrap;
    }
}

/* Desktop: All buttons in one row */
@media (min-width: 769px) {
    .btn-group-responsive .btn {
        flex: 0 1 auto;
        white-space: nowrap;
    }
}
