:root {
    --sidebar-top: 82px;
}

.history-icon-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    position: fixed;
    right: 16px;
    top: 74px;
    background: #FFFFFF;
    border: 0.5px solid #EBE9F6;
    box-shadow: 1px 2px 6px -1px rgba(0, 0, 0, 0.08);
    border-radius: 24px;
    z-index: 2;
    width: 32px;
    height: 32px;
    cursor: pointer;
}

body:has(.history-sidebar.open) .history-icon-btn {
    display: none;
}

/* Tooltip Styles */
.history-icon-btn[data-tooltiptext]:hover::before {
    content: attr(data-tooltiptext);
    position: absolute;
    top: 50%;
    right: calc(100% + 10px);
    transform: translateY(-50%);
    display: flex;
    align-items: flex-start;
    padding: 4px 12px;
    background: #2A3342;
    border-radius: 8px;
    font-weight: 400;
    font-size: 12px;
    line-height: 18px;
    text-align: center;
    color: #FFFFFF;
    z-index: 10;
}

.history-icon-btn[data-tooltiptext]:hover::after {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: 100%;
    border: 6px solid transparent;
    border-left-color: #374151;
    z-index: 10;
}


.history-sidebar {
    position: fixed;
    top: var(--sidebar-top);
    bottom: 0;
    right: 20px;
    z-index: 11;
    height: 80vh;
    width: 100%;
    max-width: 460px;
    max-height: 718px;


    background: #FFFFFF;
    box-shadow: 0px 8px 48px 8px rgba(0, 0, 0, 0.08);
    border-radius: 18px;

    display: none;
    flex-direction: column;
}

.history-sidebar.open {
    display: flex;
}

.history-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
}

.history-sidebar:not(:has(.history-card)) .history-sidebar-header {
    border-bottom: 1px solid #EBE9F6;
}

.history-close-btn {
    outline: none;
    border: none;
    cursor: pointer;
    background-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-sidebar-title {
    font-weight: 700;
    font-size: 18px;
    line-height: 26px;
    color: #242424;
}

.history-sidebar-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    padding-bottom: 150px;
}

#history-list-container {
    flex: 1;
}

/* Shimmer Loading */
.shimmer-card {
    background: #fff;
    padding: 16px 24px;
    border-bottom: 1px solid var(--history-border);
}

.shimmer-line {
    height: 14px;
    background: #f0f0f0;
    border-radius: 4px;
    margin-bottom: 8px;
    position: relative;
    overflow: hidden;
}

.shimmer-line.short {
    width: 60%;
}

.shimmer-line.x-short {
    width: 30%;
}

.shimmer-line::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

.history-header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.date-filter-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

#history-date-filter {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #FFFFFF;
    border: 1px solid #EBE9F6;
    border-radius: 99px;
    cursor: pointer;
    outline: none;
    padding: 6px 36px 6px 12px;
    min-width: fit-content;
    width: fit-content;
    font-weight: 400;
    font-size: 14px;
    line-height: 20px;
    color: #272D3C;
    overflow: visible;
}

#history-date-filter::-webkit-calendar-picker-indicator {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    cursor: pointer;
    opacity: 1;

    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M12.667 3v2.8M7.333 3v2.8M4 8.6h12m-6.667 2.8h3.334m-5.334 0h.006m3.328 2.8H7.333m5.334 0h-.006m-1.994-9.8H9.333c-2.514 0-3.77 0-4.552.82S4 7.36 4 10v1.4c0 2.64 0 3.96.781 4.78s2.038.82 4.552.82h1.334c2.514 0 3.77 0 4.552-.82S16 14.04 16 11.4V10c0-2.64 0-3.96-.781-4.78s-2.038-.82-4.552-.82' stroke='%23272d3c' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 20px 20px;
}

#history-date-filter::-webkit-datetime-edit {
    text-align: center;
    min-width: fit-content;
}

#history-date-filter::-webkit-datetime-edit-fields-wrapper {
    display: flex;
    gap: 4px;
}

#history-date-filter::-webkit-datetime-edit-day-field,
#history-date-filter::-webkit-datetime-edit-month-field,
#history-date-filter::-webkit-datetime-edit-year-field {
    font-weight: 400;
    font-size: 14px;
    line-height: 20px;
    color: #242424;
}

#history-date-filter::-webkit-datetime-edit-text {
    padding: 0;
    color: #242424;
    z-index: 2;
}

.history-date-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    gap: 12px;
    background: #FAFBFC;
    border-width: 1px 0px;
    border-style: solid;
    border-color: #EBE9F6;
}

.history-date {
    font-weight: 500;
    font-size: 14px;
    line-height: 20px;
    color: #242424;
}

.history-file-count {
    font-weight: 500;
    font-size: 12px;
    line-height: 16px;
    color: #9A969E;
}

.history-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 16px 20px;
    gap: 12px;
    cursor: pointer;
}

.history-preview {
    font-weight: 400;
    font-size: 14px;
    line-height: 20px;
    color: #272D3C;
}

