/* Mobile Responsive Styles for Shabestar - Based on kashan.ir patterns */

/* ============================================
   MOBILE FIRST - ULTRA SMALL DEVICES (< 320px)
   ============================================ */
@media screen and (max-width: 319px) {
    body {
        font-size: 12px;
    }
    
    .container-fluid,
    .container {
        padding: 0;
    }
    
    .row {
        margin-right: 0;
        margin-left: 0;
    }
    
    [class*="col-"] {
        padding-right: 0;
        padding-left: 0;
    }
}

/* ============================================
   SMALL MOBILE DEVICES (320px - 480px)
   ============================================ */
@media screen and (min-width: 320px) and (max-width: 480px) {
    html {
        font-size: 13px;
    }
    
    body {
        font-size: 13px;
        overflow-x: hidden;
        background-color: #f8f9fa;
    }
    
    /* Header Adjustments */
    header.Masai-header {
        padding: 8px 0;
        background-color: #fff;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
        border-bottom: 1px solid #e9ecef;
    }
    
    header.Masai-header .logo-area {
        -ms-flex: 0 0 100px;
        flex: 0 0 100px;
        max-width: 100px;
        padding-right: 8px;
    }
    
    header.Masai-header .logo-area a img {
        width: 100%;
        height: auto;
    }
    
    header.Masai-header .search-area form.search {
        display: none;
    }
    
    /* Navigation */
    nav.navbar {
        padding: 0 !important;
        background: linear-gradient(135deg, #00386B 0%, #004B8C 100%);
    }
    
    .navbar-collapse {
        padding: 0 !important;
    }
    
    .nav-link {
        font-size: 12px !important;
        padding: 10px 8px !important;
        margin: 0;
        color: white !important;
        border-radius: 4px;
        transition: all 0.3s ease;
    }
    
    .nav-link:hover {
        background-color: rgba(255, 255, 255, 0.1);
        color: #E7B553 !important;
        transform: translateY(-2px);
    }
    
    /* Carousel */
    #myCarousel {
        margin: 8px 0;
        border-radius: 8px;
        overflow: hidden;
    }
    
    .carousel-item {
        min-height: 180px;
    }
    
    .imgslider {
        max-height: 180px !important;
        object-fit: cover;
        display: block;
    }
    
    .carousel-control-prev,
    .carousel-control-next {
        width: 30px;
        height: 30px;
        top: 50%;
        transform: translateY(-50%);
    }
    
    .carousel-indicators {
        bottom: 10px;
        gap: 5px;
    }
    
    .carousel-indicators [data-bs-target] {
        width: 8px;
        height: 8px;
        border-radius: 50%;
    }
    
    /* Columns */
    .col-nim {
        display: none !important;
    }
    
    .col-11,
    .col-12 {
        max-width: 100% !important;
        flex: 0 0 100% !important;
        padding: 0 10px;
    }
    
    /* Text Adjustments */
    h1 {
        font-size: 18px;
        margin: 12px 0 8px;
        font-weight: 700;
        color: #00386B;
    }
    
    h2 {
        font-size: 16px;
        margin: 10px 0 6px;
        font-weight: 700;
        color: #004B8C;
    }
    
    h3 {
        font-size: 14px;
        margin: 8px 0 4px;
        font-weight: 600;
        color: #00386B;
    }
    
    h4, h5, h6 {
        font-weight: 600;
        color: #333;
    }
    
    p {
        margin-bottom: 8px;
        line-height: 1.6;
    }
    
    /* Button Styling */
    .btn {
        font-size: 12px;
        padding: 8px 14px;
        border-radius: 6px;
        font-weight: 600;
        transition: all 0.3s ease;
        border: none;
    }
    
    .btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    }
    
    .btn-primary {
        background-color: #00386B;
    }
    
    .btn-primary:hover {
        background-color: #004B8C;
    }
    
    .btn-lg {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    /* Cards & Containers */
    .card {
        margin-bottom: 12px;
        border: none;
        border-radius: 10px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
        overflow: hidden;
        transition: all 0.3s ease;
    }
    
    .card:hover {
        box-shadow: 0 4px 16px rgba(0,0,0,0.12);
        transform: translateY(-2px);
    }
    
    .card-body {
        padding: 12px;
    }
    
    .card-title {
        color: #00386B;
        font-weight: 700;
        margin-bottom: 8px;
    }
    
    /* Forms */
    .form-control,
    .form-select {
        font-size: 13px;
        padding: 10px 12px;
        border-radius: 6px;
        border: 1px solid #ddd;
        transition: all 0.3s ease;
    }
    
    .form-control:focus,
    .form-select:focus {
        border-color: #00386B;
        box-shadow: 0 0 0 3px rgba(0, 56, 107, 0.1);
    }
    
    label {
        font-size: 12px;
        margin-bottom: 6px;
        font-weight: 600;
        color: #333;
    }
    
    /* Modals */
    .modal-content {
        border-radius: 12px;
        border: none;
        box-shadow: 0 5px 40px rgba(0,0,0,0.16);
    }
    
    .modal-header {
        padding: 16px;
        border-bottom: 1px solid #e9ecef;
        background: linear-gradient(135deg, #00386B 0%, #004B8C 100%);
        color: white;
        border-radius: 12px 12px 0 0;
    }
    
    .modal-title {
        font-weight: 700;
        font-size: 14px;
    }
    
    .modal-body {
        padding: 16px;
        font-size: 13px;
    }
    
    /* Spacing Utilities */
    .mt-1, .mt-2, .mt-3 {
        margin-top: 8px !important;
    }
    
    .mb-1, .mb-2, .mb-3 {
        margin-bottom: 8px !important;
    }
    
    .p-1, .p-2, .p-3 {
        padding: 8px !important;
    }
    
    /* Tables */
    .table {
        font-size: 12px;
        border-collapse: collapse;
        border-radius: 8px;
        overflow: hidden;
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    }
    
    .table thead {
        background: linear-gradient(135deg, #00386B 0%, #004B8C 100%);
        color: white;
    }
    
    .table thead th {
        padding: 10px 6px;
        font-weight: 700;
        border: none;
        text-align: center;
    }
    
    .table tbody td {
        padding: 8px 6px;
        border-bottom: 1px solid #e9ecef;
        text-align: center;
    }
    
    .table tbody tr:hover {
        background-color: #f8f9fa;
    }
    
    /* Footer */
    footer {
        font-size: 12px;
        padding: 20px 0 !important;
        background: #00386B;
        color: white;
        margin-top: 20px;
    }
    
    footer a {
        color: #E7B553;
        text-decoration: none;
    }
    
    footer a:hover {
        text-decoration: underline;
    }
    
    .footer-section {
        margin-bottom: 12px;
    }
    
    /* Alert Messages */
    .alert {
        font-size: 12px;
        padding: 12px 14px;
        margin-bottom: 10px;
        border-radius: 8px;
        border: none;
    }
    
    .alert-info {
        background-color: #cfe2ff;
        color: #084298;
    }
    
    .alert-success {
        background-color: #d1e7dd;
        color: #0f5132;
    }
    
    .alert-warning {
        background-color: #fff3cd;
        color: #664d03;
    }
    
    .alert-danger {
        background-color: #f8d7da;
        color: #842029;
    }
    
    /* Dropdown Menu */
    .dropdown-menu {
        font-size: 12px;
        min-width: 150px;
        border-radius: 8px;
        border: none;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    }
    
    .dropdown-item {
        padding: 10px 14px;
        font-size: 12px;
        transition: all 0.3s ease;
    }
    
    .dropdown-item:hover {
        background-color: #00386B;
        color: white;
    }
    
    /* Links */
    a {
        color: #00386B;
        text-decoration: none;
        transition: all 0.2s ease;
    }
    
    a:hover {
        color: #E7B553;
    }
    
    /* Divider */
    hr {
        border: none;
        height: 1px;
        background: linear-gradient(to right, transparent, #ddd, transparent);
        margin: 12px 0;
    }
    
    /* Breadcrumb */
    .breadcrumb {
        background-color: #f8f9fa;
        padding: 8px 10px;
        border-radius: 6px;
        font-size: 12px;
        margin-bottom: 12px;
    }
    
    .breadcrumb-item.active {
        color: #00386B;
        font-weight: 600;
    }
}

/* ============================================
   TABLETS & MEDIUM DEVICES (481px - 768px)
   ============================================ */
@media screen and (min-width: 481px) and (max-width: 768px) {
    html {
        font-size: 14px;
    }
    
    body {
        font-size: 14px;
        background-color: #f8f9fa;
    }
    
    /* Header Adjustments */
    header.Masai-header {
        padding: 12px 0;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    header.Masai-header .logo-area {
        -ms-flex: 0 0 140px;
        flex: 0 0 140px;
        max-width: 140px;
        padding-right: 15px;
    }
    
    header.Masai-header .search-area form.search input {
        width: 90%;
        padding: 10px 45px 10px;
        font-size: 13px;
        border-radius: 6px;
    }
    
    /* Navigation */
    nav.navbar {
        background: linear-gradient(135deg, #00386B 0%, #004B8C 100%);
    }
    
    .nav-link {
        font-size: 13px !important;
        padding: 12px 10px !important;
        border-radius: 4px;
        transition: all 0.3s ease;
    }
    
    .nav-link:hover {
        background-color: rgba(255, 255, 255, 0.1);
        color: #E7B553 !important;
    }
    
    /* Carousel */
    .carousel-item {
        min-height: 300px;
    }
    
    .imgslider {
        max-height: 300px !important;
    }
    
    /* Columns */
    .col-nim {
        display: none !important;
    }
    
    .col-11 {
        max-width: 100% !important;
        flex: 0 0 100% !important;
        padding: 0 15px;
    }
    
    /* Typography */
    h1 {
        font-size: 24px;
        margin: 14px 0 10px;
        font-weight: 700;
    }
    
    h2 {
        font-size: 22px;
        margin: 12px 0 8px;
        font-weight: 700;
    }
    
    h3 {
        font-size: 20px;
        margin: 10px 0 6px;
        font-weight: 700;
    }
    
    /* Buttons */
    .btn {
        font-size: 13px;
        padding: 8px 14px;
    }
    
    /* Cards */
    .card {
        margin-bottom: 15px;
    }
    
    .card-body {
        padding: 15px;
    }
    
    /* Forms */
    .form-control,
    .form-select {
        font-size: 14px;
        padding: 8px 10px;
    }
    
    label {
        font-size: 13px;
        margin-bottom: 6px;
    }
    
    /* Tables */
    .table {
        font-size: 13px;
    }
    
    .table thead th {
        padding: 8px;
    }
    
    .table tbody td {
        padding: 8px;
    }
    
    /* Modals */
    .modal-dialog {
        margin: 20px auto;
    }
    
    .modal-body {
        font-size: 14px;
        padding: 15px;
    }
    
    /* Spacing */
    .mt-1, .mt-2, .mt-3 {
        margin-top: 10px !important;
    }
    
    .mb-1, .mb-2, .mb-3 {
        margin-bottom: 10px !important;
    }
    
    /* Navbar Brand */
    .navbar-brand {
        font-size: 18px;
    }
    
    /* Dropdown */
    .dropdown-menu {
        font-size: 13px;
        min-width: 180px;
    }
}

/* ============================================
   LANDSCAPE MODE OPTIMIZATION
   ============================================ */
@media screen and (max-height: 500px) and (orientation: landscape) {
    header.Masai-header {
        padding: 5px 0;
    }
    
    header.Masai-header .logo-area {
        max-height: 50px;
    }
    
    .carousel-item {
        min-height: 150px;
    }
    
    .imgslider {
        max-height: 150px !important;
    }
    
    nav.navbar {
        padding: 0 !important;
    }
    
    .nav-link {
        padding: 5px 8px !important;
    }
}

/* ============================================
   TOUCH-FRIENDLY ADJUSTMENTS
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    /* Mobile touch devices */
    a,
    button,
    .btn,
    .nav-link {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    .dropdown-toggle::after {
        margin-right: 5px;
    }
    
    /* Increase clickable area */
    .form-check-input {
        width: 20px;
        height: 20px;
        cursor: pointer;
    }
}

/* ============================================
   RESPONSIVE UTILITIES
   ============================================ */
@media screen and (max-width: 768px) {
    /* Hide desktop elements */
    .d-none.d-md-block,
    .d-none.d-lg-block {
        display: none !important;
    }
    
    /* Show mobile elements */
    .d-block.d-md-none,
    .d-block.d-lg-none {
        display: block !important;
    }
    
    /* Responsive Padding */
    .p-responsive {
        padding: 10px !important;
    }
    
    .p-responsive-lr {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
    
    .p-responsive-tb {
        padding-top: 10px !important;
        padding-bottom: 10px !important;
    }
    
    /* Responsive Margin */
    .m-responsive {
        margin: 10px !important;
    }
    
    .m-responsive-v {
        margin-top: 10px !important;
        margin-bottom: 10px !important;
    }
    
    .m-responsive-h {
        margin-left: 10px !important;
        margin-right: 10px !important;
    }
}

/* ============================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================ */
@media screen and (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Improve text readability on mobile */
@media screen and (max-width: 768px) {
    body {
        line-height: 1.6;
        letter-spacing: 0.5px;
    }
    
    p {
        margin-bottom: 12px;
    }
    
    /* Avoid horizontal scroll */
    body,
    html {
        overflow-x: hidden;
        width: 100%;
    }
}

/* ============================================
   VENDOR PREFIXES & FALLBACKS
   ============================================ */
@media screen and (max-width: 768px) {
    /* WebKit & Firefox */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        border-radius: 4px;
    }
    
    /* Better select styling */
    select {
        padding: 10px;
        border-radius: 4px;
        background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20width%3D%2712%27%20height%3D%278%27%20viewBox%3D%270%200%2012%208%27%3E%3Cpath%20fill%3D%27%23333%27%20d%3D%27M0%200l6%208%206-8z%27%2F%3E%3C%2Fsvg%3E");
        background-repeat: no-repeat;
        background-position: right 10px center;
        background-size: 12px;
        padding-right: 30px;
        appearance: none;
        -webkit-appearance: none;
        -moz-appearance: none;
    }
}

/* ============================================
   IMAGE OPTIMIZATION
   ============================================ */
@media screen and (max-width: 768px) {
    img {
        max-width: 100%;
        height: auto;
        display: block;
    }
    
    picture {
        display: block;
        width: 100%;
    }
    
    /* Responsive images */
    img.img-fluid {
        max-width: 100%;
        height: auto;
    }
}

/* ============================================
   FIXED ELEMENTS SAFETY
   ============================================ */
@media screen and (max-width: 768px) {
    /* Ensure fixed elements don't break layout */
    position: fixed {
        z-index: 1000;
    }
    
    /* Safe areas for notches and rounded corners */
    @supports (padding: max(0px)) {
        header,
        footer,
        nav {
            padding-left: max(1rem, env(safe-area-inset-left));
            padding-right: max(1rem, env(safe-area-inset-right));
        }
    }
}
