/* overrides / extras on top of site2.css */

@font-face {
    font-family: 'Estedad';
    src: local('Tahoma');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'Estedad';
    src: local('Tahoma');
    font-weight: bold;
}

@font-face {
    font-family: 'Vazir';
    src: local('Tahoma');
    font-weight: normal;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    max-width: 100%;
}

body {
    overflow-x: hidden;
    max-width: 100%;
    font-family: Vazir, Estedad, Tahoma, 'Segoe UI', sans-serif !important;
}

img, video, canvas, svg {
    max-width: 100%;
    height: auto;
}

/* ===== Single-level right sidebar ===== */
.main-menu,
.sub-menu {
    display: none !important;
}

.side-nav {
    width: 240px;
    height: 100%;
    background: #fff;
    position: fixed;
    right: 0;
    top: 0;
    z-index: 1100;
    overflow-x: hidden;
    overflow-y: auto;
    border-left: 1px solid #e6ebf2;
    box-shadow: -2px 0 12px rgba(23, 50, 77, .04);
}

.side-nav .systemInfo {
    padding: 1.25rem 1rem 1rem;
    text-align: center;
    border-bottom: 1px solid #eef2f7;
    top: 0 !important;
}

.side-nav .systemInfo a {
    text-decoration: none;
    color: inherit;
}

.side-nav .systemInfo img {
    width: 64px;
    height: auto;
}

.side-nav .organname {
    margin-top: .5rem;
    font-size: .85rem;
    color: #6b7785;
    width: auto !important;
}

.side-nav .systemname {
    font-weight: 700;
    color: #383EC0;
    font-size: .95rem;
    width: auto !important;
}

.side-nav-links {
    padding: .75rem .65rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: .35rem;
}

.side-nav .menuItem {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .7rem .85rem;
    border-radius: .65rem;
    color: #334155 !important;
    text-decoration: none !important;
    font-weight: 500;
}

.side-nav .menuItem .bi {
    font-size: 1.15rem;
    color: #383EC0;
    flex-shrink: 0;
}

.side-nav .menuItem:hover,
.side-nav .menuItem.selectedmenu {
    background: #eef1ff;
    color: #383EC0 !important;
}

.main-content {
    right: 240px !important;
    left: 0 !important;
    max-width: 100%;
}

.mobile-nav-toggle {
    display: none;
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 1200;
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 10px;
    background: #383EC0;
    color: #fff;
    box-shadow: 0 4px 14px rgba(56, 62, 192, .35);
    align-items: center;
    justify-content: center;
}

.sidebar-backdrop {
    display: none;
}

.page-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.quota-box {
    background: #f7f9fc;
    border: 1px solid #e3e8ef;
    border-radius: .5rem;
    padding: .55rem .85rem;
    max-width: 100%;
}

.cards-container {
    min-height: 120px;
    max-width: 100%;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
    gap: 1rem;
    max-width: 100%;
}

.item-card {
    background: #fff;
    border: 1px solid #e6ebf2;
    border-radius: 14px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: .75rem;
    box-shadow: 0 8px 20px rgba(23, 50, 77, .04);
    min-width: 0;
    max-width: 100%;
}

.item-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: #eef1ff;
    color: #383EC0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    font-size: 1.35rem;
    flex-shrink: 0;
}

.item-card-icon.ok { background: #e8f8ef; color: #198754; }
.item-card-icon.fail { background: #fdebec; color: #dc3545; }

.ext-badge {
    position: absolute;
    bottom: -6px;
    left: -6px;
    background: #383EC0;
    color: #fff;
    font-size: .65rem;
    padding: .1rem .35rem;
    border-radius: .35rem;
    text-transform: uppercase;
}

.item-card-body {
    min-width: 0;
}

.item-card-title {
    font-size: 1rem;
    margin: 0;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.item-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem .85rem;
    color: #6b7785;
    font-size: .85rem;
}

.status-pill {
    background: #eef1ff;
    color: #383EC0;
    border-radius: 999px;
    padding: .1rem .55rem;
}

.share-line {
    display: flex;
    gap: .5rem;
    align-items: center;
    margin-top: .35rem;
    min-width: 0;
}

.share-url {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .82rem;
    direction: ltr;
    text-align: left;
}

.item-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-top: auto;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #7a8694;
}

.empty-state .bi {
    font-size: 2.5rem;
    display: block;
    margin-bottom: .75rem;
}

.welcome {
    max-width: 640px;
    margin: 3rem auto;
    text-align: center;
    padding: 0 1rem;
}

.download-gate {
    max-width: 480px;
    margin: 2rem auto;
    background: #fff;
    border-radius: .75rem;
    padding: 1.25rem;
    box-shadow: 0 10px 30px rgba(23, 50, 77, .08);
}

.download-gate .file-name {
    font-weight: 700;
    font-size: 1.05rem;
}

/* ===== Dialog ===== */
#win.modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(15, 23, 42, .45);
    overflow-x: hidden;
    overflow-y: auto;
    padding: 1rem;
    display: none;
}