.history-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;

    span {
        font-weight: 500 !important;
        font-size: 12px !important;
        line-height: 16px !important;
        color: #9A969E;
    }
}

.history-sidebar-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-height: 150px;
    justify-content: center;
    align-items: flex-end;
    padding: 20px;
    gap: 12px;
    z-index: 12;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.5) 0%, #FFFFFF 100%);

    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 18px;
    display: none;
}

.history-sidebar:has(.load-more-btn[style="display: inline-flex;"]) .history-sidebar-footer {
    display: flex;
}

.load-more-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    gap: 4px;
    background: #FFFFFF;
    border: 1px solid #EBE9F6;
    border-radius: 99px;

    font-weight: 500;
    font-size: 14px;
    line-height: 20px;
    text-align: center;
    color: #242424;
}

.no-more-results {
    font-weight: 400;
    font-size: 14px;
    line-height: 20px;
    color: #272D3C;
    text-align: center;
}

.history-state.history-empty,
.history-state.history-locked {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    width: 100%;
    height: 100%;
}

.history-state-img {
    width: 150px;
    height: 110px;
    margin-bottom: 22px;
}

.no-history {
    font-weight: 500;
    font-size: 16px;
    line-height: 24px;
    color: #242424;
    margin-bottom: 6px;
}

.history-state.history-empty p,
.history-state.history-locked p {
    font-weight: 400;
    font-size: 14px;
    line-height: 20px;
    text-align: center;
    color: #9A969E;
    margin-bottom: 16px;
}

.get-premium-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 6px 12px;
    gap: 4px;
    background: linear-gradient(90deg, #7B61FF 0%, #E736F3 100%);
    border-radius: 99px;
    text-decoration: none;

    font-weight: 500;
    font-size: 14px;
    line-height: 20px;
    color: #FFFFFF;
}

.history-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;

    background: rgba(36, 36, 36, 0.4);
    backdrop-filter: blur(3px);
    z-index: 12;
    display: none;
    align-items: center;
    justify-content: center;
}

.history-modal.open {
    display: flex;
}

.history-modal-content {
    padding: 0px;
    border-radius: 24px;
    width: 100%;
    height: 100%;
    max-width: 800px;
    max-height: 600px;
    background-color: #FFFFFF;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 8px;
    gap: 8px;
    background: #FAFBFC;
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
}

.modal-header .modal-title {
    font-weight: 700;
    font-size: 16px;
    line-height: 24px;
    color: #4B5563;
}

.modal-header-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0px;
    gap: 8px;
}
.modal-header-actions .tooltip::after {
    left: 50%;
    transform: translateX(-50%);
}

.modal-header-actions button {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2px;
    gap: 10px;
    width: 24px;
    height: 24px;

    outline: none;
    border: none;
    cursor: pointer;
    background-color: transparent;
}

.modal-input-container {
    background: #FAFBFC;
    padding: 0 16px 8px 16px;
}

.modal-input {
    display: flex;
    align-items: start;
    padding: 8px;
    gap: 4px;
    background: #FFFFFF;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
}

.modal-input>div {
    font-weight: 500;
    font-size: 12px;
    line-height: 16px;
    color: #4B5563;
}

.input-text {
    font-weight: 500;
    font-size: 12px;
    line-height: 16px;
    color: #242424;
}

.modal-body {
    flex: 1;
    padding: 16px;
    background: #FFFFFF;
    border-width: 1px 0px;
    border-style: solid;
    border-color: #F3F4F6;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

.modal-output-content{
    flex: 1;
    font-weight: 500;
    line-height: 20px;
    color: #272D3C;
}
.modal-output-content * {
    font-size: 14px !important;
    text-align: justify;
}
.modal-output-content ul {
    padding-left: 20px;
}

.modal-footer {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 16px;
    gap: 6px;
    background: #FAFBFC;
    border-bottom-left-radius: 24px;
    border-bottom-right-radius: 24px;
}

.metadata-tags {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.metadata-tag {
    font-weight: 500;
    font-size: 12px;
    line-height: 16px;
    color: #242424;
    padding: 4px 8px;
    gap: 2px;
    background: #FFFFFF;
    border: 1px solid #E5E7EB;
    border-radius: 99px;
}

.metadata-tag span {
    font-weight: 500;
    font-size: 12px;
    line-height: 16px;
    color: #4B5563;
}

@media screen and (max-width: 768px) {
    .history-sidebar {
        right: 0;
        width: 100%;
        height: calc(100% - var(--sidebar-top));
        max-width: none;
        max-height: none;
        top: var(--sidebar-top);
        border-radius: 0;
    }

    body:has(.history-sidebar.open) {
        overflow: hidden;
    }

    .history-modal {
        width: 100%;
        height: calc(100% - var(--sidebar-top));
        max-width: none;
        max-height: none;
        top: var(--sidebar-top);
        border-radius: 0;
    }
    .modal-header,.modal-footer {
        border-radius: 0;
    }
    .history-modal-content {
        width: 100%;
        max-width: none;
        max-height: none;
        border-radius: 0;
    }
}
