﻿/* reset */
* {
    box-sizing: border-box;
    font-size: 14px;
}

body {
    margin: 0;
}

img {
    max-width: 100%;
}

html, body, p, a, div,
h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5, h6, .h6,
table, thead, tbody, tfoot, tr, th, td,
label, input, button, select, optgroup, textarea,
abbr, ul, ol, li, dl, dd, blockquote {
    font-family: Vazirmatn, Tahoma, Calibri;
}

    a:hover, a:visited, a:active, a {
        outline: none;
        text-decoration: none;
        color: initial;
    }

p {
    margin-top: 0;
    margin-bottom: 1rem;
}

/* headings */

h1, h2, h3, h4, h5, h6 {
    margin-bottom: 1rem;
    margin-top: 0;
}

h1 {
    font-size: 2.5rem;
}

h2 {
    font-size: 2rem;
}

h3 {
    font-size: 1.75rem;
}

h4 {
    font-size: 1.5rem;
}

h5 {
    font-size: 1.25rem;
}

h6 {
    font-size: 1rem;
}

/* main */
main#acc-app {
    display: grid;
    grid-template-columns: 216px 1fr;
    height: 100vh;
    max-height: 100vh;

    div#content article#article {
        height: calc(100vh - 48px);
        max-height: calc(100vh - 48px);
        overflow-y: auto;
        background: var(--acc-article-background-color);
    }

    div#overlay {
        display: none;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        position: fixed;
        z-index: 3;
        backdrop-filter: blur(2px);
    }
}

/* aside */

aside.acc-aside {
    background: var(--acc-aside-background-color);
    overflow: auto;
    position: relative;
    z-index: 5;
    height: 100vh;
    transition: right 0.75s ease;
    animation-fill-mode: forwards;

    &::-webkit-scrollbar {
        display: none;
    }

    * {
        user-select: none;
    }

    :where(a, span, div, i, code) {
        color: var(--acc-aside-text-color);
    }

    input {
        color: var(--acc-aside-text-color) !important;

        &::placeholder {
            color: var(--acc-aside-text-color) !important;
        }
    }

    > div {
        display: flex;
        color: initial;
        justify-content: space-between;
        align-items: center;
        height: 48px;
        background: color-mix( var(--acc-aside-background-color) 75%, black 25%);
        padding: 1rem;
        width: 100%;
        z-index: 2;
        position: sticky;
        top: 0;

        > h1 {
            white-space: nowrap;
            margin: 0;
            color: var(--acc-aside-text-color);
            font-size: 1rem;
        }

        > code {
            direction: ltr;
            font-family: inherit;
            font-size: smaller;
        }
    }

    li {
        position: relative;

        &[active]::after {
            content: "▲";
            position: absolute;
            color: var(--acc-article-background-color);
            left: -6px;
            top: 50%;
            transform: translateY(-50%) rotate(90deg) scaleX(1.5);
            font-size: 1.25rem;
        }
    }

    > ul {
        margin-block: 0;
        font-weight: bold;
        display: flex;
        flex-direction: column;
        padding: 0 !important;
        list-style-type: none;
        position: relative;

        > li {
            min-height: 3rem;

            > :where(a, div) {
                min-height: 3rem;
                display: flex;
                align-items: center;
                gap: 0.5rem;
                cursor: pointer;
                user-select: none;
                padding: 0.5rem;
                padding-inline: 1rem;

                &:hover {
                    background: color-mix(var(--acc-aside-background-color) 90%, white 10%);
                }
            }

            > ul {
                padding: 0;
                margin: 0;
                padding-inline-start: 1.75rem;
                list-style-type: none;
                max-height: 0;
                overflow: hidden;
                transition: max-height 0.5s ease;

                &:has(li[active]) {
                    max-height: fit-content;
                }

                > li {
                    margin-bottom: 1rem;

                    &:first-of-type {
                        margin-top: 1rem;
                    }
                }
            }

            a {
                width: 100%;
                gap: 0.5rem;
            }
        }
    }

    li#search {
        padding: 0.5rem 1rem;
        display: flex;
        gap: 0.5rem;
        align-items: center;

        > input {
            border: none;
            background: transparent;
            resize: none;
            transition: box-shadow 0.3s ease;
            color: initial;
            width: 100%;

            &:focus {
                outline: none;
            }

            &::placeholder {
                color: initial;
            }
        }
    }

    li#master * {
        color: initial !important;
    }

    i.bi-chevron-down {
        margin-inline-start: auto;
        transition: rotate 0.3s linear;
    }
}

