/* Enhanced Responsive Improvements for VCM System */

/* ===== CRITICAL MOBILE TABLE FIXES ===== */

/* Enhanced Table Responsiveness */
.enhanced-table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

@media (max-width: 768px) {
    /* Convert tables to card layout on mobile */
    .mobile-table-cards table,
    .mobile-table-cards thead,
    .mobile-table-cards tbody,
    .mobile-table-cards th,
    .mobile-table-cards td,
    .mobile-table-cards tr {
        display: block;
    }
    
    .mobile-table-cards thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    
    .mobile-table-cards tr {
        background: white;
        border: 1px solid #e5e7eb;
        border-radius: 0.75rem;
        padding: 1rem;
        margin-bottom: 1rem;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    
    .mobile-table-cards td {
        border: none;
        padding: 0.75rem 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid #f3f4f6;
        font-size: 0.875rem;
    }
    
    .mobile-table-cards td:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }
    
    .mobile-table-cards td:before {
        content: attr(data-label);
        font-weight: 600;
        color: #6b7280;
        font-size: 0.8125rem;
        text-transform: uppercase;
        letter-spacing: 0.025em;
        flex-shrink: 0;
        margin-right: 1rem;
        min-width: 100px;
    }
}

/* ===== ENHANCED FORM RESPONSIVENESS ===== */

/* Mobile-first form improvements */
@media (max-width: 640px) {
    .enhanced-form {
        padding: 1rem;
        width: 100%;
        max-width: none;
    }
    
    .enhanced-form .form-group {
        margin-bottom: 1.5rem;
    }
    
    .enhanced-form input,
    .enhanced-form textarea,
    .enhanced-form select {
        font-size: 16px !important; /* Prevent iOS zoom */
        padding: 1rem;
        width: 100%;
        border-radius: 0.75rem;
        border: 2px solid #e5e7eb;
        transition: all 0.2s ease;
    }
    
    .enhanced-form input:focus,
    .enhanced-form textarea:focus,
    .enhanced-form select:focus {
        border-color: #dc2626;
        box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
        outline: none;
    }
    
    .enhanced-form button {
        width: 100%;
        padding: 1rem;
        font-size: 1rem;
        font-weight: 600;
        border-radius: 0.75rem;
        min-height: 48px;
        touch-action: manipulation;
    }
    
    .enhanced-form .form-row {
        flex-direction: column;
        gap: 1rem;
    }
    
    .enhanced-form .form-row > * {
        width: 100%;
    }
    
    /* Enhanced mobile checkbox styling */
    .enhanced-form input[type="checkbox"],
    .enhanced-form input[type="radio"] {
        width: 20px !important;
        height: 20px !important;
        margin-right: 12px !important;
        cursor: pointer !important;
        border-radius: 4px !important;
        border: 2px solid #d1d5db !important;
        background-color: white !important;
        transition: all 0.2s ease !important;
        flex-shrink: 0 !important;
    }
    
    .enhanced-form input[type="checkbox"]:checked,
    .enhanced-form input[type="radio"]:checked {
        background-color: #dc2626 !important;
        border-color: #dc2626 !important;
    }
    
    .enhanced-form input[type="checkbox"]:focus,
    .enhanced-form input[type="radio"]:focus {
        outline: none !important;
        box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2) !important;
    }
    
    /* Enhanced mobile checkbox/radio labels */
    .enhanced-form label:has(input[type="checkbox"]),
    .enhanced-form label:has(input[type="radio"]) {
        padding: 12px 8px !important;
        margin: -12px -8px !important;
        border-radius: 8px !important;
        transition: background-color 0.2s ease !important;
        min-height: 48px !important;
        display: flex !important;
        align-items: center !important;
        cursor: pointer !important;
        -webkit-tap-highlight-color: transparent !important;
    }
    
    .enhanced-form label:has(input[type="checkbox"]):hover,
    .enhanced-form label:has(input[type="radio"]):hover {
        background-color: rgba(220, 38, 38, 0.05) !important;
    }
    
    .enhanced-form label:has(input[type="checkbox"]):active,
    .enhanced-form label:has(input[type="radio"]):active {
        background-color: rgba(220, 38, 38, 0.1) !important;
        transform: scale(0.98) !important;
    }
}

/* ===== ENHANCED MODAL RESPONSIVENESS ===== */

@media (max-width: 640px) {
    .enhanced-modal {
        margin: 0;
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
        width: 100%;
        max-width: 100%;
    }
    
    .enhanced-modal .modal-content {
        height: 100%;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        display: flex;
        flex-direction: column;
    }
    
    .enhanced-modal .modal-header {
        padding: 1.5rem 1rem 1rem;
        border-bottom: 1px solid #e5e7eb;
        flex-shrink: 0;
        position: sticky;
        top: 0;
        background: white;
        z-index: 10;
    }
    
    .enhanced-modal .modal-body {
        padding: 1rem;
        flex: 1;
        overflow-y: auto;
    }
    
    .enhanced-modal .modal-footer {
        padding: 1rem;
        border-top: 1px solid #e5e7eb;
        flex-shrink: 0;
        position: sticky;
        bottom: 0;
        background: white;
    }
    
    .enhanced-modal .modal-footer .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .enhanced-modal .modal-footer .btn:last-child {
        margin-bottom: 0;
    }
}

