/**
 * Drawer Panel Component Styles
 *
 * Provides slide-out panels that replace modal dialogs for better UX.
 * Maintains page context while allowing user actions.
 *
 * Version: 1.0
 * Date: February 9, 2026
 */

/* Backdrop */
.drawer-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1040;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.drawer-backdrop.show {
    opacity: 1;
}

/* Drawer Panel Base */
.drawer-panel {
    position: fixed;
    background: white;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    overflow: hidden;
}

/* Right Position (Default) */
.drawer-panel.drawer-right {
    top: 0;
    right: 0;
    height: 100%;
    transform: translateX(100%);
}

.drawer-panel.drawer-right.show {
    transform: translateX(0);
}

/* Left Position */
.drawer-panel.drawer-left {
    top: 0;
    left: 0;
    height: 100%;
    transform: translateX(-100%);
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
}

.drawer-panel.drawer-left.show {
    transform: translateX(0);
}

/* Bottom Position (Mobile) */
.drawer-panel.drawer-bottom {
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 90%;
    transform: translateY(100%);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.15);
    border-radius: 12px 12px 0 0;
}

.drawer-panel.drawer-bottom.show {
    transform: translateY(0);
}

/* Sizes */
.drawer-panel.drawer-small {
    width: 360px;
}

.drawer-panel.drawer-medium {
    width: 500px;
}

.drawer-panel.drawer-large {
    width: 700px;
}

.drawer-panel.drawer-full {
    width: 100%;
}

/* Mobile: Always full width */
@media (max-width: 768px) {
    .drawer-panel.drawer-right,
    .drawer-panel.drawer-left {
        width: 100% !important;
    }
}

/* Header */
.drawer-header {
    padding: 1.5rem;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.drawer-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #212529;
}

.drawer-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #6c757d;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.25rem;
    transition: all 0.2s ease;
}

.drawer-close:hover {
    background-color: #f8f9fa;
    color: #212529;
}

.drawer-close:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

/* Body */
.drawer-body {
    padding: 1.5rem;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Custom scrollbar */
.drawer-body::-webkit-scrollbar {
    width: 8px;
}

.drawer-body::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.drawer-body::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.drawer-body::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Footer */
.drawer-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #dee2e6;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-shrink: 0;
    background: #f8f9fa;
}

/* Forms inside drawer */
.drawer-body .form-group,
.drawer-body .mb-3 {
    margin-bottom: 1.25rem;
}

.drawer-body label {
    font-weight: 500;
    margin-bottom: 0.5rem;
}

/* Sections inside drawer */
.drawer-section {
    margin-bottom: 2rem;
}

.drawer-section:last-child {
    margin-bottom: 0;
}

.drawer-section-title {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #6c757d;
    margin-bottom: 1rem;
    letter-spacing: 0.5px;
}

/* Info boxes inside drawer */
.drawer-info-box {
    background: #e7f3ff;
    border-left: 3px solid #0d6efd;
    padding: 1rem;
    margin-bottom: 1.5rem;
    border-radius: 0.25rem;
}

.drawer-info-box p {
    margin: 0;
    font-size: 0.875rem;
    color: #004085;
}

.drawer-info-box.warning {
    background: #fff3cd;
    border-left-color: #ffc107;
}

.drawer-info-box.warning p {
    color: #856404;
}

.drawer-info-box.success {
    background: #d4edda;
    border-left-color: #28a745;
}

.drawer-info-box.success p {
    color: #155724;
}

/* List groups inside drawer */
.drawer-body .list-group {
    margin-bottom: 1.5rem;
}

.drawer-body .list-group-item {
    border-left: none;
    border-right: none;
}

.drawer-body .list-group-item:first-child {
    border-top: none;
}

.drawer-body .list-group-item:last-child {
    border-bottom: none;
}

/* Stats inside drawer */
.drawer-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #e9ecef;
}

.drawer-stat:last-child {
    border-bottom: none;
}

.drawer-stat-label {
    font-weight: 500;
    color: #495057;
}

.drawer-stat-value {
    font-weight: 600;
    color: #212529;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .drawer-header {
        padding: 1rem;
    }

    .drawer-body {
        padding: 1rem;
    }

    .drawer-footer {
        padding: 0.75rem 1rem;
        flex-direction: column;
    }

    .drawer-footer .btn {
        width: 100%;
    }

    .drawer-panel.drawer-bottom {
        max-height: 95%;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .drawer-panel {
        background: #212529;
        color: #f8f9fa;
    }

    .drawer-header {
        border-bottom-color: #495057;
    }

    .drawer-title {
        color: #f8f9fa;
    }

    .drawer-close {
        color: #adb5bd;
    }

    .drawer-close:hover {
        background-color: #343a40;
        color: #f8f9fa;
    }

    .drawer-footer {
        border-top-color: #495057;
        background: #343a40;
    }

    .drawer-info-box {
        background: #0d3a58;
    }

    .drawer-info-box p {
        color: #b3d7f7;
    }
}

/* Animations for stacking */
.drawer-panel:nth-of-type(1) {
    z-index: 1050;
}

.drawer-panel:nth-of-type(2) {
    z-index: 1060;
}

.drawer-panel:nth-of-type(3) {
    z-index: 1070;
}

/* Loading state */
.drawer-body.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.drawer-body.loading::before {
    content: '';
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0d6efd;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Empty state */
.drawer-empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: #6c757d;
}

.drawer-empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.drawer-empty-state h5 {
    margin-bottom: 0.5rem;
    color: #495057;
}

.drawer-empty-state p {
    margin: 0;
    font-size: 0.875rem;
}
