/* 
 * ڕێسپۆنسیڤ CSS - بۆ هەموو لقەکان
 * RTL Mobile-First Responsive Design
 */

/* === تایپۆگرافی ڕێسپۆنسیڤ === */
html {
    font-size: 16px;
}

@media (max-width: 768px) {
    html {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 13px;
    }
}

/* === ناڤبار ڕێسپۆنسیڤ === */
@media (max-width: 991.98px) {
    .navbar {
        padding: 0.75rem 1rem !important;
    }

    .navbar-brand {
        font-size: 1.1rem !important;
    }

    .navbar-collapse {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: inherit;
        padding: 1rem;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
        z-index: 1000;
        border-radius: 0 0 16px 16px;
    }

    .navbar-nav {
        flex-direction: column !important;
    }

    .navbar-nav .nav-item {
        margin-bottom: 0.5rem;
    }

    .navbar-nav .dropdown-menu {
        position: static !important;
        float: none;
        width: 100%;
        margin-top: 0;
        background-color: rgba(255, 255, 255, 0.1);
        border: none;
        box-shadow: none;
    }
}

/* === هیڕۆ سەکشن === */
@media (max-width: 768px) {
    .hero-section {
        padding: 2rem 1.5rem !important;
        border-radius: 16px !important;
    }

    .hero-section h1 {
        font-size: 1.75rem !important;
    }

    .hero-section p {
        font-size: 0.95rem !important;
    }
}

@media (max-width: 480px) {
    .hero-section {
        padding: 1.5rem 1rem !important;
        border-radius: 12px !important;
    }

    .hero-section h1 {
        font-size: 1.5rem !important;
    }
}

/* === ستات کارت === */
@media (max-width: 768px) {
    .stat-card {
        padding: 1rem !important;
        margin-bottom: 1rem;
    }

    .stat-icon {
        width: 50px !important;
        height: 50px !important;
        font-size: 1.25rem !important;
    }

    .stat-number {
        font-size: 1.5rem !important;
    }

    .stat-label {
        font-size: 0.8rem !important;
    }
}

@media (max-width: 480px) {
    .row .col-md-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    .stat-card {
        padding: 0.75rem !important;
    }

    .stat-number {
        font-size: 1.25rem !important;
    }
}

/* === کارتەکان === */
@media (max-width: 768px) {
    .card {
        border-radius: 12px !important;
    }

    .card-header {
        padding: 0.75rem 1rem !important;
        font-size: 0.9rem;
    }

    .card-body {
        padding: 1rem !important;
    }

    .subsidiary-card {
        padding: 1.25rem !important;
    }

    .category-card {
        padding: 1rem !important;
    }

    .category-card .icon {
        font-size: 2rem !important;
    }
}

/* === خشتە ڕێسپۆنسیڤ === */
@media (max-width: 992px) {
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 1rem;
    }

    .table {
        font-size: 0.85rem;
        white-space: nowrap;
    }

    .table th,
    .table td {
        padding: 0.5rem 0.75rem !important;
    }
}

