/* Global uniform controls */
:root {
    --ctrl-h: 40px;
    --ctrl-h-sm: 36px;
}

.btn {
    min-height: var(--ctrl-h);
    display: inline-flex;
    align-items: center;
}

.btn-sm {
    min-height: var(--ctrl-h-sm);
    height: var(--ctrl-h-sm);
    display: inline-flex;
    align-items: center;
}

.form-control {
    min-height: var(--ctrl-h);
}

.form-control-sm {
    min-height: var(--ctrl-h-sm);
    height: var(--ctrl-h-sm);
}

.select2-container .select2-selection--single {
    height: var(--ctrl-h) !important;
}

.select2-container .select2-selection--multiple {
    min-height: var(--ctrl-h) !important;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: calc(var(--ctrl-h) - 6px) !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: var(--ctrl-h) !important;
}

/* استایل‌های جدول در site.css توسط project-colors.css override می‌شوند */
.table th, .table td {
    vertical-align: middle;
}

/* حذف border-radius از input-group و input-group-text برای ظاهر تیز گوشه‌ها */
.input-group-text {
    border-radius: 0 !important;
}

.input-group .form-control {
    border-radius: 0 !important;
}

.input-group .btn {
    border-radius: 0 !important;
}

/* Captcha block unified */
.captcha-card {
    background: #f8f9fa;
    border: 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
}

.captcha-card .captcha-img {
    height: 48px;
}

.captcha-card .btn-refresh {
    min-width: 110px;
}

.captcha-card .captcha-input {
    text-align: center;
    font-size: 1.05rem;
}

main > .container {
    padding: 70px 15px 20px;
}

.footer {
    background-color: #f5f5f5;
    font-size: .9em;
    height: 60px;
}

.footer > .container {
    padding-right: 15px;
    padding-left: 15px;
}

.not-set {
    color: #c55;
    font-style: italic;
}

/* add sorting icons to gridview sort links */
a.asc:after, a.desc:after {
    content: '';
    left: 3px;
    display: inline-block;
    width: 0;
    height: 0;
    border: solid 5px transparent;
    margin: 4px 4px 2px 4px;
    background: transparent;
}

a.asc:after {
    border-bottom: solid 7px #212529;
    border-top-width: 0;
}

a.desc:after {
    border-top: solid 7px #212529;
    border-bottom-width: 0;
}

.grid-view th {
    white-space: nowrap;
}

.hint-block {
    display: block;
    margin-top: 5px;
    color: #999;
}

.error-summary {
    color: #a94442;
    background: #fdf7f7;
    border-left: 3px solid #eed3d7;
    padding: 10px 20px;
    margin: 0 0 15px 0;
}

/* align the logout "link" (button in form) of the navbar */
.nav li > form > button.logout {
    padding-top: 7px;
    color: rgba(255, 255, 255, 0.5);
}

@media (max-width: 767px) {
    .nav li > form > button.logout {
        display: block;
        text-align: left;
        width: 100%;
        padding: 10px 0;
    }
}

.nav > li > form > button.logout:focus,
.nav > li > form > button.logout:hover {
    text-decoration: none;
    color: rgba(255, 255, 255, 0.75);
}

.nav > li > form > button.logout:focus {
    outline: none;
}

.form-group {
    margin-bottom: 1rem;
}

.help-block {
    color: darkred !important;
}

/* ======================= */
/* Responsive Tabs Styles */
/* ======================= */

/* Container for scrollable tabs on mobile */
.nav-tabs {
    position: relative;
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
    margin-bottom: 1rem;
}

/* Hide scrollbar for Chrome, Safari and Opera */
.nav-tabs::-webkit-scrollbar {
    height: 6px;
}

.nav-tabs::-webkit-scrollbar-track {
    background: transparent;
}

.nav-tabs::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.nav-tabs::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.3);
}

/* Prevent tabs from wrapping on mobile */
.nav-tabs .nav-item {
    flex-shrink: 0;
    white-space: nowrap;
}

/* Ensure tab links don't wrap */
.nav-tabs .nav-link {
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    padding: 0.75rem 1rem;
}

/* Badge inside tabs - ensure proper spacing */
.nav-tabs .nav-link .badge {
    margin-right: 0.25rem;
    margin-left: 0.25rem;
    flex-shrink: 0;
}

/* Icon spacing in tabs */
.nav-tabs .nav-link i {
    margin-left: 0.5rem;
    flex-shrink: 0;
}