/* forms */

form.acc-form {
    fieldset {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
        margin-bottom: 0.5rem;
        margin-inline: 0;
        position: relative;
        border: none;
        padding: 0;

        ul {
            padding: 0;
            color: var(--tw-slate-400) !important;
            list-style-type: circle;

            li {
                font-size: small !important;
            }
        }

        > button {
            font-size: smaller;
            color: var(--tw-blue-800);
            border: none;
            background: transparent;
            border-radius: 0.25rem;
            position: absolute;
            left: 0;
            padding-left: 2px;
            max-height: 1rem;
        }

        label {
            font-size: smaller;
            color: var(--acc-form-label-text-color);
            user-select: none;
            cursor: pointer;
        }
        /* common input fields */
        :where(input:not([type]), input:is([type=text], [type=file], [type=number], [type=password], [type=email], [type=url], [type=date]), textarea, select) {
            border-radius: 0.25rem;
            border: 1px solid var(--acc-form-input-border-color);
            background: var(--acc-form-input-background-color);
            padding: 0.25rem;
            resize: none;
            width: 100%;
            transition: box-shadow 0.3s ease;
            color: var(--acc-form-input-text-color);
            font-size: 12px;

            &:focus {
                outline: none;
            }

            &:not([readonly]):focus {
                box-shadow: 0 0 0px 2px var(--tw-blue-200);
            }
        }
        /* select */
        select {
            appearance: none;
            cursor: pointer;
            padding-inline: 0.5rem 2rem;
            background-color: var(--acc-form-input-background-color);
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708'/%3E%3C/svg%3E");
            background-repeat: no-repeat;
            background-position: 0.5rem center;
            background-size: 0.75rem;
        }
        /* color */
        input[type=color] {
            padding: 0;
            border: none !important;
            cursor: pointer;
            border-radius: 0.25rem;
            min-width: 64px;
        }
        /* validation message */
        > span.field-validation-error,
        > span.field-validation-error * {
            color: var(--tw-red-600);
            font-size: smaller;
        }
    }

    [readonly] {
        opacity: 0.5;
    }
    /* submit */
    div.buttons {
        display: flex;
        justify-content: flex-end;
        gap: 0.5rem;

        button[type=submit]::before {
            content: "\f7d8";
            font-family: "bootstrap-icons";
        }
    }

    :where(button:not(.disable-other-styles, .day, .bd-next, .bd-prev),input[type=submit]) {
        height: 32px;
        max-height: 32px;
        display: inline-flex;
        gap: 0.25rem;
        align-items: center;
        justify-content: center;
        border: none;
        border-radius: 0.25rem;
        background-color: var(--tw-blue-400);
        color: var(--tw-gray-200);
        padding: 0.3rem 0.6rem;
        transition: box-shadow 0.3s ease;

        &:focus {
            outline: none;
            box-shadow: 0 0 0 2px color-mix(var(--tw-blue-400), transparent);
        }
    }
    /* checkbox */
    input[type=checkbox] {
        margin-inline-end: auto;
        cursor: pointer;
        border: 1px solid var(--tw-gray-300);
        appearance: none;
        width: 1.25rem;
        height: 1.25rem;
        aspect-ratio: 1;
        border-radius: 0.5rem;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background-color 0.3s ease, box-shadow 0.3s ease;

        &:checked {
            background-color: var(--tw-blue-800);

            &::before {
                scale: 1;
            }
        }

        &:focus {
            outline: none;
            box-shadow: 0 0 0px 2px var(--tw-blue-200);
        }

        &::before {
            content: "\f26e";
            font-family: "bootstrap-icons";
            scale: 0;
            transition: scale 0.3s ease;
            color: var(--tw-gray-200);
        }
    }
}

