@use "sass:color";

// ===================================
// UTILITIES (GENERATED FROM MAPS)
// ===================================
// Generator otomatis untuk variant warna (background light, soft, alert)
@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);
    }
}

// ===================================
// LANDING PAGE CUSTOM STYLING
// ===================================

html {
    scroll-behavior: smooth;
}

// Navbar Landing
.landing-navbar {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
    z-index: 1050;

    .navbar-brand {
        font-size: 1.25rem;

        i {
            font-size: 1.5rem;
        }

        @media (max-width: 575.98px) {
            font-size: 1.1rem;

            i {
                font-size: 1.25rem;
            }
        }
    }

    .navbar-toggler {
        padding: 0.25rem 0.5rem;

        &:focus {
            box-shadow: none;
        }
    }

    .navbar-nav {
        .nav-link-landing {
            padding: 0.5rem 1rem;
            color: #49769F;
            text-decoration: none;
            display: block;
            transition: color 0.3s ease;

            &:hover,
            &.active {
                color: #0C5495;
                font-weight: 500;
                transition: all 0.3s ease-in;
            }

            @media (max-width: 991.98px) {
                padding: 0.5rem 0;
            }
        }
    }

    @media (max-width: 991.98px) {
        .navbar-collapse {
            margin-top: 1rem;
            padding-top: 1rem;
            border-top: 1px solid rgba(0, 0, 0, 0.1);

            .navbar-nav {
                text-align: left !important;
                width: 100%;
            }

            .nav-item {
                margin: 0 !important;
                text-align: left !important;
            }

            .nav-link {
                width: 100%;
                justify-content: start;
                padding-left: 0.75rem;
                padding-right: 0.75rem;
            }
        }
    }
}

// Hero Section
.landing-hero-section {
    background: linear-gradient(135deg,
            #0C5495 0%,
            color.adjust(#0C5495, $lightness: 10%) 100%);
    padding: 60px 0;

    @media (min-width: 992px) {
        padding: 100px 0;
    }

    .btn-hero-solid {
        background-color: #fff !important;
        border-color: #fff !important;
        color: $primary !important;
        /* Menggunakan warna primary Anda #0C5495 */

        &:hover {
            background-color: lighten($primary, 70%) !important;
            /* Sedikit keabu-abuan saat hover */
            border-color: lighten($primary, 70%) !important;
            color: $primary !important;
        }
    }
}

.landing-hero-illustration {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;

    i {
        font-size: 5rem;
    }

}

.card-img-top {
    height: 200px;
    object-fit: cover;
}

.card-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
    min-height: 2.8rem;
    font-size: 0.9rem;

    @media (max-width: 575.98px) {
        font-size: 0.85rem;
        min-height: 2.4rem;
    }
}

// Stat Card
.landing-stat-card {
    transition: all 0.3s ease;

    &:hover {
        transform: translateY(-3px);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12) !important;
    }

    h2 {
        font-size: 2rem;

        @media (min-width: 768px) {
            font-size: 2.5rem;
        }
    }
}

// CTA Section
.landing-cta-section {
    background: linear-gradient(135deg,
            #0C5495 0%,
            color.adjust(#0C5495, $lightness: 10%) 100%);
    border-radius: 1rem;

    @media (min-width: 768px) {
        border-radius: 1.5rem;
    }
}


// ===================================
// BASE COMPONENTS
// ===================================
// Styling komponen Bootstrap yang dioverride

.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;
        }
    }
}

// Styling button dengan efek hover dan active
.btn {
    padding: 0.5rem 1.5rem;
    font-weight: 500;
    border-radius: 0.6rem;
    transition: all 0.2s ease-in-out;

    &:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    }

    &:active {
        transform: translateY(0);
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
    }

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

.btn.btn-primary {
    background-color: $primary;
    border-color: $primary;
    color: #fff;

    &:hover {
        background-color: darken($primary, 5%);
        border-color: darken($primary, 5%);
        color: #fff;
    }

    &:active {
        background-color: darken($primary, 7%) !important;
        border-color: darken($primary, 7%) !important;
    }
}

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

// ===================================
// LAYOUT & NAVIGATION
// ===================================
// Struktur layout aplikasi (sidebar, main content, overlay)

body {
    background-color: map-get($grays, "light");
}

// Sidebar 
.sidebar {
    width: 270px;
    position: fixed;
    top: 0;
    bottom: 0;
    z-index: 1050;
    transition: all 0.3s ease;
}

.main-wrapper {
    transition: margin-left 0.3s ease;
}

// Overlay gelap untuk mobile sidebar
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1049;
    display: none;
}

.overlay.active {
    display: block;
}

// Desktop: sidebar selalu muncul, bisa diminimize
@media (min-width: 992px) {
    .sidebar {
        left: 0;
    }

    .main-wrapper {
        margin-left: 260px;
    }

    .sidebar.minimized {
        width: 70px;
    }

    .sidebar.minimized .nav-text,
    .sidebar.minimized .sidebar-title {
        display: none;
    }

    .sidebar.minimized .nav-link {
        justify-content: center;
    }

    .main-wrapper.sidebar-minimized {
        margin-left: 80px;
    }
}