/* ===== ENHANCED GRID SYSTEMS ===== */

/* Responsive grid with better breakpoints */
.enhanced-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
}

@media (min-width: 480px) {
    .enhanced-grid-2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 768px) {
    .enhanced-grid-3 {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .enhanced-grid-4 {
        grid-template-columns: repeat(4, 1fr);
        gap: 2rem;
    }
}

@media (min-width: 1280px) {
    .enhanced-grid-5 {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* ===== ENHANCED CARD RESPONSIVENESS ===== */

.enhanced-card {
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    overflow: hidden;
}

.enhanced-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

@media (max-width: 640px) {
    .enhanced-card {
        margin-bottom: 1rem;
        border-radius: 0.5rem;
    }
    
    .enhanced-card .card-header {
        padding: 1rem;
        border-bottom: 1px solid #f3f4f6;
    }
    
    .enhanced-card .card-body {
        padding: 1rem;
    }
    
    .enhanced-card .card-footer {
        padding: 1rem;
        border-top: 1px solid #f3f4f6;
        background: #f9fafb;
    }
}

/* ===== ENHANCED NAVIGATION RESPONSIVENESS ===== */

/* Better mobile navigation spacing */
@media (max-width: 1023px) {
    .enhanced-nav-mobile {
        padding: 0.75rem 1rem;
    }
    
    .enhanced-nav-mobile .nav-item {
        padding: 0.875rem 1rem;
        min-height: 48px;
        display: flex;
        align-items: center;
        font-size: 0.9rem;
        border-radius: 0.5rem;
        margin-bottom: 0.25rem;
        transition: all 0.2s ease;
    }
    
    .enhanced-nav-mobile .nav-item:hover {
        background: rgba(220, 38, 38, 0.05);
        transform: translateX(4px);
    }
    
    .enhanced-nav-mobile .nav-item.active {
        background: rgba(220, 38, 38, 0.1);
        color: #dc2626;
        font-weight: 600;
    }
    
    .enhanced-nav-mobile .nav-dropdown {
        margin: 0.25rem 0;
    }
    
    .enhanced-nav-mobile .nav-dropdown-content {
        background: #f8f9fa;
        border-radius: 0.5rem;
        margin: 0.5rem 0;
        padding: 0.5rem 0;
        border-left: 3px solid #dc2626;
    }
    
    .enhanced-nav-mobile .nav-dropdown-item {
        padding: 0.75rem 1rem 0.75rem 2rem;
        font-size: 0.85rem;
        color: #6b7280;
        border-radius: 0.375rem;
        margin: 0.125rem 0.5rem;
        transition: all 0.2s ease;
    }
    
    .enhanced-nav-mobile .nav-dropdown-item:hover {
        background: white;
        color: #dc2626;
        transform: translateX(4px);
    }
}

/* ===== ENHANCED BUTTON RESPONSIVENESS ===== */

.enhanced-btn {
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    touch-action: manipulation;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    border: none;
    cursor: pointer;
}

.enhanced-btn:active {
    transform: scale(0.98);
}

@media (max-width: 640px) {
    .enhanced-btn-mobile {
        width: 100%;
        padding: 1rem;
        font-size: 1rem;
        border-radius: 0.75rem;
        margin-bottom: 0.5rem;
    }
    
    .enhanced-btn-group-mobile {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .enhanced-btn-group-mobile .enhanced-btn {
        width: 100%;
    }
}

/* ===== ENHANCED TYPOGRAPHY RESPONSIVENESS ===== */

.enhanced-text-responsive {
    line-height: 1.6;
    word-break: break-word;
    hyphens: auto;
}

.enhanced-heading-1 {
    font-size: 2rem;
    line-height: 1.2;
    font-weight: 800;
    margin-bottom: 1rem;
}

@media (min-width: 640px) {
    .enhanced-heading-1 {
        font-size: 2.5rem;
    }
}

@media (min-width: 768px) {
    .enhanced-heading-1 {
        font-size: 3rem;
    }
}

@media (min-width: 1024px) {
    .enhanced-heading-1 {
        font-size: 3.75rem;
    }
}

.enhanced-heading-2 {
    font-size: 1.5rem;
    line-height: 1.3;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

@media (min-width: 640px) {
    .enhanced-heading-2 {
        font-size: 1.875rem;
    }
}

@media (min-width: 768px) {
    .enhanced-heading-2 {
        font-size: 2.25rem;
    }
}

.enhanced-body-text {
    font-size: 0.875rem;
    line-height: 1.6;
}

@media (min-width: 640px) {
    .enhanced-body-text {
        font-size: 1rem;
    }
}

/* ===== ENHANCED SPACING SYSTEM ===== */

@media (max-width: 640px) {
    .enhanced-container-mobile {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .enhanced-section-mobile {
        padding-top: 2rem;
        padding-bottom: 2rem;
    }
    
    .enhanced-gap-mobile {
        gap: 1rem;
    }
}

@media (min-width: 641px) and (max-width: 1023px) {
    .enhanced-container-tablet {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
    
    .enhanced-section-tablet {
        padding-top: 3rem;
        padding-bottom: 3rem;
    }
    
    .enhanced-gap-tablet {
        gap: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .enhanced-container-desktop {
        padding-left: 2rem;
        padding-right: 2rem;
    }
    
    .enhanced-section-desktop {
        padding-top: 4rem;
        padding-bottom: 4rem;
    }
    
    .enhanced-gap-desktop {
        gap: 2rem;
    }
}

/* ===== ENHANCED ACCESSIBILITY ===== */

/* Focus improvements */
.enhanced-focus:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-radius: 0.25rem;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .enhanced-card {
        border: 2px solid #000;
    }
    
    .enhanced-btn {
        border: 2px solid currentColor;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .enhanced-card,
    .enhanced-btn,
    .enhanced-nav-mobile .nav-item {
        transition: none !important;
        animation: none !important;
    }
}

/* ===== ENHANCED PERFORMANCE OPTIMIZATIONS ===== */

.enhanced-performance {
    will-change: transform;
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.enhanced-smooth-scroll {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

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

@media print {
    .enhanced-no-print {
        display: none !important;
    }
    
    .enhanced-print-full {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border-radius: 0 !important;
    }
    
    .enhanced-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

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

.enhanced-loading {
    position: relative;
    overflow: hidden;
}

.enhanced-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: loading-shimmer 1.5s infinite;
}

@keyframes loading-shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

.enhanced-spinner {
    width: 2rem;
    height: 2rem;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #dc2626;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== ENHANCED UTILITY CLASSES ===== */

/* Visibility utilities */
.enhanced-mobile-only {
    display: block;
}

@media (min-width: 768px) {
    .enhanced-mobile-only {
        display: none;
    }
}

.enhanced-desktop-only {
    display: none;
}

@media (min-width: 768px) {
    .enhanced-desktop-only {
        display: block;
    }
}

/* Spacing utilities */
.enhanced-space-y-mobile > * + * {
    margin-top: 1rem;
}

@media (min-width: 768px) {
    .enhanced-space-y-desktop > * + * {
        margin-top: 1.5rem;
    }
}

/* Text utilities */
.enhanced-text-center-mobile {
    text-align: center;
}

@media (min-width: 768px) {
    .enhanced-text-left-desktop {
        text-align: left;
    }
}

/* Flexbox utilities */
.enhanced-flex-mobile {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

@media (min-width: 768px) {
    .enhanced-flex-desktop {
        flex-direction: row;
        gap: 1.5rem;
    }
}

/* ===== ENHANCED MOBILE CHECKBOX UTILITIES ===== */

/* Mobile-optimized checkbox styling */
.mobile-checkbox {
    width: 20px !important;
    height: 20px !important;
    margin-right: 12px !important;
    cursor: pointer !important;
    border-radius: 4px !important;
    border: 2px solid #d1d5db !important;
    background-color: white !important;
    transition: all 0.2s ease !important;
    flex-shrink: 0 !important;
}

.mobile-checkbox:checked {
    background-color: #dc2626 !important;
    border-color: #dc2626 !important;
}

.mobile-checkbox:focus {
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2) !important;
}

/* Mobile-optimized checkbox label */
.mobile-checkbox-label {
    padding: 12px 8px !important;
    margin: -12px -8px !important;
    border-radius: 8px !important;
    transition: all 0.2s ease !important;
    min-height: 48px !important;
    display: flex !important;
    align-items: center !important;
    cursor: pointer !important;
    -webkit-tap-highlight-color: transparent !important;
    user-select: none !important;
}

.mobile-checkbox-label:hover {
    background-color: rgba(220, 38, 38, 0.05) !important;
}

.mobile-checkbox-label:active {
    background-color: rgba(220, 38, 38, 0.1) !important;
    transform: scale(0.98) !important;
}

/* Mobile form section utilities */
.mobile-form-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: stretch;
}

@media (min-width: 768px) {
    .mobile-form-section {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}

/* Mobile link button styling */
.mobile-link-button {
    padding: 12px !important;
    border-radius: 8px !important;
    background-color: rgba(220, 38, 38, 0.05) !important;
    border: 1px solid rgba(220, 38, 38, 0.2) !important;
    text-decoration: none !important;
    transition: all 0.2s ease !important;
    min-height: 48px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-weight: 600 !important;
    text-align: center !important;
    -webkit-tap-highlight-color: transparent !important;
}

.mobile-link-button:hover {
    background-color: rgba(220, 38, 38, 0.1) !important;
    border-color: rgba(220, 38, 38, 0.3) !important;
}

.mobile-link-button:active {
    transform: scale(0.98) !important;
}