/* 
 * Responsive Design خاص بصفحة الأدوية
 * Medicines Page Responsive Design
 */

/* ===== MEDICINES HERO RESPONSIVE ===== */
.medicines-hero {
    padding: calc(var(--dynamic-header-height) + 60px) 0 60px;
    background-attachment: fixed;
    margin-top: 0.25rem;
}

.medicines-hero-content h1 {
    font-size: 3.5rem;
    margin-bottom: 20px;
}

.medicines-hero-content p {
    font-size: 1.3rem;
    margin-bottom: 30px;
}

@media (max-width: 1200px) {
    .medicines-hero-content h1 {
        font-size: 3rem;
    }
}

@media (max-width: 992px) {
    .medicines-hero {
        padding: 100px 0 50px;
        background-attachment: scroll;
    }
    
    .medicines-hero-content h1 {
        font-size: 2.5rem;
    }
    
    .medicines-hero-content p {
        font-size: 1.2rem;
    }
}

@media (max-width: 768px) {
    .medicines-hero {
        padding: 80px 0 40px;
    }
    
    .medicines-hero-content h1 {
        font-size: 2rem;
        margin-bottom: 15px;
    }
    
    .medicines-hero-content p {
        font-size: 1.1rem;
        margin-bottom: 25px;
    }
}

@media (max-width: 576px) {
    .medicines-hero {
        padding: 60px 0 30px;
    }
    
    .medicines-hero-content h1 {
        font-size: 1.8rem;
        margin-bottom: 10px;
    }
    
    .medicines-hero-content p {
        font-size: 1rem;
        margin-bottom: 20px;
    }
}

/* ===== MEDICINES CATALOG RESPONSIVE ===== */
.catalog-container {
    display: flex;
    gap: 30px;
    margin-top: 0.25rem;
    /* No padding-top needed - body padding handles header offset */
}

.filters-sidebar {
    flex: 0 0 280px;
    background: #ffffff;
    border-radius: 15px;
    padding: 25px;
    height: fit-content;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    position: sticky;
    top: calc(var(--dynamic-header-height) + 0.5rem);
    scroll-margin-top: calc(var(--dynamic-header-height) + 8px);
}

.medicines-content {
    flex: 1;
}

/* Mobile offcanvas support */
@media (max-width: 991.98px) {
    .mobile-filter-toggle {
        display: flex !important;
    }
    
    .filters-sidebar {
        order: 1 !important;
    }
    
    .medicines-content {
        order: 2 !important;
    }
    
    /* Offcanvas positioning for mobile - uses dynamic header height */
    .offcanvas-filters {
        top: var(--dynamic-header-height) !important;
        height: calc(100dvh - var(--dynamic-header-height)) !important;
        z-index: 1025 !important;
        margin-top: 0 !important;
        transform: translateX(-100%) !important;
    }
    
    .offcanvas-filters.show {
        transform: translateX(0) !important;
    }
    
    .offcanvas-backdrop {
        top: var(--dynamic-header-height) !important;
        height: calc(100dvh - var(--dynamic-header-height)) !important;
        z-index: 1020 !important;
    }
    
    .offcanvas-backdrop.show {
        top: var(--dynamic-header-height) !important;
        height: calc(100dvh - var(--dynamic-header-height)) !important;
    }
    
    /* Force all offcanvas elements below header */
    .offcanvas-start {
        top: var(--dynamic-header-height) !important;
        height: calc(100dvh - var(--dynamic-header-height)) !important;
        margin-top: 0 !important;
    }
}

@media (max-width: 1200px) {
    .filters-sidebar {
        flex: 0 0 250px;
        padding: 20px;
    }
}

@media (max-width: 992px) {
    .catalog-container {
        flex-direction: column;
        gap: 20px;
    }
    
    .filters-sidebar {
        flex: none;
        position: static;
        order: 1;
    }
    
    .medicines-content {
        order: 2;
    }
}

@media (max-width: 768px) {
    .catalog-container {
        gap: 15px;
        margin-top: 20px;
    }
    
    .filters-sidebar {
        padding: 15px;
        border-radius: 10px;
        order: 1;
        margin-bottom: 10px;
    }
    
    .medicines-content {
        order: 2;
    }
}