/* Responsive adjustments for smaller screens */
@media (max-width: 768px) {
    .nav-tabs {
        border-bottom: 1px solid #dee2e6;
        padding-bottom: 0;
    }
    
    .nav-tabs .nav-link {
        padding: 0.6rem 0.8rem;
        font-size: 0.9rem;
    }
    
    /* Smaller badges on mobile */
    .nav-tabs .nav-link .badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }
    
    /* Smaller icons on mobile */
    .nav-tabs .nav-link i {
        font-size: 0.85rem;
        margin-left: 0.4rem;
    }
}

@media (max-width: 576px) {
    .nav-tabs .nav-link {
        padding: 0.5rem 0.6rem;
        font-size: 0.85rem;
    }
    
    /* Hide text on very small screens, show only icons if available */
    .nav-tabs .nav-link span:not(.badge) {
        display: none;
    }
    
    /* Show text on active tab even on small screens */
    .nav-tabs .nav-link.active span:not(.badge) {
        display: inline;
    }
}

/* Ensure tab content is responsive */
.tab-content {
    width: 100%;
    overflow-x: auto;
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
}

.tab-pane {
    width: 100%;
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    overflow: visible !important;
}

/* Override any fixed heights for exam tabs */
#examTabsContent.tab-content,
#examTabsContent .tab-pane {
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
}

/* Ensure school assignment management div doesn't have height restrictions */
.manage-school-assignments .mb-4,
.tab-pane .mb-4 {
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    overflow: visible !important;
}

/* Fix for RTL direction */
[dir="rtl"] .nav-tabs {
    direction: rtl;
}

[dir="rtl"] .nav-tabs .nav-link i {
    margin-right: 0.5rem;
    margin-left: 0;
}

[dir="rtl"] .nav-tabs .nav-link .badge {
    margin-left: 0.25rem;
    margin-right: 0.25rem;
}

@media (max-width: 768px) {
    [dir="rtl"] .nav-tabs .nav-link i {
        margin-right: 0.4rem;
    }
    
    /* بهبود نمایش تب‌ها در موبایل */
    .nav-tabs {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
        margin-bottom: 1rem;
        padding-bottom: 0.5rem;
        border-bottom: 2px solid #dee2e6;
    }
    
    .nav-tabs::-webkit-scrollbar {
        height: 4px;
    }
    
    .nav-tabs::-webkit-scrollbar-track {
        background: transparent;
    }
    
    .nav-tabs::-webkit-scrollbar-thumb {
        background-color: rgba(0, 0, 0, 0.2);
        border-radius: 2px;
    }
    
    .nav-tabs .nav-item {
        flex-shrink: 0;
        white-space: nowrap;
    }
    
    .nav-tabs .nav-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
        display: flex;
        align-items: center;
        gap: 0.25rem;
    }
    
    .nav-tabs .nav-link i {
        font-size: 0.875rem;
    }
    
    .nav-tabs .nav-link .badge {
        font-size: 0.65rem;
        padding: 0.15rem 0.4rem;
        margin-right: 0.25rem;
        margin-left: 0.25rem;
    }
    
    /* بهبود نمایش جدول‌ها در موبایل */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
        border-radius: 0.375rem;
    }
    
    .table {
        font-size: 0.875rem;
        margin-bottom: 0;
    }
    
    .table thead {
        display: none;
    }
    
    .table tbody tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid #dee2e6;
        border-radius: 0.375rem;
        background-color: #fff;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }
    
    .table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.75rem;
        border: none;
        border-bottom: 1px solid #f0f0f0;
        text-align: right !important;
    }
    
    .table tbody td:last-child {
        border-bottom: none;
    }
    
    .table tbody td:before {
        content: attr(data-label);
        font-weight: 600;
        color: #495057;
        margin-left: 1rem;
        flex-shrink: 0;
    }
    
    /* حذف label برای سلول‌هایی که data-label خالی است یا "عملیات" است */
    .table tbody td[data-label=""]:before,
    .table tbody td[data-label="عملیات"]:before {
        display: none;
        content: '';
    }
    
    /* برای جدول‌هایی که از GridView استفاده می‌کنند */
    .table-sm tbody td {
        padding: 0.5rem;
        font-size: 0.8125rem;
    }
    
    /* بهبود نمایش دکمه‌ها در جدول موبایل */
    .table tbody td .btn {
        width: 100%;
        justify-content: center;
        margin-top: 0.5rem;
    }
    
    .table tbody td .btn-group {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .table tbody td .btn-group .btn {
        width: 100%;
    }
    
    /* برای جدول‌هایی که از GridView استفاده می‌کنند - نمایش header در موبایل */
    .table-responsive .table thead {
        display: none;
    }
    
    /* بهبود نمایش badge ها در جدول موبایل */
    .table tbody td .badge {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
}

/* JavaScript برای اضافه کردن data-label به سلول‌های جدول در موبایل */
@media (max-width: 768px) {
    .table-responsive {
        position: relative;
    }
}