/* =========================================================
   Zhenic & Punic Test Application - Master RTL Stylesheet
   Full Responsive & Mobile Optimized
   ========================================================= */

/* 1. Base & Reset */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-size: 14px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Vazirmatn', Tahoma, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    direction: rtl;
    text-align: right;
    margin: 0;
    padding: 0;
    background-color: #f3f5f9;
    color: #3f4254;
    overflow-x: hidden;
    min-height: 100vh;
}

/* 2. Grid System (100% Bootstrap Compatible RTL) */
.container, .container-fluid {
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
    margin-right: auto;
    margin-left: auto;
}

.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -10px;
    margin-left: -10px;
}

.col, [class*="col-"] {
    position: relative;
    width: 100%;
    padding-right: 10px;
    padding-left: 10px;
}

/* Default / Mobile Col (0px and up) */
.col-1  { flex: 0 0 8.333333%; max-width: 8.333333%; }
.col-2  { flex: 0 0 16.666667%; max-width: 16.666667%; }
.col-3  { flex: 0 0 25%; max-width: 25%; }
.col-4  { flex: 0 0 33.333333%; max-width: 33.333333%; }
.col-5  { flex: 0 0 41.666667%; max-width: 41.666667%; }
.col-6  { flex: 0 0 50%; max-width: 50%; }
.col-7  { flex: 0 0 58.333333%; max-width: 58.333333%; }
.col-8  { flex: 0 0 66.666667%; max-width: 66.666667%; }
.col-9  { flex: 0 0 75%; max-width: 75%; }
.col-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
.col-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
.col-12 { flex: 0 0 100%; max-width: 100%; }

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) {
    .col-sm-1  { flex: 0 0 8.333333%; max-width: 8.333333%; }
    .col-sm-2  { flex: 0 0 16.666667%; max-width: 16.666667%; }
    .col-sm-3  { flex: 0 0 25%; max-width: 25%; }
    .col-sm-4  { flex: 0 0 33.333333%; max-width: 33.333333%; }
    .col-sm-5  { flex: 0 0 41.666667%; max-width: 41.666667%; }
    .col-sm-6  { flex: 0 0 50%; max-width: 50%; }
    .col-sm-7  { flex: 0 0 58.333333%; max-width: 58.333333%; }
    .col-sm-8  { flex: 0 0 66.666667%; max-width: 66.666667%; }
    .col-sm-9  { flex: 0 0 75%; max-width: 75%; }
    .col-sm-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
    .col-sm-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
    .col-sm-12 { flex: 0 0 100%; max-width: 100%; }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) {
    .col-md-1  { flex: 0 0 8.333333%; max-width: 8.333333%; }
    .col-md-2  { flex: 0 0 16.666667%; max-width: 16.666667%; }
    .col-md-3  { flex: 0 0 25%; max-width: 25%; }
    .col-md-4  { flex: 0 0 33.333333%; max-width: 33.333333%; }
    .col-md-5  { flex: 0 0 41.666667%; max-width: 41.666667%; }
    .col-md-6  { flex: 0 0 50%; max-width: 50%; }
    .col-md-7  { flex: 0 0 58.333333%; max-width: 58.333333%; }
    .col-md-8  { flex: 0 0 66.666667%; max-width: 66.666667%; }
    .col-md-9  { flex: 0 0 75%; max-width: 75%; }
    .col-md-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
    .col-md-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
    .col-md-12 { flex: 0 0 100%; max-width: 100%; }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) {
    .col-lg-1  { flex: 0 0 8.333333%; max-width: 8.333333%; }
    .col-lg-2  { flex: 0 0 16.666667%; max-width: 16.666667%; }
    .col-lg-3  { flex: 0 0 25%; max-width: 25%; }
    .col-lg-4  { flex: 0 0 33.333333%; max-width: 33.333333%; }
    .col-lg-5  { flex: 0 0 41.666667%; max-width: 41.666667%; }
    .col-lg-6  { flex: 0 0 50%; max-width: 50%; }
    .col-lg-7  { flex: 0 0 58.333333%; max-width: 58.333333%; }
    .col-lg-8  { flex: 0 0 66.666667%; max-width: 66.666667%; }
    .col-lg-9  { flex: 0 0 75%; max-width: 75%; }
    .col-lg-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
    .col-lg-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
    .col-lg-12 { flex: 0 0 100%; max-width: 100%; }
}

/* 3. Layout Structure */
#kt_body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.page {
    display: flex;
    flex-direction: row;
    flex: 1 0 auto;
    width: 100%;
}

.wrapper {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
}

