/**
 * Responsive Design Improvements
 * Bookkeeper.io - Mobile & Tablet Optimizations
 */

/* Tablet Breakpoint (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    /* Adjust grid columns for tablets */
    .grid.md\:grid-cols-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    
    /* Table overflow handling */
    .overflow-x-auto {
        -webkit-overflow-scrolling: touch;
    }
}

/* Desktop: Force hide mobile menu toggle */
@media (min-width: 769px) {
    .mobile-menu-toggle {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }
}

/* Mobile Breakpoint (< 768px) */
@media (max-width: 768px) {
    /* Main content area */
    .sidenav-content {
        margin-left: 0 !important;
        padding: 1rem;
    }
    
    /* Mobile typography adjustments */
    h1 {
        font-size: 1.875rem; /* 30px */
    }
    
    h2 {
        font-size: 1.5rem; /* 24px */
    }
    
    h3 {
        font-size: 1.25rem; /* 20px */
    }
    
    /* Stat cards - larger text for better readability */
    .text-3xl {
        font-size: 2rem;
    }
    
    /* Card padding reduction */
    .p-6 {
        padding: 1rem;
    }
    
    /* Period selector - stack vertically */
    .period-btn {
        flex: 1;
        min-width: calc(50% - 0.5rem);
    }
    
    /* Hide custom date range on very small screens */
    @media (max-width: 640px) {
        .period-btn {
            font-size: 0.75rem;
            padding: 0.5rem 0.75rem;
        }
    }
}

/* Small Mobile Breakpoint (< 640px) */
@media (max-width: 640px) {
    /* Even smaller padding */
    .sidenav-content {
        padding: 0.75rem;
    }
    
    /* Adjust gap in grids */
    .gap-6 {
        gap: 1rem;
    }
    
    .gap-4 {
        gap: 0.75rem;
    }
    
    /* Button sizes */
    button, .btn, a.btn {
        min-height: 44px;
        padding: 0.75rem 1rem;
    }
    
    /* Form inputs */
    input, select, textarea {
        min-height: 44px;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }
    
    /* Tables - better mobile handling */
    table {
        font-size: 0.875rem;
    }
    
    td, th {
        padding: 0.5rem !important;
    }
    
    /* Hide non-essential table columns */
    .hide-on-mobile {
        display: none;
    }
    
    /* Stack action buttons vertically */
    .flex.gap-2 {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    /* Modal adjustments */
    .modal-content {
        max-width: 95vw;
        margin: 1rem;
    }
    
    /* Chart containers */
    #revenueChart,
    #profitChart,
    #customersChart,
    #suppliersChart {
        min-height: 250px;
    }
}

/* Touch-friendly elements */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets */
    a, button, input[type="checkbox"], input[type="radio"] {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Better spacing for touch */
    .sidenav-item,
    .sidenav-subitem {
        padding: 0.75rem 1rem;
    }
    
    /* Remove hover states (they stick on mobile) */
    *:hover {
        transition: none;
    }
}

/* Landscape mode adjustments */
@media (max-width: 900px) and (orientation: landscape) {
    /* Reduce vertical spacing in landscape */
    .mb-6 {
        margin-bottom: 1rem;
    }
    
    .mb-8 {
        margin-bottom: 1.5rem;
    }
    
    /* Compact header */
    h1 {
        margin-bottom: 0.5rem;
    }
}

/* Print styles */
@media print {
    .sidenav,
    .mobile-menu-toggle,
    .sidenav-overlay,
    button,
    .no-print {
        display: none !important;
    }
    
    .sidenav-content {
        margin-left: 0 !important;
    }
    
    body {
        font-size: 12pt;
    }
    
    h1 {
        font-size: 18pt;
    }
    
    h2 {
        font-size: 16pt;
    }
    
    h3 {
        font-size: 14pt;
    }
}

