/**
 * LiraCore Responsive Styles
 * Mobile-first responsive design for all screen sizes
 */

/* ==========================================================================
   Base Responsive Setup
   ========================================================================== */

* {
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    overflow-x: hidden;
}

/* ==========================================================================
   Responsive Typography
   ========================================================================== */

/* Mobile: Smaller text */
@media (max-width: 640px) {
    html {
        font-size: 14px;
    }

    h1, .h1 {
        font-size: 1.75rem !important;
        line-height: 2rem !important;
    }

    h2, .h2 {
        font-size: 1.5rem !important;
        line-height: 1.75rem !important;
    }

    h3, .h3 {
        font-size: 1.25rem !important;
        line-height: 1.5rem !important;
    }

    .page-title {
        font-size: 1.25rem !important;
        line-height: 1.75rem !important;
    }
}

/* Tablet: Medium text */
@media (min-width: 641px) and (max-width: 1024px) {
    html {
        font-size: 15px;
    }
}

/* ==========================================================================
   Responsive Layout
   ========================================================================== */

/* Container max-widths */
.container-responsive {
    width: 100%;
    padding-left: 1rem;
    padding-right: 1rem;
    margin-left: auto;
    margin-right: auto;
}

@media (min-width: 640px) {
    .container-responsive {
        max-width: 640px;
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

@media (min-width: 768px) {
    .container-responsive {
        max-width: 768px;
    }
}

@media (min-width: 1024px) {
    .container-responsive {
        max-width: 1024px;
    }
}

@media (min-width: 1280px) {
    .container-responsive {
        max-width: 1280px;
    }
}

/* ==========================================================================
   Responsive Grid System
   ========================================================================== */

.grid-responsive {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
}

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

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

    .grid-responsive-md-3 {
        grid-template-columns: repeat(3, 1fr);
    }
}

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

    .grid-responsive-lg-3 {
        grid-template-columns: repeat(3, 1fr);
    }

    .grid-responsive-lg-4 {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ==========================================================================
   Responsive Tables
   ========================================================================== */

@media (max-width: 768px) {
    /* Stack tables on mobile */
    .table-responsive {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-responsive table {
        min-width: 600px;
    }

    /* Card-style tables for mobile */
    .table-card-mobile thead {
        display: none;
    }

    .table-card-mobile tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid #e5e7eb;
        border-radius: 0.5rem;
        padding: 1rem;
        background: white;
    }

    .table-card-mobile td {
        display: flex;
        justify-content: space-between;
        padding: 0.5rem 0;
        border-bottom: 1px solid #f3f4f6;
    }

    .table-card-mobile td:last-child {
        border-bottom: none;
    }

    .table-card-mobile td::before {
        content: attr(data-label);
        font-weight: 600;
        margin-right: 1rem;
    }
}

/* ==========================================================================
   Responsive Cards
   ========================================================================== */

.card-responsive {
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 1rem;
}

@media (min-width: 768px) {
    .card-responsive {
        padding: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .card-responsive {
        padding: 2rem;
    }
}

/* ==========================================================================
   Responsive Buttons
   ========================================================================== */

.btn-responsive {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

@media (min-width: 768px) {
    .btn-responsive {
        padding: 0.625rem 1.25rem;
        font-size: 1rem;
    }
}

/* Mobile: Full-width buttons */
@media (max-width: 640px) {
    .btn-full-mobile {
        width: 100%;
        justify-content: center;
    }
}

/* ==========================================================================
   Responsive Forms
   ========================================================================== */

@media (max-width: 640px) {
    .form-responsive input,
    .form-responsive select,
    .form-responsive textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .form-group-responsive {
        margin-bottom: 1rem;
    }

    .form-label-responsive {
        display: block;
        margin-bottom: 0.5rem;
    }
}

/* ==========================================================================
   Responsive Navigation
   ========================================================================== */

.nav-responsive {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

@media (min-width: 1024px) {
    .nav-responsive {
        flex-direction: row;
        align-items: center;
    }
}

/* ==========================================================================
   Responsive Spacing
   ========================================================================== */

/* Mobile: Reduced spacing */
@media (max-width: 640px) {
    .spacing-responsive {
        padding: 1rem;
    }

    .spacing-y-responsive {
        padding-top: 1rem;
        padding-bottom: 1rem;
    }

    .spacing-x-responsive {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* Tablet: Medium spacing */
@media (min-width: 641px) and (max-width: 1024px) {
    .spacing-responsive {
        padding: 1.5rem;
    }

    .spacing-y-responsive {
        padding-top: 1.5rem;
        padding-bottom: 1.5rem;
    }

    .spacing-x-responsive {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

/* Desktop: Full spacing */
@media (min-width: 1025px) {
    .spacing-responsive {
        padding: 2rem;
    }

    .spacing-y-responsive {
        padding-top: 2rem;
        padding-bottom: 2rem;
    }

    .spacing-x-responsive {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

/* ==========================================================================
   Responsive Images
   ========================================================================== */

.img-responsive {
    max-width: 100%;
    height: auto;
    display: block;
}

.img-responsive-cover {
    width: 100%;
    height: auto;
    object-fit: cover;
}

/* ==========================================================================
   Responsive Modal/Dialog
   ========================================================================== */

@media (max-width: 640px) {
    .modal-responsive {
        width: 95% !important;
        margin: 1rem auto !important;
        max-height: 90vh;
        overflow-y: auto;
    }

    .modal-responsive .modal-content {
        padding: 1rem !important;
    }
}

@media (min-width: 641px) and (max-width: 1024px) {
    .modal-responsive {
        width: 80% !important;
        max-width: 600px;
    }
}

/* ==========================================================================
   Responsive Sidebar
   ========================================================================== */

@media (max-width: 1023px) {
    .sidebar-responsive {
        position: fixed !important;
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        z-index: 40;
    }

    .sidebar-responsive.active {
        transform: translateX(0);
    }

    .main-content-responsive {
        margin-left: 0 !important;
    }
}

@media (min-width: 1024px) {
    .sidebar-responsive {
        position: fixed !important;
        transform: translateX(0);
    }

    .main-content-responsive {
        margin-left: 16rem; /* 256px for w-64 sidebar */
    }
}

/* ==========================================================================
   Responsive Charts
   ========================================================================== */

.chart-responsive {
    position: relative;
    height: 250px;
    width: 100%;
}

@media (min-width: 768px) {
    .chart-responsive {
        height: 300px;
    }
}

@media (min-width: 1024px) {
    .chart-responsive {
        height: 400px;
    }
}

/* ==========================================================================
   Responsive Stats Cards
   ========================================================================== */

.stat-card-responsive {
    padding: 1rem;
    text-align: center;
}

@media (min-width: 768px) {
    .stat-card-responsive {
        padding: 1.5rem;
        text-align: left;
    }
}

/* ==========================================================================
   Responsive Utilities
   ========================================================================== */

/* Hide on mobile */
@media (max-width: 640px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Hide on tablet */
@media (min-width: 641px) and (max-width: 1024px) {
    .hide-tablet {
        display: none !important;
    }
}

/* Hide on desktop */
@media (min-width: 1025px) {
    .hide-desktop {
        display: none !important;
    }
}

/* Show only on mobile */
.show-mobile {
    display: block !important;
}

@media (min-width: 641px) {
    .show-mobile {
        display: none !important;
    }
}

/* Show only on tablet */
.show-tablet {
    display: none !important;
}

@media (min-width: 641px) and (max-width: 1024px) {
    .show-tablet {
        display: block !important;
    }
}

/* Show only on desktop */
.show-desktop {
    display: none !important;
}

@media (min-width: 1025px) {
    .show-desktop {
        display: block !important;
    }
}

/* ==========================================================================
   Responsive Text Alignment
   ========================================================================== */

@media (max-width: 640px) {
    .text-center-mobile {
        text-align: center !important;
    }
}

/* ==========================================================================
   Responsive Flexbox
   ========================================================================== */

.flex-responsive {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

@media (min-width: 768px) {
    .flex-responsive {
        flex-direction: row;
        align-items: center;
    }
}

/* ==========================================================================
   Touch-Friendly Interactions
   ========================================================================== */

@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets for mobile */
    .touch-target {
        min-height: 44px;
        min-width: 44px;
        padding: 0.75rem !important;
    }

    /* Remove hover effects on touch devices */
    .no-touch-hover:hover {
        background-color: inherit !important;
        color: inherit !important;
    }
}

/* ==========================================================================
   Responsive Code Blocks
   ========================================================================== */

@media (max-width: 640px) {
    pre, code {
        font-size: 0.75rem !important;
        overflow-x: auto;
        word-wrap: break-word;
        white-space: pre-wrap;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .no-print {
        display: none !important;
    }

    body {
        font-size: 12pt;
        line-height: 1.5;
    }

    .sidebar-responsive,
    .mobile-menu-btn,
    button,
    .no-print {
        display: none !important;
    }

    .main-content-responsive {
        margin-left: 0 !important;
    }
}

/* ==========================================================================
   Landscape Orientation Fixes
   ========================================================================== */

@media screen and (max-height: 500px) and (orientation: landscape) {
    .modal-responsive {
        max-height: 80vh;
        overflow-y: auto;
    }

    .sidebar-responsive {
        overflow-y: auto;
    }
}

/* ==========================================================================
   Accessibility Enhancements
   ========================================================================== */

/* Focus visible for keyboard navigation */
*:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    * {
        border-width: 2px !important;
    }
}
