/* ========================================================
   LAWNOVUS RESPONSIVE UTILITIES
   Mobile-First Design System - CSS Utilities
   ======================================================== */

/* Base Responsive Typography */
html {
    font-size: 16px;
}

@media (max-width: 640px) {
    html {
        font-size: 14px;
    }
}

/* Safe Area and Padding Utilities */
:root {
    --safe-area-inset-left: 0;
    --safe-area-inset-right: 0;
    --safe-area-inset-top: 0;
    --safe-area-inset-bottom: 0;
}

@supports (padding: max(0px)) {
    body {
        padding-left: max(1rem, var(--safe-area-inset-left));
        padding-right: max(1rem, var(--safe-area-inset-right));
    }
}

/* Mobile-First Container Queries */
.responsive-container {
    width: 100%;
    margin: 0 auto;
    padding: 0 1rem;
}

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

@media (min-width: 1024px) {
    .responsive-container {
        padding: 0 2rem;
        max-width: 1280px;
    }
}

/* Touch-Friendly Button/Link Sizing */
button, 
a, 
[role="button"],
[role="link"] {
    /* Minimum 48px touch target for mobile accessibility */
    min-height: 44px;
    min-width: 44px;
}

@media (min-width: 768px) {
    button,
    a,
    [role="button"],
    [role="link"] {
        min-height: auto;
        min-width: auto;
    }
}

/* Responsive Input Fields */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
textarea,
select {
    /* Always 16px+ font to prevent zoom on iOS */
    font-size: 16px;
    padding: 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb;
    width: 100%;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="tel"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

/* Mobile-Friendly Form Layout */
.form-group {
    margin-bottom: 1.25rem;
}

@media (min-width: 768px) {
    .form-group {
        margin-bottom: 1.5rem;
    }
}

/* Responsive Grid Layout */
.responsive-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

@media (min-width: 640px) {
    .responsive-grid {
        gap: 1.5rem;
    }
}

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

/* Responsive Card Layout */
.card {
    background: white;
    border-radius: 0.75rem;
    border: 1px solid #f3f4f6;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.2s, transform 0.2s;
}

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

.card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

/* Responsive Table Handling */
@media (max-width: 768px) {
    table {
        font-size: 0.875rem;
    }
    
    table tbody td {
        padding: 0.5rem 0.75rem;
    }
    
    table thead th {
        padding: 0.75rem 0.5rem;
    }
    
    /* Hide non-essential columns on mobile */
    table th:nth-child(n+3),
    table td:nth-child(n+3) {
        display: none;
    }
}

/* Responsive Navigation */
.nav-toggle {
    display: none;
}

@media (max-width: 768px) {
    .nav-toggle {
        display: block;
    }
    
    .nav-menu {
        position: fixed;
        left: -100%;
        top: 0;
        flex-direction: column;
        background-color: white;
        width: 100%;
        text-align: center;
        transition: 0.3s;
        box-shadow: 0 10px 27px rgba(0, 0, 0, 0.05);
        z-index: 40;
    }
    
    .nav-menu.active {
        left: 0;
    }
}

/* Responsive Sidebar */
.sidebar {
    width: 100%;
    max-width: 250px;
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        width: 100%;
        height: 100vh;
        transition: left 0.3s;
        z-index: 39;
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s;
        z-index: 38;
    }
    
    .sidebar.open + .sidebar-overlay {
        opacity: 1;
        pointer-events: all;
    }
}

/* Responsive Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 1rem;
}

.modal-content {
    background: white;
    border-radius: 0.75rem;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

@media (max-width: 640px) {
    .modal-content {
        border-radius: 1rem 1rem 0 0;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-width: none;
        max-height: 80vh;
    }
}

/* Responsive Typography Scale */
h1 { font-size: 1.875rem; line-height: 1.2; }
h2 { font-size: 1.5rem; line-height: 1.3; }
h3 { font-size: 1.25rem; line-height: 1.4; }
h4 { font-size: 1.125rem; line-height: 1.4; }
h5 { font-size: 1rem; line-height: 1.5; }
h6 { font-size: 0.875rem; line-height: 1.5; }

@media (max-width: 640px) {
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.125rem; }
    h4 { font-size: 1rem; }
}

/* Image Responsiveness */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Utility Classes for Visibility */
.hide-mobile {
    display: none !important;
}

@media (min-width: 768px) {
    .hide-mobile {
        display: block !important;
    }
}

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

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

/* Scrollbar Styling for Better Mobile UX */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Print Styles */
@media print {
    .hide-print {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.5;
    }
    
    a {
        text-decoration: underline;
    }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .card {
        background: #1f2937;
        border-color: #374151;
        color: #f9fafb;
    }
    
    input[type="text"],
    input[type="email"],
    input[type="password"],
    textarea,
    select {
        background: #ffffff;
        border-color: #d1d5db;
        color: #111827;
    }
}

/* High DPI Screen Adjustments */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    border-width all,
    border-bottom-width,
    border-top-width,
    border-left-width,
    border-right-width {
        border-width: 0.5px;
    }
}