input.acc-input {
    border-radius: 0.25rem;
    border: 1px solid var(--tw-gray-300);
    background: var(--tw-gray-100);
    padding: 0.25rem;
    resize: none;
    width: 100%;
    transition: box-shadow 0.3s ease;
    color: var(--tw-slate-500);

    &:focus {
        outline: none;
    }

    &:not([readonly]):focus {
        box-shadow: 0 0 0px 2px var(--tw-blue-200);
    }
}

/* tables */

div.acc-table-container {
    border-radius: 0.5rem;
    overflow: clip;

    table.acc-table {
        width: 100%;
        border-collapse: collapse;
        border: none;
        margin-bottom: 1rem;

        :where(td, th) {
            padding: 0.5rem;
            border: 1px solid var(--acc-table-border-color);
        }

        > thead > tr {
            background-color: var(--acc-table-even-row-background-color);
            color: var(--acc-table-text-color);
            font-weight: bold;

            > th {
                font-weight: bold;
                text-align: start;
            }
        }

        > tbody {
            > tr {
                > td {
                    color: var(--acc-table-text-color);
                    font-weight: normal;

                    div.buttons {
                        display: flex;
                        gap: 0.5rem;
                        flex-wrap: wrap;

                        > a {
                            font-size: small;
                            border-radius: 0.25rem;
                            border-width: 1px;
                            border-style: solid;
                            padding: 0.2rem 0.6rem;
                            display: inline-flex;
                            align-items: center;
                            justify-content: center;
                            text-align: center;
                            user-select: none;
                            cursor: pointer;
                            position: relative;

                            > i {
                                display: flex;
                                padding: 0.25rem 0;
                            }

                            &::after {
                                content: attr(data-title);
                                position: absolute;
                                top: -32px;
                                padding: 0.2rem 0.4rem;
                                color: var(--tw-gray-100);
                                font-size: smaller;
                                border-radius: 0.75rem;
                                z-index: 2;
                                white-space: nowrap;
                                scale: 0;
                                transition: scale 0.2s ease;
                            }

                            &:hover {
                                &::after {
                                    scale: 1;
                                }

                                &::before {
                                    scale: 1.75 1;
                                }
                            }

                            &::before {
                                content: "▲";
                                rotate: 180deg;
                                display: flex;
                                position: absolute;
                                top: -20px;
                                scale: 0;
                                transition: scale 0.2s ease;
                            }

                            &.details {
                                border-color: var(--tw-yellow-600);
                                color: var(--tw-yellow-600);

                                &:not(.custom) > i::before {
                                    font-family: 'bootstrap-icons';
                                    content: "\f479";
                                }

                                &:hover {
                                    background-color: color-mix(40% var(--tw-yellow-500), 60% transparent);

                                    &::after {
                                        background-color: var(--tw-yellow-600);
                                    }
                                }

                                &:focus {
                                    box-shadow: 0 0 0 3px var(--tw-yellow-300);
                                }
                            }

                            &.update {
                                border-color: var(--tw-blue-600);
                                color: var(--tw-blue-600);

                                &:not(.custom) > i::before {
                                    content: "\f4cb";
                                }

                                &:hover {
                                    background-color: color-mix(40% var(--tw-blue-500), 60% transparent);

                                    &::after {
                                        background-color: var(--tw-blue-600);
                                    }
                                }

                                &:focus {
                                    box-shadow: 0 0 0 3px var(--tw-blue-300);
                                }
                            }

                            &.delete {
                                border-color: var(--tw-red-600);
                                color: var(--tw-red-600);

                                form {
                                    display: none;
                                }

                                &:not(.custom) > i::before {
                                    content: "\f5de";
                                }

                                &[data-status=locked] > i::before {
                                    content: "\f47b";
                                }

                                &[data-status=pending] > i::before {
                                    content: "\f130";
                                    animation: spinner-border 3s linear infinite;
                                }

                                &:hover {
                                    background-color: color-mix(40% var(--tw-red-500), 60% transparent);

                                    &::after {
                                        background-color: var(--tw-red-600);
                                    }
                                }

                                &:focus {
                                    box-shadow: 0 0 0 3px var(--tw-red-300);
                                }
                            }

                            &.master {
                                border-color: var(--tw-gray-600);
                                color: var(--tw-gray-600);

                                &:not(.custom) > i::before {
                                    content: "\f4da";
                                }

                                &:hover {
                                    background-color: color-mix(40% var(--tw-gray-600), 60% transparent);

                                    &::after {
                                        background-color: var(--tw-gray-600);
                                    }
                                }

                                &:focus {
                                    box-shadow: 0 0 0 3px var(--tw-gray-300);
                                }
                            }

                            &.apply {
                                border-color: var(--tw-purple-600);
                                color: var(--tw-purple-600);

                                &:not(.custom) > i::before {
                                    content: "\f675";
                                }

                                &:hover {
                                    background-color: color-mix(40% var(--tw-purple-600), 60% transparent);

                                    &::after {
                                        background-color: var(--tw-purple-600);
                                    }
                                }

                                &:focus {
                                    box-shadow: 0 0 0 3px var(--tw-purple-300);
                                }
                            }
                        }
                    }
                }

                &[ondblclick] {
                    cursor: pointer;
                }

                &.warning > td {
                    color: var(--tw-orange-600);
                }

                &.danger > td {
                    color: var(--tw-red-600);
                }

                &:nth-child(odd) {
                    background-color: var(--acc-table-odd-row-background-color);
                }

                &:nth-child(even) {
                    background-color: var(--acc-table-even-row-background-color);
                }

                &:hover {
                    background-color: var(--acc-table-hover-row-background-color);
                }
            }
        }

        > tfoot > tr > td {
            width: 100%;

            > div {
                display: flex;
                justify-content: space-between;

                > a {
                    display: flex;
                    cursor: pointer;
                    gap: 0.5rem;
                    align-items: center;
                    justify-content: center;

                    > i {
                        display: inline-flex;
                    }
                }

                > ul {
                    display: flex;
                    list-style-type: none;
                    gap: 1rem;
                    margin: 0;

                    > li {
                        border: 1px solid var(--tw-gray-200);
                        cursor: pointer;
                        aspect-ratio: 1 !important;
                        width: 24px;
                        max-height: 24px;
                        display: inline-flex;
                        align-items: center;
                        justify-content: center;
                        border-radius: 50%;
                        padding: 0.25rem;

                        > a {
                            font-family: fadigits !important;
                        }

                        &.active {
                            background-color: var(--tw-blue-300);
                        }
                    }
                }
            }
        }

        > tfoot > * {
            user-select: none;
            color: var(--tw-gray-600);
        }

        img.thumbnail {
            min-height: 2rem;
            height: 2rem;
            max-height: 2rem;
            border-radius: 0.25rem;
        }
    }
}

