/* =============================================================================
   MOBILE RESPONSIVE STYLES - KPI & PORTFOLIO TIZIMI
   Version 2.1 - Cleaned & Optimized 3-Variant Support
   ============================================================================= */

/* =============================================================================
   BREAKPOINTS STRATEGIYASI:
   - Mobile:  ≤ 640px  (sm)
   - Tablet:  641-1024px (md)
   - Desktop: > 1024px (lg)
   ============================================================================= */

/* =============================================================================
   MOBILE VARIANT (≤ 640px) - Smartfonlar
   ============================================================================= */

@media (max-width: 640px) {
    /* ===== HEADER TEXT SIZES ===== */
    .page-title, .section-title {
        font-size: 1.5rem !important;
    }

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

    h3.text-xl, h3.text-2xl {
        font-size: 1.125rem !important;
    }

    /* ===== TABLE RESPONSIVE ===== */
    .hide-on-mobile {
        display: none !important;
    }

    .show-on-mobile {
        display: block !important;
    }

    .table-responsive {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 1rem;
    }

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

    /* Mobile card format for tables */
    .mobile-card {
        background: white;
        border-radius: 0.5rem;
        padding: 1rem;
        margin-bottom: 1rem;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }

    .mobile-card-header {
        font-weight: 600;
        font-size: 1.125rem;
        margin-bottom: 0.75rem;
        color: #1f2937;
        padding-bottom: 0.75rem;
        border-bottom: 2px solid #e5e7eb;
    }

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

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

    .mobile-card-label {
        font-weight: 500;
        color: #6b7280;
        font-size: 0.875rem;
    }

    .mobile-card-value {
        font-weight: 600;
        color: #111827;
        font-size: 0.875rem;
        text-align: right;
    }

    /* ===== STATISTICS CARDS - 2 COLUMNS ===== */
    .stats-grid,
    .grid.grid-cols-1.md\:grid-cols-3.lg\:grid-cols-6 {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem !important;
    }

    .stats-grid.stats-grid-single {
        grid-template-columns: 1fr !important;
    }

    .stats-grid > div,
    .grid.grid-cols-1.md\:grid-cols-3.lg\:grid-cols-6 > div {
        padding: 0.75rem !important;
    }

    .stats-grid p:first-child,
    .grid.grid-cols-1.md\:grid-cols-3.lg\:grid-cols-6 p:first-child {
        font-size: 0.65rem !important;
    }

    .stats-grid p.text-2xl,
    .grid.grid-cols-1.md\:grid-cols-3.lg\:grid-cols-6 p.text-2xl {
        font-size: 1.25rem !important;
    }

    .stats-grid i.text-xl,
    .grid.grid-cols-1.md\:grid-cols-3.lg\:grid-cols-6 i.text-xl {
        font-size: 1rem !important;
    }

    .stats-grid .w-12,
    .grid.grid-cols-1.md\:grid-cols-3.lg\:grid-cols-6 .w-12 {
        width: 2rem !important;
        height: 2rem !important;
    }

    /* ===== DASHBOARD CARDS ===== */
    .grid.grid-cols-1.md\:grid-cols-3 {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

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

    /* ===== WELCOME BANNERS ===== */
    .bg-gradient-to-r.from-green-500,
    .bg-gradient-to-r.from-blue-500 {
        padding: 1.5rem !important;
    }

    .bg-gradient-to-r h2 {
        font-size: 1.5rem !important;
    }

    .bg-gradient-to-r p {
        font-size: 0.875rem !important;
    }

    .hidden.md\:block {
        display: none !important;
    }

    /* ===== PAGE HEADERS - PREVENT OVERFLOW ===== */
    .flex.justify-between.items-center {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1rem;
    }

    .flex.justify-between.items-center > div:last-child {
        width: 100%;
    }

    .flex.justify-between.items-center a,
    .flex.justify-between.items-center button {
        width: 100% !important;
        justify-content: center !important;
    }

    /* ===== FILTERS - VERTICAL STACK ===== */
    .filter-section,
    form.grid.grid-cols-1.md\:grid-cols-3 {
        grid-template-columns: 1fr !important;
        flex-direction: column !important;
    }

    .filter-section > div {
        width: 100% !important;
        margin-bottom: 0.75rem !important;
    }

    .filter-buttons,
    .flex.items-end {
        flex-direction: column !important;
        width: 100%;
        align-items: stretch !important;
    }

    .filter-buttons button,
    .filter-buttons a,
    .flex.items-end button,
    .flex.items-end a {
        width: 100% !important;
        margin-bottom: 0.5rem !important;
        margin-right: 0 !important;
    }

    /* ===== FORMS ===== */
    form .grid {
        grid-template-columns: 1fr !important;
    }

    .input-group-mobile {
        flex-direction: column !important;
    }

    .input-group-mobile > * {
        width: 100% !important;
        margin-bottom: 0.5rem;
    }

    select, input[type="text"], input[type="email"], input[type="date"], textarea {
        font-size: 16px !important; /* Prevent iOS zoom */
    }

    input[type="file"] {
        font-size: 14px !important;
    }

    .mobile-btn-full {
        width: 100% !important;
        justify-content: center !important;
    }

    /* ===== PROFILE TABS ===== */
    nav.flex.overflow-x-auto {
        -webkit-overflow-scrolling: touch;
    }

    nav.flex.overflow-x-auto button {
        padding: 1rem 0.75rem !important;
        font-size: 0.75rem !important;
        white-space: nowrap;
    }

    nav.flex.overflow-x-auto button i {
        font-size: 0.875rem !important;
        margin-right: 0.25rem !important;
    }

    /* ===== PORTFOLIO CARDS ===== */
    .card-horizontal {
        flex-direction: column !important;
    }

    .card-horizontal-img {
        width: 100% !important;
        height: 200px !important;
        object-fit: cover;
    }

    .card-horizontal-body {
        padding: 1.5rem !important;
    }

    .card-horizontal-body h5 {
        font-size: 1.5rem !important;
    }

    /* ===== ALERT MESSAGES ===== */
    .flex.items-center.p-4 {
        padding: 0.75rem !important;
    }

    .flex.items-center.p-4 svg {
        width: 1.25rem !important;
        height: 1.25rem !important;
    }

    /* ===== KPI SUBMISSION CARDS ===== */
    .space-y-4 > div {
        padding: 1rem !important;
    }

    .space-y-4 .flex.items-center.gap-2 {
        flex-wrap: wrap;
        gap: 0.5rem !important;
    }

    /* ===== CONTAINER SPACING ===== */
    .py-8,
    .py-12 {
        padding-top: 1.5rem !important;
        padding-bottom: 1.5rem !important;
    }

    .px-4,
    .px-6,
    .px-8 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    .mb-6,
    .mb-8 {
        margin-bottom: 1.5rem !important;
    }

    .max-w-7xl,
    .max-w-6xl,
    .max-w-5xl {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    /* ===== MODALS ===== */
    .modal-mobile-full {
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }

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

    /* ===== CHARTS ===== */
    .chart-container {
        height: 250px !important;
        margin-bottom: 1.5rem;
    }

    canvas {
        max-height: 250px !important;
    }

    /* ===== BADGES ===== */
    .badge, .status-badge {
        font-size: 0.75rem !important;
        padding: 0.25rem 0.5rem !important;
    }

    .badge i, .status-badge i {
        font-size: 0.75rem !important;
    }

    /* ===== PAGINATION ===== */
    .pagination .hidden {
        display: none !important;
    }

    .pagination nav {
        justify-content: center !important;
    }

    .pagination a,
    .pagination span {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.875rem !important;
    }

    /* ===== SIDEBAR ===== */
    .sidebar-mobile {
        position: fixed;
        top: 0;
        left: -100%;
        width: 80%;
        max-width: 300px;
        height: 100vh;
        background: white;
        z-index: 9999;
        transition: left 0.3s ease-in-out;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    }

    .sidebar-mobile.active {
        left: 0;
    }

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

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

    /* ===== TABS ===== */
    .tabs-mobile {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        display: flex;
        flex-wrap: nowrap;
    }

    .tabs-mobile button {
        flex-shrink: 0;
        padding: 0.75rem 1rem !important;
        font-size: 0.875rem !important;
    }

    .tabs-mobile .tab-text {
        display: none;
    }

    .tabs-mobile .tab-icon {
        display: inline-block;
        margin-right: 0 !important;
    }

    /* ===== IMAGES ===== */
    img {
        max-width: 100%;
        height: auto;
    }

    .image-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem !important;
    }

    /* ===== UTILITY CLASSES ===== */
    .sm\:hidden {
        display: none !important;
    }

    .sm\:block {
        display: block !important;
    }

    .sm\:flex {
        display: flex !important;
    }

    .sm\:grid {
        display: grid !important;
    }

    /* ===== TEXT UTILITIES ===== */
    .mobile-truncate {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mobile-line-clamp-2 {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .mobile-line-clamp-3 {
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    /* ===== SPACING UTILITIES ===== */
    .mobile-mt-2 { margin-top: 0.5rem !important; }
    .mobile-mb-2 { margin-bottom: 0.5rem !important; }
    .mobile-mt-4 { margin-top: 1rem !important; }
    .mobile-mb-4 { margin-bottom: 1rem !important; }
    .mobile-space-y-2 > * + * { margin-top: 0.5rem !important; }
    .mobile-space-y-4 > * + * { margin-top: 1rem !important; }

    /* ===== BUTTON & FLEX UTILITIES ===== */
    .button-group-mobile {
        flex-direction: column !important;
        width: 100%;
    }

    .button-group-mobile > * {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .flex-mobile-stack {
        flex-direction: column !important;
        align-items: flex-start !important;
    }

    .flex-mobile-stack > * {
        width: 100%;
        margin-bottom: 0.75rem;
    }

    .mobile-px-2 {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }

    .mobile-py-2 {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }

    .mobile-p-2 {
        padding: 0.5rem !important;
    }
}

/* =============================================================================
   TABLET VARIANT (641-1024px) - iPad, Surface
   ============================================================================= */

@media (min-width: 641px) and (max-width: 1024px) {
    /* ===== TABLE RESPONSIVE ===== */
    .table-responsive {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 1rem;
    }

    .table-responsive table {
        min-width: 100%;
        font-size: 0.875rem;
    }

    .table-responsive th,
    .table-responsive td {
        padding: 0.5rem !important;
    }

    /* ===== STATISTICS CARDS - 3 COLUMNS ===== */
    .grid.grid-cols-1.md\:grid-cols-3.lg\:grid-cols-6 {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 1rem !important;
    }

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

    .stats-grid > div,
    .grid.grid-cols-1.md\:grid-cols-3.lg\:grid-cols-6 > div {
        padding: 1rem !important;
    }

    .stats-grid p.text-2xl,
    .grid.grid-cols-1.md\:grid-cols-3.lg\:grid-cols-6 p.text-2xl {
        font-size: 1.75rem !important;
    }

    /* ===== DASHBOARD CARDS - 2 COLUMNS ===== */
    .grid.grid-cols-1.md\:grid-cols-3:not(.grid-cols-1.md\:grid-cols-3.lg\:grid-cols-6) {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1.5rem !important;
    }

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

    /* ===== WELCOME BANNERS ===== */
    .bg-gradient-to-r.from-green-500,
    .bg-gradient-to-r.from-blue-500 {
        padding: 2rem !important;
    }

    .bg-gradient-to-r h2 {
        font-size: 2rem !important;
    }

    /* ===== PAGE HEADERS ===== */
    .flex.justify-between.items-center a,
    .flex.justify-between.items-center button {
        padding: 0.5rem 1rem !important;
        font-size: 0.875rem !important;
    }

    .flex.justify-between.items-center h1 {
        font-size: 1.5rem !important;
    }

    /* ===== FILTERS ===== */
    .filter-section > div {
        margin-bottom: 0.5rem;
    }

    .filter-buttons button,
    .filter-buttons a {
        padding: 0.5rem 1rem !important;
        font-size: 0.875rem !important;
    }

    /* ===== PROFILE TABS ===== */
    nav.flex.overflow-x-auto button {
        padding: 1rem 1.25rem !important;
        font-size: 0.875rem !important;
    }

    /* ===== PORTFOLIO CARDS ===== */
    .card-horizontal-body h5 {
        font-size: 2rem !important;
    }

    /* ===== CONTAINER SPACING ===== */
    .py-12 {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }
}

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

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

    .print-break {
        page-break-after: always;
    }
}