#win .modal-dialog {
    width: 100%;
    max-width: 480px;
    margin: 1.5rem auto;
}

#win .modal-content {
    border-radius: 12px;
    overflow: hidden;
    max-width: 100%;
}

#win .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .85rem 1rem;
}

#win .modal-body {
    padding: 1rem;
    max-height: min(60vh, 420px);
    overflow: auto;
}

#win .modal-footer {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
    justify-content: flex-start;
    padding: .85rem 1rem;
}

#win #win-button {
    display: flex;
    flex: 1 1 auto;
    gap: .5rem;
}

#win #win-button .btn {
    min-width: 100px;
}

#win .modal-footer > .btn {
    flex: 0 0 auto;
}

#divFileUpload .upload-actions {
    margin-top: 1rem;
}

#divFileUpload .upload-actions .btn {
    width: 100%;
}

/* ===== Mobile ===== */
@media (max-width: 992px) {
    .mobile-nav-toggle {
        display: inline-flex;
    }

    .side-nav {
        width: min(280px, 86vw);
        right: 0;
        transform: translate3d(105%, 0, 0);
        transition: transform .25s ease;
        box-shadow: none;
        visibility: hidden;
        pointer-events: none;
    }

    body.nav-open .side-nav {
        transform: translate3d(0, 0, 0);
        visibility: visible;
        pointer-events: auto;
        box-shadow: -8px 0 28px rgba(15, 23, 42, .18);
    }

    body.nav-open {
        overflow: hidden;
    }

    .main-content {
        right: 0 !important;
        left: 0 !important;
        width: 100% !important;
        max-width: 100vw !important;
        position: relative !important;
        height: auto !important;
        min-height: 100vh;
        overflow-x: hidden !important;
        overflow-y: visible !important;
    }

    .header-panel {
        position: sticky;
        top: 0;
        z-index: 100;
        height: auto !important;
        min-height: 64px;
        padding: .75rem 3.25rem .75rem .85rem;
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }

    .sitemapper {
        position: static !important;
        display: inline-block;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        margin: 0;
    }

    .userInfoHeader {
        position: static !important;
        text-align: right;
        margin-top: .4rem;
        max-width: 100%;
        overflow: hidden;
    }

    .userInfoHeader .user {
        max-width: 100%;
    }

    .userInfoHeader .username,
    .userInfoHeader .userrole {
        display: inline-block;
        max-width: 42vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        top: 0 !important;
        left: 0 !important;
        vertical-align: middle;
    }

    .userInfoHeader .userrole {
        display: none;
    }

    .main-panel {
        position: relative !important;
        top: 0 !important;
        bottom: auto !important;
        width: 100% !important;
        max-width: 100%;
        padding: .75rem;
        overflow-x: hidden !important;
        overflow-y: visible !important;
    }

    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, .45);
        z-index: 1050;
    }

    body.nav-open .sidebar-backdrop {
        display: block;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .btn-label {
        display: none;
    }

    #win.modal {
        padding: .5rem;
        align-items: flex-end;
    }

    #win .modal-dialog {
        margin: .5rem auto;
        max-width: calc(100vw - 1rem);
        width: calc(100vw - 1rem);
    }

    #win .modal-body {
        max-height: 55vh;
        padding: .85rem;
    }

    #win .modal-footer {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    #win #win-button {
        width: 100%;
        flex-direction: column;
    }

    #win #win-button .btn,
    #win .modal-footer > .btn {
        width: 100%;
        min-width: 0;
    }

    body.modal-open {
        overflow: hidden;
    }
}

@media (max-width: 576px) {
    .page-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .quota-box .progress {
        max-width: 100% !important;
        width: 100%;
    }

    .share-line {
        flex-direction: column;
        align-items: stretch;
    }

    .item-card-actions .btn {
        flex: 1;
    }

    .form-control {
        max-width: 100%;
    }

    input[type="file"].form-control {
        padding: .4rem;
        font-size: .85rem;
    }
}
