@use "sass:color";

// ===================================
// VARIABLES & MAPS
// ===================================

// Theme Colors Map
$theme-colors: (
    "primary": #435ebe,
    "secondary": color.mix(#6c757d, #ffffff, 80%),
    "success": color.mix(#198754, #ffffff, 85%),
    "info": color.mix(#0dcaf0, #ffffff, 80%),
    "warning": color.mix(#ffc107, #ffffff, 80%),
    "danger": color.mix(#dc3545, #ffffff, 80%),
);

// Gray Colors Map
$grays: (
    "light": #f4f7f8,
    "dark": #4c5053,
);

// Spacing & Sizing
$border-radius: 0.5rem;
$border-radius-sm: 0.25rem;
$border-radius-lg: 1rem;

// Shadows & Transitions
$card-box-shadow: 0 0 1.25rem rgba(33, 37, 41, 0.05);
$shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.08);
$shadow-md: 0 4px 8px rgba(0, 0, 0, 0.12);
$shadow-lg: 0 8px 20px rgba(0, 0, 0, 0.15);
$transition: all 0.3s ease;

// ===================================
// UTILITIES (GENERATED FROM MAPS)
// ===================================
@each $color, $value in $theme-colors {
    .bg-#{$color}-light {
        background-color: rgba($value, 0.25) !important;
    }
    .bg-#{$color}-soft {
        background-color: rgba($value, 0.25);
        color: $value;
    }
    .alert-#{$color} {
        background-color: rgba($value, 0.2);
        color: color.adjust($value, $lightness: -25%);
        border-color: rgba($value, 0.3);
    }
}

// ===================================
// BASE COMPONENTS
// ===================================

.card {
    box-shadow: $card-box-shadow;
    .card-header {
        background-color: #fff;
        border-bottom: 1px solid rgba(map-get($grays, "dark"), 0.1);
    }
}

.alert {
    border-radius: $border-radius;
    box-shadow: $shadow-sm;
    .alert-icon {
        width: 24px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

.modal {
    .modal-content {
        border: none;
        border-radius: $border-radius-lg;
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
        .modal-header,
        .modal-footer {
            border-color: rgba(map-get($grays, "dark"), 0.1);
            padding: 1.5rem;
        }
        .modal-title {
            color: map-get($grays, "dark");
            font-weight: 700;
        }
    }
}

.btn {
    padding: 0.5rem 1.5rem;
    font-weight: 500;
    &.btn-sm {
        padding: 0.375rem 1.25rem;
        font-size: 0.875rem;
    }
}

.badge.rounded-pill {
    font-weight: 500;
    padding: 0.5rem 1rem;
}

// ===================================
// CUSTOM COMPONENTS
// ===================================

.icon-circle,
.icon-box {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: $transition;
}

.icon-circle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
}

.icon-box {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    i {
        font-size: 1.2rem;
    }
}

.book-cover {
    transition: $transition;
    border-radius: $border-radius-sm;
    &-container {
        background: linear-gradient(
            135deg,
            rgba(map-get($grays, "light"), 0.5) 0%,
            rgba(map-get($grays, "light"), 0.8) 100%
        );
        border-radius: $border-radius-sm 0 0 $border-radius-sm;
    }
}

.section-header {
    padding-bottom: 15px;
    border-bottom: 2px solid map-get($grays, "light");
    h5 {
        color: map-get($grays, "dark");
        font-weight: 700;
    }
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    i {
        font-size: 4rem;
        color: map-get($grays, "dark");
        margin-bottom: 1rem;
        opacity: 0.25;
    }
    p {
        color: map-get($grays, "dark");
        opacity: 0.7;
        font-size: 1rem;
        margin: 0;
    }
}

.btn-primary-soft {
    --bs-btn-color: #{map-get($grays, "dark")};
    --bs-btn-bg: #{map-get($theme-colors, "primary")};
    --bs-btn-border-color: #{map-get($theme-colors, "primary")};
    --bs-btn-hover-color: #{map-get($grays, "dark")};
    --bs-btn-hover-bg: #{color.adjust(
            map-get($theme-colors, "primary"),
            $lightness: -5%
        )};
    --bs-btn-hover-border-color: #{color.adjust(
            map-get($theme-colors, "primary"),
            $lightness: -7.5%
        )};
}

// ===================================
// UTILITIES & CUSTOMIZATIONS
// ===================================

.line-clamp-2,
.line-clamp-3 {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}
.line-clamp-2 {
    -webkit-line-clamp: 2;
}
.line-clamp-3 {
    -webkit-line-clamp: 3;
}

// Custom Scrollbar
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: map-get($grays, "light");
    border-radius: 3px;
}
::-webkit-scrollbar-thumb {
    background: rgba(map-get($grays, "dark"), 0.25);
    border-radius: 3px;
    &:hover {
        background: rgba(map-get($grays, "dark"), 0.4);
    }
}

// ===================================
// Style untuk kartu pemilihan buku di dalam modal
// ===================================

.card-book-select {
    cursor: pointer;
    position: relative;
    transition: $transition;

    &:hover {
        transform: translateY(-5px);
        box-shadow: $shadow-md;
    }

    .card-select-overlay {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(#435ebe, 0.7);
        display: flex;
        align-items: center;
        justify-content: center;
        opacity: 0;
        transition: $transition;
        border-radius: $border-radius-sm;

        i {
            text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
        }
    }

    &.selected {
        border: 2px solid map-get($theme-colors, "primary");

        .card-select-overlay {
            opacity: 1;
        }
    }

    &.disabled {
        cursor: not-allowed;
        opacity: 0.6;
    }
}

// ===================================
// Styling untuk Form Peminjaman
// ===================================

.form-book-cover {
    width: 60px;
    height: 80px;
    object-fit: cover;
}

.book-item {
    background-color: map-get($grays, "light");
    border-left: 4px solid map-get($theme-colors, "primary");
}

// Styling untuk kartu buku di dalam modal pemilihan
.book-card {
    cursor: pointer;
    transition: $transition;
    border: 2px solid transparent;
    box-shadow: $card-box-shadow;

    &:hover {
        transform: translateY(-2px);
        border-color: map-get($theme-colors, "primary");
        box-shadow: $shadow-md;
        .book-cover {
            transform: scale(1.03);
        }
    }

    // Style khusus ketika checkbox di dalamnya terpilih
    &:has(.book-checkbox:checked) {
        border-color: map-get($theme-colors, "success");
        background-color: rgba(map-get($theme-colors, "success"), 0.05);
    }
}

.remove-book {
    padding: 2px 6px;
    font-size: 12px;
}

.btn.disabled {
    pointer-events: none;
    opacity: 0.65;
}

.book-option[style*="display: none"] {
    display: none !important;
}
