/* Mobile Responsive CSS for Muhasebe Pro */

/* Touch-friendly buttons (minimum 44px) */
@media (max-width: 768px) {
    button,
    .btn,
    [role="button"],
    input[type="submit"],
    input[type="button"] {
        min-height: 36px;
        font-size: 14px;
    }

    /* Buttons that contain text should have proper padding */
    button:not(.icon-btn):not([class*="w-8"]):not([class*="w-10"]):not([class*="h-8"]):not([class*="h-10"]) {
        padding: 8px 14px;
    }

    /* Touch-friendly form inputs */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    input[type="tel"],
    select,
    textarea {
        min-height: 42px;
        font-size: 16px;
    }

    /* Mobile sidebar - Tailwind translate classes handle open/close */
    .app-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100dvh;
        min-height: -webkit-fill-available;
        width: 280px;
        z-index: 1000;
        box-shadow: 2px 0 10px rgba(0,0,0,0.3);
    }

    /* Mobile overlay */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }

    .sidebar-overlay.show {
        display: block;
    }

    /* Mobile header */
    .mobile-header {
        display: flex !important;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 56px;
        background: #0f172a;
        z-index: 998;
        align-items: center;
        padding: 0 16px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }

    .mobile-menu-btn {
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: white;
        background: transparent;
        border: none;
        font-size: 20px;
        cursor: pointer;
    }

    .mobile-header-title {
        flex: 1;
        text-align: center;
        color: white;
        font-weight: 600;
        font-size: 18px;
    }

    /* Main content adjustment */
    .main-content {
        margin-left: 0 !important;
        padding-top: 70px !important;
        width: 100% !important;
    }

    /* Reduce main content padding on mobile */
    main .flex-1.overflow-auto {
        padding: 12px !important;
    }

    /* Responsive tables - horizontal scroll */
    .overflow-x-auto {
        -webkit-overflow-scrolling: touch;
    }

    .overflow-x-auto > table {
        min-width: max-content;
        width: 100%;
        -webkit-overflow-scrolling: touch;
    }

    /* Dense data tables: safer mobile typography/spacing */
    .data-table-solid th,
    .data-table-solid td {
        padding: 8px 10px !important;
        font-size: 12px !important;
    }
    .data-table-solid th {
        letter-spacing: 0.02em !important;
    }
    .data-table-solid td {
        white-space: normal;
        word-break: break-word;
    }

    /* Cards on mobile */
    .grid-cols-4,
    .md\:grid-cols-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .grid-cols-3,
    .md\:grid-cols-3 {
        grid-template-columns: repeat(1, 1fr) !important;
    }

    /* Modal: full width on mobile, centered vertically */
    .fixed.inset-0.bg-black {
        align-items: flex-end !important;
    }

    .fixed.inset-0.bg-black > div,
    .fixed.inset-0.bg-black\.bg-opacity-50 > div {
        max-width: 100% !important;
        width: 100% !important;
        margin: 0 !important;
        border-radius: 16px 16px 0 0 !important;
        max-height: 90vh;
        overflow-y: auto;
    }

    /* Hide desktop elements */
    .hidden-mobile {
        display: none !important;
    }

    /* Stats cards */
    .stats-card {
        padding: 12px !important;
    }

    .stats-card .text-2xl,
    .stats-card .text-3xl {
        font-size: 1.25rem !important;
    }

    /* Search bar */
    .search-container {
        width: 100% !important;
    }

    /* Action buttons group */
    .action-buttons {
        flex-direction: column;
        gap: 8px;
    }

    .action-buttons button {
        width: 100%;
    }

    /* Dashboard hero image - hide on very small screens */
    .dashboard-hero-img {
        display: none;
    }

    /* Category filter pills - allow wrapping */
    .flex.flex-wrap.gap-2 {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
    }

    /* Chart container on mobile */
    canvas {
        max-height: 200px;
    }

    /* Invoice status dropdown - make larger tap targets */
    .group\/status > div {
        min-width: 140px;
    }

    /* Heading sizes on mobile */
    h2.text-2xl {
        font-size: 1.2rem !important;
    }

    /* Large section paddings compress on mobile */
    .p-6 {
        padding: 1rem !important;
    }

    /* Card text sizes */
    .text-3xl.font-bold {
        font-size: 1.4rem !important;
    }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    .app-sidebar {
        width: 220px;
    }

    .main-content {
        margin-left: 220px;
    }

    .grid-cols-4,
    .md\\:grid-cols-4 {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

/* Large screens */
@media (min-width: 1025px) {
    .mobile-header {
        display: none !important;
    }

    .sidebar-overlay {
        display: none !important;
    }
}

/* Swipe gestures support (visual feedback) */
.swipeable {
    touch-action: pan-x;
}

/* Pull to refresh indicator */
.pull-to-refresh {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(to bottom, #6366f1, transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transform: translateY(-100%);
    transition: transform 0.3s;
    z-index: 1001;
}

.pull-to-refresh.active {
    transform: translateY(0);
}

/* Offline indicator */
.offline-indicator {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px;
    background: #ef4444;
    color: white;
    text-align: center;
    font-weight: 600;
    z-index: 9999;
    display: none;
}

.offline-indicator.show {
    display: block;
}

/* Install PWA banner */
.pwa-install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    z-index: 9999;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
}

.pwa-install-banner button {
    background: white;
    color: #6366f1;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

.pwa-install-banner .dismiss {
    background: transparent;
    color: white;
    opacity: 0.8;
}

/* Safe area insets for notched devices */
@supports (padding: max(0px)) {
    .mobile-header {
        padding-top: max(0px, env(safe-area-inset-top));
        height: calc(56px + max(0px, env(safe-area-inset-top)));
    }

    .main-content {
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
}