/* Desktop Sidebar Aside */
.aside {
    width: 265px;
    background-color: #1e1e2d;
    height: 100vh;
    position: fixed;
    right: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.brand {
    padding: 18px 25px;
    background-color: #1a1a27;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.aside-menu {
    flex: 1;
    overflow-y: auto;
    padding: 15px 0;
}

/* Desktop Header */
.header {
    height: 60px;
    background-color: #fff;
    box-shadow: 0 0 20px 0 rgba(82, 63, 105, 0.08);
    position: fixed;
    top: 0;
    right: 265px;
    left: 0;
    z-index: 900;
    display: flex;
    align-items: center;
    padding: 0 25px;
    transition: right 0.3s ease;
}

/* Main Content Area */
#kt_content {
    padding: 25px;
    margin-right: 265px;
    margin-top: 60px;
    flex: 1 1 auto;
    min-width: 0;
    width: calc(100% - 265px);
    transition: margin-right 0.3s ease, width 0.3s ease;
}

/* Sidebar Menu */
.menu-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.menu-item {
    padding: 0;
    margin: 0;
}

.menu-link {
    display: flex;
    align-items: center;
    padding: 12px 25px;
    color: #9899ac;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
    font-size: 13.5px;
}

.menu-link:hover {
    background-color: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.menu-item.menu-item-active .menu-link {
    background-color: #181c32;
    color: #3699ff;
    font-weight: 600;
    border-right: 3px solid #3699ff;
}

.menu-icon {
    width: 30px;
    display: flex;
    justify-content: center;
    font-size: 15px;
}

.menu-text {
    flex: 1;
}

/* 4. Cards & Containers */
.card {
    border-radius: 8px;
    box-shadow: 0 0 20px 0 rgba(82, 63, 105, 0.05);
    border: 1px solid #ebedf3;
    background-color: #fff;
    margin-bottom: 20px;
    position: relative;
    width: 100%;
}

.card-header {
    padding: 15px 20px;
    border-bottom: 1px solid #ebedf3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: transparent;
}

.card-body {
    padding: 20px;
}

/* 5. Tables & Responsive Table Wrapper */
.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    -ms-overflow-style: -ms-autohiding-scrollbar;
    border: 1px solid #ebedf3;
    border-radius: 6px;
    margin-bottom: 10px;
}

.table {
    width: 100%;
    margin-bottom: 0;
    color: #3f4254;
    border-collapse: collapse;
}

.table th, .table td {
    padding: 10px 12px;
    vertical-align: middle;
    border: 1px solid #ebedf3;
    font-size: 12.5px;
    white-space: nowrap;
}

.table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #181c32;
    text-align: right;
}

.table-hover tbody tr:hover {
    background-color: #f4f6fa;
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(0, 0, 0, 0.015);
}

/* 6. Forms & Inputs */
.form-group {
    margin-bottom: 15px;
}

.form-label, label {
    display: inline-block;
    margin-bottom: 6px;
    font-size: 13px;
    color: #3f4254;
}