@media (max-width: 576px) {
    .filters-sidebar {
        padding: 12px;
        margin-bottom: 15px;
        order: 1;
    }
    
    .medicines-content {
        order: 2;
    }
    
    /* تحسين الفلترة للموبايل الصغير */
    .filter-section {
        margin-bottom: 12px;
    }
    
    .filter-title {
        font-size: 0.9rem;
        margin-bottom: 8px;
        text-align: center;
        padding: 8px;
        background: #f8f9fa;
        border-radius: 8px;
        cursor: pointer;
        position: relative;
    }
    
    .filter-title::after {
        content: '▼';
        position: absolute;
        right: 10px;
        top: 50%;
        transform: translateY(-50%);
        font-size: 0.8rem;
        transition: transform 0.3s ease;
    }
    
    .filter-section.collapsed .filter-title::after {
        transform: translateY(-50%) rotate(-90deg);
    }
    
    .filter-section.collapsed .filter-options {
        display: none;
    }
}

/* ===== MEDICINE CARDS RESPONSIVE ===== */
.medicines-grid {
    margin-bottom: 40px;
    scroll-margin-top: calc(var(--header-h) + 8px);
}

/* Bootstrap responsive grid support */
.medicines-grid .row {
    margin: 0;
}

.medicines-grid .col-12,
.medicines-grid .col-sm-6,
.medicines-grid .col-md-4,
.medicines-grid .col-lg-4,
.medicines-grid .col-xl-3 {
    padding: 0;
    margin-bottom: 1.5rem;
}

@media (min-width: 576px) {
    .medicines-grid .col-sm-6 {
        padding-right: 0.75rem;
        padding-left: 0.75rem;
    }
}

@media (min-width: 768px) {
    .medicines-grid .col-md-4 {
        padding-right: 0.75rem;
        padding-left: 0.75rem;
    }
}

@media (min-width: 992px) {
    .medicines-grid .col-lg-4 {
        padding-right: 0.75rem;
        padding-left: 0.75rem;
    }
}

@media (min-width: 1200px) {
    .medicines-grid .col-xl-3 {
        padding-right: 0.75rem;
        padding-left: 0.75rem;
    }
}

.medicine-card {
    background: #ffffff;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    transition: all 0.4s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 450px;
    scroll-margin-top: calc(var(--header-h) + 8px);
}

.medicine-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.15);
}

.medicine-image-container {
    position: relative;
    height: 200px;
    overflow: hidden;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    flex-shrink: 0;
}

.medicine-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 15px;
    transition: transform 0.4s ease;
}

.medicine-card:hover .medicine-image {
    transform: scale(1.05);
}

.medicine-info {
    padding: 25px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.medicine-name {
    font-size: 1.4rem;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 10px;
    line-height: 1.3;
}

.medicine-description {
    color: #6c757d;
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 15px;
    flex: 1;
}

.medicine-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-top: 15px;
    border-top: 1px solid #f1f3f4;
}