@media screen and (max-width: 640px) {
    table.acc-table {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        border: none;

        > thead {
            display: none;
        }

        :where(td, th) {
            border: none;
        }

        > tbody {
            display: flex;
            flex-direction: column;
            gap: 1rem;

            > tr {
                display: flex;
                flex-direction: column;
                border: 1px solid var(--acc-table-border-color);
                border-radius: 0.25rem;
                padding: 1rem;

                > td {
                    display: flex;
                    border: none !important;
                    border-bottom: 1px solid var(--tw-gray-200) !important;
                    align-items: center;
                    width: 100%;

                    &:last-of-type {
                        border: none !important;
                    }

                    &::before {
                        content: attr(data-title);
                        display: inline-block;
                        padding-inline-end: 0.5rem;
                        width: 8rem;
                        min-width: 8rem;
                        color: var(--tw-gray-400);
                    }
                }
            }
        }
    }
}

/* flex helpers */

.flex {
    display: flex;
}

.d-flex {
    display: flex;
}

.flex-column {
    flex-direction: column;
}

.flex-wrap {
    flex-wrap: wrap;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.align-items-end {
    align-items: flex-end;
}

/* margin */
.m-0 {
    margin: 0 !important;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-3 {
    margin-bottom: 1rem;
}

.mt-3 {
    margin-top:1rem;
}

/* paddings */

.p-3 {
    padding: 1rem;
}

.p-5 {
    padding: 5rem;
}

.p-0 {
    padding: 0 !important;
}

/* gaps */

.gap-0 {
    gap: 0 !important;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-3 {
    gap: 1rem;
}

.gap-5 {
    gap: 3rem;
}

.col-gap-3 {
    column-gap: 1rem !important;
}

/* text-color */

.text-gray-400 {
    color: var(--tw-gray-400);
}

.text-success {
    color: var(--tw-green-600) !important;
}

.text-danger {
    color: var(--tw-red-600) !important;
}

.text-warning {
    color: var(--tw-orange-600) !important;
}

/* misc */

.ms-3 {
    margin-inline-start: 1rem;
}

.me-3 {
    margin-inline-end: 1rem;
}

.text-center {
    text-align: center;
}

.grid {
    display: grid;
}

.grid-cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

.w-full {
    width: 100%;
}

.container {
    max-width: 1140px;
    margin-inline: auto;
}

.rtl {
    direction: rtl !important;
}

.fa-digits, .fa-digits * {
    font-family: "fadigits", Calibri !important;
    font-weight: normal;
}

.cursor-pointer {
    cursor: pointer;
}

.scale-150 {
    transform: scale(1.5);
}

.form-check-input {
    cursor: pointer;
}

.overflow-x-auto {
    overflow-x: auto !important;
}

.shamsi-datetime {
    unicode-bidi: plaintext;
    text-align: right;
}

.d-block {
    display: block;
}

.cursor-pointer {
    cursor: pointer;
}

.no-select {
    user-select: none;
}

.list-unstyled {
    list-style-type: none;
    padding: 0;
    margin: 0;
    margin-bottom: 1rem;
}

.text-end {
    text-align: end;
}

.table-fixed {
    table-layout: fixed;
}

.d-none {
    display: none;
}

.col-8 {
    grid-column: span 8;
}

.col-4 {
    grid-column: span 4;
}

/* buttons */

.btn {
    padding: 0.5rem;
    border-radius: 0.25rem;
    align-items: center;
    color: var(--tw-gray-200) !important;
}

.btn-success {
    background: var(--tw-green-600);
}

.btn-primary {
    background: var(--tw-blue-800);
}

/* alerts */

.alert {
    padding: 1rem;
    border-radius: 0.25rem;
    margin-bottom: 1rem;
    text-align: justify;

    &.alert-danger {
        background: var(--tw-red-100);
        border: 1px solid var(--tw-red-300);
        color: var(--tw-red-500);
    }

    &.alert-warning {
        background: var(--tw-yellow-100);
        border: 1px solid var(--tw-yellow-300);
        color: var(--tw-yellow-500);
    }

    &.alert-info {
        background: var(--tw-blue-100);
        border: 1px solid var(--tw-blue-300);
        color: var(--tw-blue-500);
    }
}

/* cards */
.acc-card {
    border: 1px solid var(--acc-table-border-color);
    border-radius: 0.25rem;
    margin-bottom: 1rem;

    > div.header {
        background: var(--acc-table-even-row-background-color);
        border-bottom: 1px solid var(--acc-table-border-color);
        padding: 1rem;
        color: var(--acc-form-label-text-color);

        h4 {
            font-size: 1rem;
            margin: 0;
        }
    }

    > div.content {
        padding: 1rem;
    }
}


/* phone */
@media screen and (max-width: 639px) {
    :root {
        --acc-smart-spacing: 1rem;
        --acc-smart-columns: 1fr;
    }

    *[class*=grid-cols-] {
        grid-template-columns: 1fr;
    }
}
/* tablet */
@media screen and (min-width: 640px) and (max-width: 1023px) {
    :root {
        --acc-smart-spacing: 2rem;
        --acc-smart-columns: 2;
    }
}
/* desktop */
@media screen and (min-width: 1024px) {
    :root {
        --acc-smart-spacing: 3rem;
        --acc-smart-columns: 4;
    }
}