.form-control {
    display: block;
    width: 100%;
    height: 38px;
    padding: 6px 12px;
    font-size: 13px;
    font-family: inherit;
    line-height: 1.5;
    color: #3f4254;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid #e4e6ef;
    border-radius: 4px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus {
    border-color: #3699ff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(54, 153, 255, 0.2);
}

.form-control-sm {
    height: 32px;
    padding: 4px 8px;
    font-size: 12px;
}

textarea.form-control {
    height: auto;
    resize: vertical;
}

.input-group {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    width: 100%;
}

.input-group > .form-control {
    position: relative;
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
    margin-bottom: 0;
}

.input-group-prepend, .input-group-append {
    display: flex;
}

.input-group-text {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    margin-bottom: 0;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.5;
    color: #3f4254;
    text-align: center;
    white-space: nowrap;
    background-color: #f3f6f9;
    border: 1px solid #e4e6ef;
}

.input-group-prepend .input-group-text {
    border-left: 0;
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
}

.input-group-append .input-group-text {
    border-right: 0;
    border-top-left-radius: 4px;
    border-bottom-left-radius: 4px;
}

.input-group > .form-control:not(:first-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.input-group > .form-control:not(:last-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* 7. Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    color: #3f4254;
    text-align: center;
    vertical-align: middle;
    user-select: none;
    background-color: transparent;
    border: 1px solid transparent;
    padding: 7px 16px;
    font-size: 13px;
    font-family: inherit;
    line-height: 1.5;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary { background-color: #3699ff; border-color: #3699ff; color: #fff; }
.btn-primary:hover { background-color: #187de4; border-color: #187de4; color: #fff; }

.btn-success { background-color: #1bc5bd; border-color: #1bc5bd; color: #fff; }
.btn-success:hover { background-color: #14a09a; border-color: #14a09a; color: #fff; }

.btn-secondary { background-color: #e4e6ef; border-color: #e4e6ef; color: #3f4254; }
.btn-secondary:hover { background-color: #d1d5e4; border-color: #d1d5e4; color: #181c32; }

.btn-danger { background-color: #f64e60; border-color: #f64e60; color: #fff; }
.btn-danger:hover { background-color: #e43a4d; border-color: #e43a4d; color: #fff; }

.btn-warning { background-color: #ffa800; border-color: #ffa800; color: #fff; }
.btn-outline-secondary { border-color: #e4e6ef; background-color: #fff; color: #3f4254; }
.btn-outline-secondary:hover { background-color: #f3f6f9; color: #181c32; }

.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 3px; }
.btn-icon { width: 32px; height: 32px; padding: 0; border-radius: 4px; }
.btn-clean { background-color: transparent; border-color: transparent; }
.btn-clean:hover { background-color: #f3f6f9; }

.btn-group {
    position: relative;
    display: inline-flex;
    vertical-align: middle;
}

.btn-group > .btn {
    position: relative;
    flex: 1 1 auto;
}

.btn-group > .btn:not(:first-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.btn-group > .btn:not(:last-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* 8. Badges & Labels */
.badge, .label {
    display: inline-block;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 4px;
}

.badge-light { background-color: #f3f6f9; color: #7e8299; }
.badge-light-primary { background-color: #e1f0ff; color: #3699ff; }
.badge-light-info { background-color: #eee5ff; color: #8950fc; }
.badge-success, .label-success { background-color: #c9f7f5; color: #1bc5bd; }
.badge-primary, .label-primary { background-color: #e1f0ff; color: #3699ff; }
.badge-warning, .label-warning { background-color: #fff4de; color: #ffa800; }
.badge-danger, .label-danger { background-color: #ffe2e5; color: #f64e60; }
.badge-info, .label-info { background-color: #eee5ff; color: #8950fc; }
.label-light { background-color: #f3f6f9; color: #3f4254; }
.label-inline { display: inline-block; }

/* 9. Modal */
.modal {
    position: relative;
    width: 100%;
}

.modal-dialog {
    position: relative;
    width: 100%;
    margin: 15px auto;
}

.modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.08);
}

/* 10. Checkboxes */
.form-check {
    position: relative;
    display: flex;
    align-items: center;
    padding-right: 0;
}

.form-check-input {
    margin-left: 8px;
    margin-top: 0;
    cursor: pointer;
}

/* 11. Pagination */
.pagination {
    display: flex;
    padding-right: 0;
    list-style: none;
    border-radius: 4px;
    margin: 0;
}

.page-item .page-link {
    position: relative;
    display: block;
    padding: 5px 10px;
    margin-left: -1px;
    line-height: 1.25;
    color: #3f4254;
    background-color: #fff;
    border: 1px solid #ebedf3;
    text-decoration: none;
}

.page-item.active .page-link {
    z-index: 3;
    color: #fff;
    background-color: #3699ff;
    border-color: #3699ff;
}

.page-item.disabled .page-link {
    color: #b5b5c3;
    pointer-events: none;
    background-color: #f8f9fa;
    border-color: #ebedf3;
}

/* 12. Utilities */
.d-flex { display: flex !important; }
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-inline-block { display: inline-block !important; }

.flex-column { flex-direction: column !important; }
.flex-row { flex-direction: row !important; }
.flex-wrap { flex-wrap: wrap !important; }
.flex-nowrap { flex-wrap: nowrap !important; }

.align-items-center { align-items: center !important; }
.align-items-start { align-items: flex-start !important; }
.align-items-end { align-items: flex-end !important; }

.justify-content-between { justify-content: space-between !important; }
.justify-content-center { justify-content: center !important; }
.justify-content-end { justify-content: flex-end !important; }

.text-center { text-align: center !important; }
.text-left { text-align: left !important; }
.text-right { text-align: right !important; }

.text-primary { color: #3699ff !important; }
.text-success { color: #1bc5bd !important; }
.text-danger { color: #f64e60 !important; }
.text-warning { color: #ffa800 !important; }
.text-muted { color: #7e8299 !important; }
.text-dark { color: #181c32 !important; }

.font-weight-bold { font-weight: 600 !important; }
.font-weight-bolder { font-weight: 700 !important; }

.w-100 { width: 100% !important; }
.h-100 { height: 100% !important; }
.ltr { direction: ltr !important; text-align: left; }

.m-0 { margin: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 4px !important; }
.mb-2 { margin-bottom: 8px !important; }
.mb-3 { margin-bottom: 15px !important; }
.mb-4 { margin-bottom: 20px !important; }
.mt-1 { margin-top: 4px !important; }
.mt-2 { margin-top: 8px !important; }
.mt-3 { margin-top: 15px !important; }
.ml-1 { margin-left: 4px !important; }
.ml-2 { margin-left: 8px !important; }
.mr-1 { margin-right: 4px !important; }
.mr-2 { margin-right: 8px !important; }
.p-0 { padding: 0 !important; }

/* 13. Mobile Header & Drawer Overlay */
.header-mobile {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background-color: #1a1a27;
    z-index: 1002;
    padding: 0 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

.aside-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1005;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.aside-overlay.active {
    display: block;
    opacity: 1;
}

.aside-close-btn {
    display: none;
    background: none;
    border: none;
    color: #a2a3b7;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
}

/* 14. Responsive Layout Breakpoints (< 992px: Mobile & Tablets) */
@media (max-width: 991.98px) {
    /* Hide desktop header, show mobile header */
    .header {
        display: none !important;
    }

    .header-mobile {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
    }

    /* Off-canvas mobile sidebar */
    .aside {
        position: fixed !important;
        top: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 280px !important;
        max-width: 85vw !important;
        height: 100vh !important;
        z-index: 1010 !important;
        transform: translateX(100%);
        box-shadow: -5px 0 25px rgba(0, 0, 0, 0.25);
    }

    .aside.aside-on {
        transform: translateX(0) !important;
    }

    .aside-close-btn {
        display: inline-block !important;
    }

    /* Content full width on mobile */
    #kt_content {
        margin-right: 0 !important;
        margin-top: 60px !important;
        padding: 15px 12px 110px !important;
        width: 100% !important;
        max-width: 100vw !important;
    }

    /* Card padding optimization */
    .card-header {
        padding: 12px 14px !important;
        flex-direction: column;
        align-items: flex-start !important;
        gap: 8px;
    }

    .card-body {
        padding: 14px 12px !important;
    }

    /* Modal padding & border reset */
    .modal-dialog {
        margin: 5px auto !important;
        max-width: 100% !important;
    }

    .modal-header {
        padding: 12px 14px !important;
    }

    .modal-body {
        padding: 15px 12px !important;
    }

    .modal-footer {
        padding: 12px 14px !important;
        flex-direction: column !important;
        gap: 10px !important;
    }

    .modal-footer > div {
        width: 100% !important;
        display: flex !important;
        flex-wrap: wrap !important;
    }

    .modal-footer .btn {
        flex: 1 1 auto !important;
        min-width: 110px !important;
    }

    /* Schedule Create column border reset on mobile */
    .mobile-border-reset {
        border-left: none !important;
        border-bottom: 1px solid #ebedf3 !important;
        padding-left: 0 !important;
        padding-bottom: 20px !important;
        margin-bottom: 20px !important;
    }

    .mobile-padding-reset {
        padding-right: 0 !important;
    }

    /* Form control & buttons sizing on mobile */
    .form-control {
        font-size: 13.5px !important;
    }

    /* Mobile subheader stacking */
    .page-subheader {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
    }

    .page-subheader .btn {
        width: 100% !important;
    }
}

/* Extra small screens (< 576px) */
@media (max-width: 575.98px) {
    #kt_content {
        padding: 12px 8px 110px !important;
    }

    h2 {
        font-size: 1.2rem !important;
    }

    .btn {
        font-size: 12px !important;
        padding: 6px 12px !important;
    }

    /* Duration quick select wrapping */
    .btn-group.w-100 {
        flex-wrap: wrap !important;
    }

    .btn-group.w-100 > .btn {
        flex: 0 0 33.333% !important;
        border-radius: 4px !important;
        margin: 2px 0 !important;
    }
}

/* 15. Responsive Test Settings Bar */
.test-settings-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: #1e1e2d;
    color: #fff;
    padding: 10px 15px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 12px;
    direction: rtl;
    box-shadow: 0 -3px 15px rgba(0, 0, 0, 0.25);
    font-size: 12.5px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.test-settings-toggle-btn {
    display: none;
    position: fixed;
    bottom: 12px;
    left: 12px;
    background-color: #1e1e2d;
    color: #3699ff;
    border: 1px solid #3699ff;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 9998;
    cursor: pointer;
}

@media (max-width: 991.98px) {
    .test-settings-toggle-btn {
        display: inline-flex;
        align-items: center;
        gap: 6px;
    }

    .test-settings-bar {
        flex-direction: column;
        align-items: stretch !important;
        gap: 10px;
        padding: 15px;
        background-color: #1a1a27;
        border-top: 2px solid #3699ff;
        border-top-left-radius: 12px;
        border-top-right-radius: 12px;
        max-height: 80vh;
        overflow-y: auto;
        transform: translateY(105%);
    }

    .test-settings-bar.is-open {
        transform: translateY(0);
    }

    .test-settings-bar input {
        width: 100% !important;
        height: 36px !important;
    }

    .test-settings-bar .test-settings-row {
        display: flex;
        flex-direction: column;
        gap: 4px;
        width: 100%;
    }

    .test-settings-bar .test-settings-actions {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        margin-top: 5px;
    }
}