.medicine-category {
    background: linear-gradient(135deg, #0B8A42, #00A884);
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.medicine-price {
    font-size: 1.2rem;
    font-weight: 700;
    color: #0B8A42;
}

.medicine-actions {
    display: flex;
    gap: 10px;
}

.btn-view-details {
    flex: 1;
    background: linear-gradient(135deg, #0B8A42, #00A884);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-view-details:hover {
    background: linear-gradient(135deg, #0a7a3a, #009975);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(11, 138, 66, 0.3);
}

/* Medicine Cards Responsive */
@media (max-width: 1199.98px) {
    .medicine-image-container {
        height: 200px;
    }
    
    .medicine-info {
        padding: 20px;
    }
    
    .medicine-name {
        font-size: 1.3rem;
    }
}

@media (max-width: 991.98px) {
    .medicine-image-container {
        height: 180px;
    }
    
    .medicine-info {
        padding: 18px;
    }
    
    .medicine-name {
        font-size: 1.2rem;
    }
    
    .medicine-description {
        font-size: 0.9rem;
    }
}

@media (max-width: 767.98px) {
    .medicines-grid {
        margin-bottom: 30px;
    }
    
    .medicine-card {
        border-radius: 15px;
    }
    
    .medicine-image-container {
        height: 160px;
    }
    
    .medicine-info {
        padding: 15px;
    }
    
    .medicine-name {
        font-size: 1.1rem;
        margin-bottom: 8px;
    }
    
    .medicine-description {
        font-size: 0.85rem;
        margin-bottom: 12px;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    .medicine-meta {
        margin-bottom: 15px;
        padding-top: 12px;
    }
    
    .medicine-category {
        font-size: 0.75rem;
        padding: 4px 10px;
    }
    
    .medicine-price {
        font-size: 1.1rem;
    }
    
    .btn-view-details {
        padding: 10px 15px;
        font-size: 0.85rem;
    }
}

@media (max-width: 575.98px) {
    .medicines-grid {
        margin-bottom: 25px;
    }
    
    .medicines-grid .col-12 {
        margin-bottom: 1rem;
    }
    
    .medicine-card {
        border-radius: 12px;
        margin: 0;
    }
    
    .medicine-image-container {
        height: 140px;
    }
    
    .medicine-info {
        padding: 12px;
    }
    
    .medicine-name {
        font-size: 1rem;
        margin-bottom: 6px;
    }
    
    .medicine-description {
        font-size: 0.8rem;
        margin-bottom: 10px;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    .medicine-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        margin-bottom: 12px;
        padding-top: 10px;
    }
    
    .medicine-category {
        font-size: 0.7rem;
        padding: 3px 8px;
    }
    
    .medicine-price {
        font-size: 1rem;
        align-self: flex-end;
    }
    
    .btn-view-details {
        padding: 8px 12px;
        font-size: 0.8rem;
        border-radius: 8px;
    }
}

/* ===== FILTERS RESPONSIVE ===== */
.filter-section {
    margin-bottom: 25px;
}

.filter-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid #f1f3f4;
}

.filter-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-option {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.filter-option:hover {
    background: #f8f9fa;
}

.filter-option input[type="checkbox"],
.filter-option input[type="radio"] {
    margin-right: 10px;
    margin-left: 0;
}

.filter-option label {
    flex: 1;
    cursor: pointer;
    font-size: 0.9rem;
    color: #495057;
}

@media (max-width: 992px) {
    .filters-sidebar {
        background: #f8f9fa;
        border-radius: 10px;
        padding: 20px;
    }
    
    .filter-section {
        margin-bottom: 20px;
    }
    
    .filter-title {
        font-size: 1rem;
        margin-bottom: 12px;
    }
    
    .filter-options {
        gap: 6px;
    }
    
    .filter-option {
        padding: 6px 10px;
    }
    
    .filter-option label {
        font-size: 0.85rem;
    }
}

@media (max-width: 768px) {
    .filter-section {
        margin-bottom: 15px;
    }
    
    .filter-title {
        font-size: 0.95rem;
        margin-bottom: 10px;
    }
    
    .filter-options {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .filter-option {
        flex: 0 0 auto;
        background: white;
        border: 1px solid #dee2e6;
        border-radius: 20px;
        padding: 6px 12px;
    }
    
    .filter-option input {
        display: none;
    }
    
    .filter-option label {
        font-size: 0.8rem;
        margin: 0;
    }
    
    .filter-option:has(input:checked) {
        background: #0B8A42;
        color: white;
        border-color: #0B8A42;
    }
    
    .filter-option:has(input:checked) label {
        color: white;
    }
}

@media (max-width: 576px) {
    .filter-options {
        gap: 6px;
    }
    
    .filter-option {
        padding: 5px 10px;
        border-radius: 15px;
    }
    
    .filter-option label {
        font-size: 0.75rem;
    }
}

/* ===== SEARCH BAR RESPONSIVE ===== */
.search-container {
    background: white;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

.search-form {
    display: flex;
    gap: 15px;
    align-items: end;
}

.search-input-group {
    flex: 1;
}

.search-input {
    width: 100%;
    padding: 12px 20px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.search-input:focus {
    border-color: #0B8A42;
    box-shadow: 0 0 0 0.2rem rgba(11, 138, 66, 0.25);
    outline: none;
}

.search-btn {
    background: linear-gradient(135deg, #0B8A42, #00A884);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 10px;
    font-weight: 600;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.search-btn:hover {
    background: linear-gradient(135deg, #0a7a3a, #009975);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(11, 138, 66, 0.3);
}

@media (max-width: 768px) {
    .search-container {
        padding: 20px;
        margin-bottom: 25px;
        border-radius: 12px;
    }
    
    .search-form {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    
    .search-input {
        padding: 10px 15px;
        font-size: 0.95rem;
    }
    
    .search-btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
}

@media (max-width: 576px) {
    .search-container {
        padding: 15px;
        margin-bottom: 20px;
        border-radius: 10px;
    }
    
    .search-form {
        gap: 10px;
    }
    
    .search-input {
        padding: 8px 12px;
        font-size: 0.9rem;
        border-radius: 8px;
    }
    
    .search-btn {
        padding: 8px 15px;
        font-size: 0.85rem;
        border-radius: 8px;
    }
}

/* ===== PAGINATION RESPONSIVE ===== */
.pagination-wrapper {
    display: flex;
    justify-content: center;
    margin-top: 40px;
    padding: 0 15px;
    scroll-margin-top: calc(var(--header-h) + 20px);
}

.medicines-pagination {
    display: flex;
    justify-content: center;
    margin-top: 40px;
}

.pagination {
    display: flex;
    list-style: none;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    margin: 0;
    padding: 0;
}

.page-item {
    margin: 0;
}

.page-item .page-link {
    padding: 12px 16px;
    color: #6c757d;
    background: white;
    border: 1px solid #dee2e6;
    transition: all 0.3s ease;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    font-weight: 500;
}

.page-item.active .page-link {
    background: #0B8A42;
    border-color: #0B8A42;
    color: white;
    font-weight: 600;
}

.page-item:hover:not(.disabled) .page-link {
    background: #f8f9fa;
    color: #0B8A42;
    border-color: #0B8A42;
}

.page-item.disabled .page-link {
    color: #6c757d;
    background: #f8f9fa;
    border-color: #dee2e6;
    cursor: not-allowed;
    opacity: 0.6;
}

@media (max-width: 768px) {
    .pagination-wrapper {
        margin-top: 30px;
        padding: 0 10px;
    }
    
    .medicines-pagination {
        margin-top: 30px;
    }
    
    .page-item .page-link {
        padding: 10px 12px;
        font-size: 0.9rem;
        min-width: 40px;
        min-height: 40px;
    }
}

@media (max-width: 576px) {
    .pagination-wrapper {
        margin-top: 25px;
        overflow-x: auto;
        padding: 0 5px;
        -webkit-overflow-scrolling: touch;
    }
    
    .medicines-pagination {
        margin-top: 25px;
        overflow-x: auto;
        padding: 0 10px;
        -webkit-overflow-scrolling: touch;
    }
    
    .pagination {
        min-width: max-content;
        white-space: nowrap;
        flex-wrap: nowrap;
    }
    
    .page-item {
        flex-shrink: 0;
    }
    
    .page-item .page-link {
        padding: 8px 10px;
        font-size: 0.85rem;
        min-width: 36px;
        min-height: 36px;
        white-space: nowrap;
    }
    
    /* Improve touch targets for mobile */
    .page-item .page-link:active {
        background: #0B8A42;
        color: white;
        transform: scale(0.95);
    }
    
    /* Hide some pagination items on very small screens but keep navigation functional */
    .page-item:not(.active):not(:first-child):not(:last-child):not(:nth-child(2)):not(:nth-last-child(2)) .page-link {
        padding: 8px 6px;
        min-width: 32px;
    }
}

/* ===== MODAL RESPONSIVE (Medicine Details) ===== */
.medicine-modal .modal-dialog {
    max-width: 900px;
    margin: 2rem auto;
}

.medicine-modal .modal-content {
    border-radius: 20px;
    overflow: hidden;
}

.medicine-modal .modal-header {
    background: linear-gradient(135deg, #0B8A42, #00A884);
    color: white;
    padding: 20px 25px;
}

.medicine-modal .modal-title {
    font-size: 1.4rem;
    font-weight: 700;
}

.medicine-modal .modal-body {
    padding: 30px;
}

.medicine-modal-image {
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 20px;
    background: #f8f9fa;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.medicine-modal-image img {
    max-width: 100%;
    max-height: 200px;
    object-fit: contain;
}

.medicine-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}

.detail-item {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
}

.detail-label {
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 5px;
    font-size: 0.9rem;
}

.detail-value {
    color: #6c757d;
    font-size: 0.95rem;
    line-height: 1.5;
}

@media (max-width: 992px) {
    .medicine-modal .modal-dialog {
        max-width: 90%;
        margin: 1.5rem auto;
    }
    
    .medicine-modal .modal-body {
        padding: 25px;
    }
    
    .medicine-details-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

@media (max-width: 768px) {
    .medicine-modal .modal-dialog {
        max-width: 95%;
        margin: 1rem;
    }
    
    .medicine-modal .modal-header {
        padding: 15px 20px;
    }
    
    .medicine-modal .modal-title {
        font-size: 1.2rem;
    }
    
    .medicine-modal .modal-body {
        padding: 20px;
    }
    
    .medicine-modal-image {
        min-height: 150px;
        margin-bottom: 15px;
    }
    
    .medicine-modal-image img {
        max-height: 150px;
    }
    
    .medicine-details-grid {
        gap: 12px;
        margin-top: 15px;
    }
    
    .detail-item {
        padding: 12px;
    }
    
    .detail-label {
        font-size: 0.85rem;
    }
    
    .detail-value {
        font-size: 0.9rem;
    }
}

@media (max-width: 576px) {
    .medicine-modal .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .medicine-modal .modal-header {
        padding: 12px 15px;
    }
    
    .medicine-modal .modal-title {
        font-size: 1.1rem;
    }
    
    .medicine-modal .modal-body {
        padding: 15px;
    }
    
    .medicine-modal-image {
        min-height: 120px;
        margin-bottom: 12px;
        border-radius: 10px;
    }
    
    .medicine-modal-image img {
        max-height: 120px;
    }
    
    .medicine-details-grid {
        gap: 10px;
        margin-top: 12px;
    }
    
    .detail-item {
        padding: 10px;
        border-radius: 8px;
    }
    
    .detail-label {
        font-size: 0.8rem;
        margin-bottom: 3px;
    }
    
    .detail-value {
        font-size: 0.85rem;
    }
    
    .medicine-modal .modal-footer {
        padding: 12px 15px;
        flex-direction: column;
    }
    
    .medicine-modal .modal-footer .btn {
        width: 100%;
        margin: 0.25rem 0;
    }
}

/* ===== RTL RESPONSIVE FIXES ===== */
@media (max-width: 768px) {
    /* إصلاح ترتيب العناصر للعربية - الفلترة فوق والأدوية تحت */
    body[dir="rtl"] .catalog-container,
    body.arabic-layout .catalog-container,
    [dir="rtl"] .catalog-container {
        flex-direction: column !important;
    }
    
    body[dir="rtl"] .filters-sidebar,
    body.arabic-layout .filters-sidebar,
    [dir="rtl"] .filters-sidebar {
        order: 1 !important;
        margin-bottom: 15px;
    }
    
    body[dir="rtl"] .medicines-content,
    body.arabic-layout .medicines-content,
    [dir="rtl"] .medicines-content {
        order: 2 !important;
    }
    
    body[dir="rtl"] .filter-option input {
        margin-right: 0;
        margin-left: 10px;
    }
    
    body[dir="rtl"] .medicine-meta {
        flex-direction: row-reverse;
    }
    
    body[dir="rtl"] .search-form {
        text-align: right;
    }
    
    body[dir="rtl"] .filter-title::after {
        right: auto;
        left: 10px;
    }
}

/* ===== LOADING STATES ===== */
.medicines-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
}

.medicine-card-skeleton {
    background: #f8f9fa;
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 20px;
}

.skeleton-image {
    height: 200px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 10px;
    margin-bottom: 15px;
}

.skeleton-text {
    height: 20px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 10px;
}

.skeleton-text.short {
    width: 60%;
}

.skeleton-text.medium {
    width: 80%;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@media (max-width: 576px) {
    .skeleton-image {
        height: 140px;
    }
    
    .skeleton-text {
        height: 16px;
    }
}