@media (max-width: 991.98px) {
    .sidebar {
        left: -270px;
    }

    .sidebar.active {
        left: 0;
    }
}

// Styling navigasi sidebar
.sidebar .nav-link {
    font-weight: 500;
    margin: 0.3rem 0;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
}

.sidebar.bg-primary {
    .nav-link {
        color: rgba(255, 255, 255, 0.85);

        i {
            color: rgba(255, 255, 255, 0.85);
        }

        &.py-1 {
            color: rgba(255, 255, 255, 0.7);
        }
    }

    .nav-link:hover:not(.active),
    .nav-link.py-1:hover {
        background: rgba(255, 255, 255, 0.05);
        color: #fff;

        i {
            color: #fff;
        }
    }

    .nav-link.active {
        background: rgba(255, 255, 255, 0.1);
        color: #fff;
        font-weight: 600;

        i {
            color: #fff;
        }
    }
}

.sidebar.minimized .nav-link .ms-auto {
    display: none;
}

nav {
    border-bottom-left-radius: 5px;
    border-bottom-right-radius: 5px;
}

// Styling navbar
.navbar {
    border-bottom: none;

    .navbar-brand {
        font-size: 20px;
        color: var(--bs-dark-text-emphasis) !important;

        @media (max-width: 991.98px) {
            font-size: 18px;
        }
    }

    // Icon button circular di navbar (notifikasi, profile, dll)
    .nav-link,
    .btn-light {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        background-color: transparent;
        border: none;
        transition: background-color 0.2s ease-in-out;

        &:hover,
        &:focus {
            background-color: var(--bs-light-bg-subtle);
        }
    }
}

// ===================================
// CUSTOM COMPONENTS
// ===================================
// Komponen custom yang dibuat sendiri

// Avatar profile circular
.profile-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    cursor: pointer;
}

// Item di dalam dropdown menu
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
}

.dropdown-item i {
    width: 1.25em;
}

// Dropdown notifikasi dengan responsive design
.notification-dropdown .dropdown-menu {
    width: 390px;
    max-width: calc(100vw - 20px);
    border-radius: 0.75rem;
    padding: 0.5rem !important;
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.12);
}

.notification-wrapper {
    max-height: 450px;
    overflow-y: auto;
}

.notification-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem 1rem;
    transition: background-color 0.2s ease;
    text-decoration: none !important;
}

.notification-item:hover {
    background-color: var(--bs-tertiary-bg);
}

.notification-item.unread {
    background-color: rgba(var(--bs-primary-rgb), 0.1);
}

.notification-icon {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.notification-icon i {
    text-align: center;
    font-size: 1.25rem;
}

.notification-content {
    flex: 1;
    min-width: 0;
}

.notification-content p {
    margin-bottom: 0.1rem;
    font-weight: 600;
    color: var(--bs-body-color);
    font-size: 0.925rem;
    line-height: 1.4;
}

.notification-content small {
    color: var(--bs-secondary-color);
    font-size: 0.8rem;
}

.unread-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--bs-primary);
    margin-left: auto;
    flex-shrink: 0;
}

// Responsive notifikasi untuk mobile
@media (max-width: 575.98px) {
    .notification-dropdown .dropdown-menu {
        position: fixed !important;
        top: 60px !important;
        right: 20px !important;
        left: auto !important;
        width: 320px !important;
        max-width: calc(100vw - 20px) !important;
        transform: none !important;
        margin: 0 !important;
    }

    .notification-wrapper {
        max-height: 50vh;
    }

    .notification-content p {
        font-size: 0.85rem;
        line-height: 1.3;
    }

    .notification-content small {
        font-size: 0.75rem;
    }

    .notification-icon {
        width: 36px;
        height: 36px;
    }

    .notification-icon i {
        font-size: 1.1rem;
    }

    .notification-item {
        gap: 0.6rem;
        padding: 0.65rem 0.75rem;
    }

    .notification-dropdown .dropdown-menu .px-3 {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    .notification-dropdown .dropdown-menu h6 {
        font-size: 0.95rem;
    }
}

// Icon wrapper untuk dashboard dan statistik
.icon-circle,
.icon-box {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: $transition;
}

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

.icon-box {
    width: 40px;
    height: 40px;
    border-radius: 10px;

    i {
        font-size: 1.2rem;
    }
}

// ===================================
// BOOK MANAGEMENT PAGES
// ===================================
// Styling khusus untuk halaman manajemen buku

// Cover buku dengan container gradient
.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;
    }
}

// Header section dengan border bottom
.section-header {
    padding-bottom: 15px;
    border-bottom: 2px solid map-get($grays, "light");

    h5 {
        color: map-get($grays, "dark");
        font-weight: 700;
    }
}

