// Drawer Component Styles
// Slide-out panel from screen edges

// Mask/overlay
.hi-drawer-mask {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.45);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;

    &.hi-drawer-mask-visible {
        opacity: 1;
    }
}

// Base drawer container
.hi-drawer {
    position: fixed;
    z-index: 1001;
    background-color: var(--hi-surface, #ffffff);
    box-shadow: var(--hi-shadow-xl, 0 20px 25px -5px rgba(0, 0, 0, 0.1));
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

// Position variants
.hi-drawer-right {
    top: 0;
    right: 0;
    height: 100vh;
    width: 256px;
    transform: translateX(100%);

    &.hi-drawer-open {
        transform: translateX(0);
    }
}

.hi-drawer-left {
    top: 0;
    left: 0;
    height: 100vh;
    width: 256px;
    transform: translateX(-100%);

    &.hi-drawer-open {
        transform: translateX(0);
    }
}

.hi-drawer-top {
    top: 0;
    left: 0;
    width: 100vw;
    height: 256px;
    transform: translateY(-100%);

    &.hi-drawer-open {
        transform: translateY(0);
    }
}

.hi-drawer-bottom {
    bottom: 0;
    left: 0;
    width: 100vw;
    height: 256px;
    transform: translateY(100%);

    &.hi-drawer-open {
        transform: translateY(0);
    }
}

// Drawer header
.hi-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--hi-border, rgba(0, 0, 0, 0.1));
}

.hi-drawer-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--hi-text-primary, #333);
    margin: 0;
}

.hi-drawer-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 4px;
    color: var(--hi-text-secondary, #666);
    transition: all 0.2s ease;

    &:hover {
        background-color: var(--hi-color-background, #f5f5f5);
        color: var(--hi-text-primary, #333);
    }

    &:active {
        background-color: rgba(0, 0, 0, 0.1);
    }
}

// Drawer body
.hi-drawer-body {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    overflow-x: hidden;
    color: var(--hi-text-primary, #333);
    line-height: 1.5;

    // Scrollbar styling
    &::-webkit-scrollbar {
        width: 6px;
    }

    &::-webkit-scrollbar-track {
        background: transparent;
    }

    &::-webkit-scrollbar-thumb {
        background: var(--hi-border, rgba(0, 0, 0, 0.2));
        border-radius: 3px;

        &:hover {
            background: var(--hi-color-border, rgba(0, 0, 0, 0.35));
        }
    }
}

// Drawer footer
.hi-drawer-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--hi-border, rgba(0, 0, 0, 0.1));
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

// Dark theme adjustments
[data-theme="dark"] .hi-drawer,
[data-theme="tairitsu"] .hi-drawer {
    background-color: rgba(0, 0, 0, 0.95);
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .hi-drawer-header,
[data-theme="tairitsu"] .hi-drawer-header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .hi-drawer-title,
[data-theme="tairitsu"] .hi-drawer-title {
    color: var(--hi-text-primary, #e0e0e0);
}

[data-theme="dark"] .hi-drawer-close,
[data-theme="tairitsu"] .hi-drawer-close {
    color: var(--hi-text-secondary, #b0b0b0);

    &:hover {
        background-color: rgba(255, 255, 255, 0.1);
        color: var(--hi-text-primary, #e0e0e0);
    }

    &:active {
        background-color: rgba(255, 255, 255, 0.15);
    }
}

[data-theme="dark"] .hi-drawer-body,
[data-theme="tairitsu"] .hi-drawer-body {
    color: var(--hi-text-primary, #e0e0e0);
}

[data-theme="dark"] .hi-drawer-footer,
[data-theme="tairitsu"] .hi-drawer-footer {
    border-top-color: rgba(255, 255, 255, 0.1);
}

// High contrast mode support
@media (prefers-contrast: high) {
    .hi-drawer {
        border: 2px solid var(--hi-color-border, #000);
    }

    .hi-drawer-header,
    .hi-drawer-footer {
        border-width: 2px;
    }
}

// Accessibility: respect prefers-reduced-motion
@media (prefers-reduced-motion: reduce) {
    .hi-drawer,
    .hi-drawer-mask {
        transition: opacity 0.1s ease, transform 0.1s ease;
    }
}

// Responsive width adjustments
@media (max-width: 768px) {
    .hi-drawer-right,
    .hi-drawer-left {
        width: 80vw;
        max-width: 300px;
    }

    .hi-drawer-top,
    .hi-drawer-bottom {
        height: 40vh;
        max-height: 300px;
    }
}

@media (max-width: 480px) {
    .hi-drawer-right,
    .hi-drawer-left {
        width: 100vw;
    }
}