/* Accessibility improvements */
@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-neutral-200 {
        border-color: #000;
        border-width: 2px;
    }
    
    .text-neutral-600 {
        color: #000;
    }
    
    button,
    .btn {
        border: 2px solid currentColor;
    }
}

/* Dark mode readiness (for future) */
@media (prefers-color-scheme: dark) {
    /* Currently forcing light mode, but structure is ready for dark mode */
}

/* =================================
   RESPONSIVE TABLE UTILITIES
   ================================= */

/* Amount cells - never wrap */
.amount-cell,
.whitespace-nowrap {
    white-space: nowrap !important;
}

/* Tabular numbers for better alignment */
.amount-cell,
.font-mono {
    font-variant-numeric: tabular-nums;
}

/* Responsive table base */
.responsive-table {
    width: 100%;
    border-collapse: collapse;
}

.responsive-table th,
.responsive-table td {
    transition: padding 0.15s ease;
}

/* Compact table cells on mobile */
@media (max-width: 640px) {
    .responsive-table th,
    .responsive-table td {
        padding: 0.5rem 0.25rem !important;
        font-size: 0.75rem;
    }
    
    .responsive-table th:first-child,
    .responsive-table td:first-child {
        padding-left: 0.5rem !important;
    }
    
    .responsive-table th:last-child,
    .responsive-table td:last-child {
        padding-right: 0.5rem !important;
    }
}

/* =================================
   STATUS INDICATORS
   ================================= */

/* Status dots for mobile view */
.status-dot {
    display: inline-block;
    width: 0.625rem;  /* 10px */
    height: 0.625rem; /* 10px */
    border-radius: 9999px;
    vertical-align: middle;
}

.status-dot.open,
.status-dot.warning {
    background-color: var(--warning-500, #f59e0b);
}

.status-dot.betaald,
.status-dot.success {
    background-color: var(--success-500, #22c55e);
}

.status-dot.vervallen,
.status-dot.danger {
    background-color: var(--danger-500, #ef4444);
}

/* Type indicator dots */
.type-dot {
    display: inline-block;
    width: 0.5rem;  /* 8px */
    height: 0.5rem; /* 8px */
    border-radius: 9999px;
    flex-shrink: 0;
}

.type-dot.kosten {
    background-color: var(--danger-500, #ef4444);
}

.type-dot.opbrengst {
    background-color: var(--success-500, #22c55e);
}

.type-dot.activa {
    background-color: var(--info-500, #3b82f6);
}

.type-dot.passiva {
    background-color: #a855f7; /* purple-500 */
}

/* =================================
   MOBILE BUTTON STYLING
   ================================= */

/* Touch-friendly buttons on mobile */
.btn-mobile {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1rem;
}

/* Icon-only buttons on mobile */
@media (max-width: 640px) {
    .btn-icon-mobile {
        padding: 0.5rem;
        font-size: 1rem;
    }
    
    .btn-icon-mobile span {
        display: none;
    }
}

/* =================================
   TRUNCATION UTILITIES
   ================================= */

/* Text truncation with ellipsis */
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Multi-line truncation (2 lines) */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* =================================
   COLLAPSIBLE FILTERS
   ================================= */

/* Filter toggle animation */
#filterContent {
    transition: max-height 0.3s ease, opacity 0.2s ease;
}

#filterContent.hidden {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
}

#filterArrow {
    transition: transform 0.2s ease;
}

#filterArrow.fa-chevron-up {
    transform: rotate(180deg);
}

/* =================================
   MODAL RESPONSIVE ADJUSTMENTS
   ================================= */

@media (max-width: 768px) {
    /* Stack modal content vertically on mobile */
    .modal-split-view {
        flex-direction: column;
    }
    
    .modal-split-view > div {
        width: 100% !important;
    }
    
    /* Reduce PDF preview height on mobile */
    .modal-pdf-preview {
        height: 40vh;
        min-height: 250px;
    }
}