// Empty state untuk data kosong
.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;
    }
}

// Button primary soft variant
.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%)
}

;
}

// Text clamp untuk truncate multi line
.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 untuk seluruh aplikasi
::-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);
    }
}

// Card untuk select buku (dipakai di form peminjaman)
.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;
    }
}

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

// Item buku di list (dipakai di halaman detail peminjaman)
.book-item {
    background-color: map-get($grays, "light");
    border-left: 4px solid map-get($theme-colors, "primary");
}

// Card buku dengan checkbox (dipakai di halaman pilih buku untuk peminjaman)
.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);
        }
    }

    &: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;
}

// ===================================
// AUTH PAGES
// ===================================
// Styling untuk halaman login dan register

// Background gradient hero section
.hero-gradient {
    background: linear-gradient(135deg,
            map-get($theme-colors, "primary") 0%,
            color.adjust(map-get($theme-colors, "primary"), $lightness: 10%) 100%);
}

// Card untuk pilih role (admin/user)
.role-card {
    display: block;

    .card {
        transition: $transition;
        border-radius: 20px;

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

// Panel info di halaman auth
.info-panel {
    background: linear-gradient(135deg,
            map-get($theme-colors, "primary") 0%,
            color.adjust(map-get($theme-colors, "primary"), $lightness: 10%) 100%);
}

// Panel kiri auth (logo dan branding)
.auth-left-panel {
    padding: 3rem;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.auth-branding {
    max-width: 500px;

    .auth-logo {
        display: flex;
        align-items: center;
        gap: 1rem;
        margin-bottom: 1.5rem;

        h1 {
            font-size: 3rem;
            font-weight: 700;
            color: #fff;
            margin: 0;
            padding-bottom: 5px;
        }
    }
}

// Panel kanan auth (form)
.auth-right-panel {
    padding: 2rem;
}

// Card form auth
.auth-card {
    background-color: #ffffff;
    border: none;
    padding: 2.5rem;
    border-radius: 1.5rem;
    box-shadow: $shadow-md;

    @media (max-width: 576px) {
        padding: 2rem 1.5rem;
        box-shadow: none;
    }
}

// Responsive auth pages
@media (max-width: 991.98px) {
    .auth-left-panel {
        background-image: none !important;
        background-color: #0C5495;
        position: absolute !important;
        min-height: 40vh;
    }

    .d-lg-none {
        top: 5vh !important;
    }

    .auth-branding {
        .auth-logo {
            .icon-circle {
                width: 80px !important;
                height: 80px !important;
                border-radius: 20px !important;
            }

            h1 {
                font-size: 2.5rem;
            }
        }
    }
}

// ===================================
// DATATABLE STYLING
// ===================================
// Override styling DataTables

.dataTables_wrapper {

    .dataTables_length,
    .dataTables_filter,
    .dataTables_info,
    .dataTables_paginate {
        font-size: 0.875rem;
    }

    .dataTables_filter input {
        border-radius: $border-radius-sm;
        border: 1px solid #dee2e6;
        padding: 0.375rem 0.75rem;
        margin-left: 0.5rem;

        &:focus {
            outline: none;
            border-color: map-get($theme-colors, "primary");
            box-shadow: 0 0 0 0.2rem rgba(map-get($theme-colors, "primary"), 0.25);
        }
    }

    .dataTables_length select {
        border-radius: $border-radius-sm;
        border: 1px solid #dee2e6;
        padding: 0.375rem 2rem 0.375rem 0.75rem;
        margin: 0 0.5rem;
    }
}

// Responsive DataTables untuk mobile
@media screen and (max-width: 576px) {
    .dataTables_wrapper {

        .dataTables_length,
        .dataTables_filter {
            text-align: center;
            margin-bottom: 1rem;
        }

        .dataTables_info,
        .dataTables_paginate {
            text-align: center;
            margin-top: 1rem;
        }
    }

    table.dataTable td {
        white-space: normal !important;
    }
}

// ===================================
// CHART RESPONSIVE
// ===================================
// Container responsive untuk chart/grafik

.chart-responsive {
    position: relative;
    width: 100%;
    height: 300px;

    @media (min-width: 992px) {
        height: 450px;
    }
}

// ===================================
// PROFILE PAGE 
// ===================================


// Avatar 
.profile-avatar-lg {
    width: 80px;
    height: 80px;

    @media (max-width: 575.98px) {
        width: 64px;
        height: 64px;
    }
}

// Statistik container responsive
.stats-container {
    @media (max-width: 575.98px) {
        .stat-item {
            padding: 1rem 0;
            border-bottom: 1px solid rgba(0, 0, 0, 0.1);

            &:last-child {
                border-bottom: none;
            }
        }
    }
}

.laporan-list {
    @media (max-width: 575.98px) {
        .list-group-item {
            flex-direction: column;
            align-items: flex-start !important;
            gap: 0.25rem;
        }
    }
}