@media (max-width: 768px) {
    .table {
        font-size: 0.8rem;
    }

    .table th,
    .table td {
        padding: 0.4rem 0.5rem !important;
    }

    /* شاردنەوەی ستوونە نەپێویستەکان لە مۆبایل */
    .table .d-none-mobile {
        display: none !important;
    }

    .table .text-truncate-mobile {
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* === خشتەی کارت ستایل - بۆ مۆبایل === */
@media (max-width: 576px) {
    .table-card-mobile tbody tr {
        display: flex;
        flex-wrap: wrap;
        padding: 1rem;
        margin-bottom: 0.75rem;
        background: white;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        border: 1px solid rgba(0, 0, 0, 0.05);
    }

    .table-card-mobile thead {
        display: none;
    }

    .table-card-mobile tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        padding: 0.5rem 0 !important;
        border: none !important;
        border-bottom: 1px solid #f0f0f0 !important;
    }

    .table-card-mobile tbody td:last-child {
        border-bottom: none !important;
    }

    .table-card-mobile tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6b7280;
        text-align: right;
        min-width: 40%;
    }

    .table-card-mobile tbody td:first-child {
        background: linear-gradient(135deg, #f8f9fa, #fff);
        padding: 0.75rem !important;
        border-radius: 8px;
        margin-bottom: 0.5rem;
        border-bottom: none !important;
    }
}

/* === فۆرم ڕێسپۆنسیڤ === */
@media (max-width: 768px) {
    .form-control,
    .form-select {
        font-size: 16px !important; /* بۆ ڕێگری لە زووم لە iOS */
        padding: 0.75rem 1rem !important;
    }

    .btn {
        padding: 0.75rem 1.25rem !important;
        font-size: 0.95rem !important;
    }

    .btn-sm {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.85rem !important;
    }

    .d-flex.gap-2 {
        flex-wrap: wrap;
    }

    .d-flex.gap-2 > * {
        margin-bottom: 0.5rem;
    }
}

@media (max-width: 576px) {
    .d-flex.justify-content-between {
        flex-direction: column;
        gap: 1rem;
    }

    .d-flex.justify-content-between > * {
        width: 100%;
    }

    input[type="date"] {
        width: 100%;
    }

    .btn-group {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .btn-group .btn {
        flex: 1;
    }
}

/* === فووتەر ڕێسپۆنسیڤ === */
@media (max-width: 768px) {
    footer {
        padding: 1rem 0 !important;
        font-size: 0.85rem;
    }

    footer .row {
        text-align: center !important;
    }

    footer .col-md-6 {
        margin-bottom: 0.75rem;
    }

    footer .col-md-6:last-child {
        margin-bottom: 0;
    }
}

/* === مۆدال ڕێسپۆنسیڤ === */
@media (max-width: 576px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    .modal-content {
        border-radius: 16px;
    }

    .modal-header {
        padding: 0.75rem 1rem;
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-footer {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .modal-footer .btn {
        flex: 1;
        min-width: 45%;
    }
}

/* === باجەکان === */
@media (max-width: 576px) {
    .badge {
        font-size: 0.7rem !important;
        padding: 0.35rem 0.5rem !important;
    }
}

/* === ئامێرەکانی خێرا (Quick Actions) === */
@media (max-width: 768px) {
    .quick-actions {
        flex-wrap: wrap;
        gap: 0.75rem !important;
    }

    .quick-actions .btn {
        flex: 1 1 calc(50% - 0.5rem);
        min-width: 120px;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .quick-actions .btn {
        flex: 1 1 100%;
    }
}

/* === کاتی پسووڵە چاپکردن === */
@media (max-width: 576px) {
    .invoice-actions {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        padding: 1rem;
        box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.1);
        z-index: 1000;
        display: flex;
        gap: 0.5rem;
    }

    .invoice-actions .btn {
        flex: 1;
    }
}

/* === ئایکۆن ڕێسپۆنسیڤ === */
@media (max-width: 576px) {
    .bi {
        font-size: 1rem;
    }

    h2 .bi {
        font-size: 1.25rem;
    }
}

/* === ئالێرت و نۆتیفیکەیشن === */
@media (max-width: 576px) {
    .alert {
        padding: 0.75rem 1rem !important;
        font-size: 0.85rem;
        border-radius: 12px !important;
    }
}

/* === لۆدینگ و ئێمپتی ستەیت === */
@media (max-width: 576px) {
    .text-center.py-5 {
        padding: 2rem 0 !important;
    }

    .text-center.py-5 i {
        font-size: 2.5rem !important;
    }

    .text-center.py-5 p {
        font-size: 0.9rem;
    }
}

/* === درۆپداون === */
@media (max-width: 768px) {
    .dropdown-menu {
        position: fixed !important;
        bottom: 0;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        transform: none !important;
        border-radius: 16px 16px 0 0 !important;
        max-height: 70vh;
        overflow-y: auto;
        padding: 1rem;
    }

    .dropdown-item {
        padding: 0.75rem 1rem;
        border-radius: 8px;
        margin-bottom: 0.25rem;
    }

    .dropdown-item:hover {
        background-color: #f8f9fa;
    }
}

/* === سپینەر === */
@media (max-width: 576px) {
    .spinner-border {
        width: 1.5rem;
        height: 1.5rem;
    }
}

/* === سکرۆڵبار === */
@media (max-width: 768px) {
    ::-webkit-scrollbar {
        width: 4px;
        height: 4px;
    }

    ::-webkit-scrollbar-thumb {
        border-radius: 10px;
        background: rgba(0, 0, 0, 0.2);
    }
}

/* === تەچ فرەندلی === */
@media (hover: none) and (pointer: coarse) {
    /* مۆبایل تەچ دیڤایس */
    .btn:hover,
    .nav-link:hover,
    .card:hover,
    .stat-card:hover,
    .category-card:hover {
        transform: none !important;
    }

    /* گەورەکردنی تاچ تارگێتەکان */
    .btn,
    .nav-link,
    .form-control,
    .form-select,
    .dropdown-item {
        min-height: 44px;
    }
}

/* === پانتوم ڕێسپۆنسیڤ (Breakpoints) === */

/* گەورە (lg) - ١٩٩٢ بۆ سەرەوە */
@media (min-width: 992px) {
    .container {
        max-width: 960px;
    }
}

/* گەورەتر (xl) - ١٢٠٠ بۆ سەرەوە */
@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }
}

/* گەورەترین (xxl) - ١٤٠٠ بۆ سەرەوە */
@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
    }
}

/* === پڕینت === */
@media print {
    body {
        font-size: 12pt;
    }

    .navbar,
    .quick-actions,
    footer,
    .btn:not(.btn-print),
    .invoice-actions {
        display: none !important;
    }

    .card {
        border: 1px solid #ddd !important;
        box-shadow: none !important;
    }

    .table {
        font-size: 10pt;
    }
}

/* === لەند سکەیپ مۆد === */
@media (max-width: 768px) and (orientation: landscape) {
    .hero-section {
        padding: 1.5rem !important;
    }

    .row .col-md-3 {
        flex: 0 0 25%;
        max-width: 25%;
    }

    .stat-card {
        padding: 0.75rem !important;
    }
}

/* === سەیف ئەریا بۆ نۆچ (iOS) === */
@supports (padding-top: env(safe-area-inset-top)) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    .navbar {
        padding-top: calc(0.5rem + env(safe-area-inset-top));
    }

    footer {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    }

    .invoice-actions {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    }
}

/* === هەڵپەستانی RTL === */
@media (max-width: 768px) {
    [dir="rtl"] .text-md-start {
        text-align: center !important;
    }

    [dir="rtl"] .me-2,
    [dir="rtl"] .ms-2 {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    [dir="rtl"] .d-flex {
        flex-direction: column;
    }

    [dir="rtl"] .d-flex.flex-row-mobile {
        flex-direction: row;
    }
}

