/* Custom Styles for SISBIM - MA Ulil Amwal */

:root {
    --primary-color: #006a67;
    --secondary-color: #28a745;
    --success-color: #20c997;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --sidebar-width: 250px;
}

body {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
}

/* Sidebar Styles */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: linear-gradient(135deg, var(--primary-color), #004d4a);
    color: white;
    transition: all 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.sidebar.collapsed {
    width: 70px;
}

/* Sidebar Header */
.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-container {
    display: flex;
    align-items: center;
    flex: 1;
}

.sidebar-logo {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    margin-right: 12px;
}

.logo-text h4 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: bold;
    color: white;
}

.logo-text p {
    margin: 0;
    font-size: 0.75rem;
    opacity: 0.8;
    color: white;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.1rem;
    padding: 5px;
    border-radius: 5px;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    z-index: 1002;
}

.sidebar-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.sidebar.collapsed .logo-text {
    display: none;
}

/* Keep toggle button visible but reposition it in collapsed sidebar */
.sidebar.collapsed .sidebar-toggle {
    position: absolute;
    top: 15px;
    right: -40px;
    background: var(--primary-color);
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 1001;
}

.sidebar.collapsed .sidebar-toggle:hover {
    background: #004d4a;
    transform: scale(1.1);
}

.sidebar.collapsed .logo-container {
    justify-content: center;
}

.sidebar.collapsed .sidebar-logo {
    margin-right: 0;
}

/* Sidebar Menu */
.sidebar-menu {
    flex: 1;
    padding: 10px 0;
    overflow-y: auto;
}

.sidebar-menu .nav-item {
    margin-bottom: 2px;
}

.sidebar-menu .nav-link {
    color: rgba(255, 255, 255, 0.8);
    padding: 12px 20px;
    border-radius: 0;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    text-decoration: none;
    position: relative;
}

.sidebar-menu .nav-link:hover,
.sidebar-menu .nav-link.active {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.sidebar-menu .nav-link.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background-color: #28a745;
}

.nav-icon {
    font-size: 1rem;
    width: 24px;
    text-align: center;
    margin-right: 12px;
}

.nav-text {
    flex: 1;
}

.nav-dropdown-toggle {
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.nav-caret {
    font-size: 0.75rem;
    margin-left: auto;
    transition: transform 0.2s ease;
}

.nav-dropdown.open .nav-caret {
    transform: rotate(180deg);
}

.nav-submenu {
    display: none;
    list-style: none;
    margin: 2px 0 6px;
    padding: 4px 0 4px 56px;
}

.nav-dropdown.open .nav-submenu {
    display: block;
}

.nav-sublink {
    display: block;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.9rem;
    line-height: 1.25;
    padding: 8px 18px 8px 0;
    text-decoration: none;
    border-radius: 4px;
    transition: color 0.2s ease, padding-left 0.2s ease;
}

.nav-sublink:hover,
.nav-sublink.active {
    color: #fff;
    padding-left: 4px;
}

.nav-sublink.active {
    font-weight: 600;
}

/* Hide text in collapsed sidebar */
.sidebar.collapsed .nav-text {
    display: none;
}

.sidebar.collapsed .nav-caret,
.sidebar.collapsed .nav-submenu {
    display: none;
}

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

.sidebar.collapsed .nav-icon {
    margin-right: 0;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    transition: all 0.3s ease;
    min-height: 100vh;
}

.main-content.expanded {
    margin-left: 70px;
}

/* Top Navigation */
.top-navbar {
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Cards */
.dashboard-card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.dashboard-card:hover {
    transform: translateY(-5px);
}

.dashboard-card .card-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

/* Tables */
.table-container {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.table-container .table th {
    background-color: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
}

/* Forms */
.form-container {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 30px;
}

/* Buttons */
.btn-custom {
    border-radius: 25px;
    padding: 10px 25px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-custom:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1050;
    }

    .sidebar.mobile-view.show {
        transform: translateX(0);
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }

    .sidebar.collapsed.mobile-view {
        transform: translateX(-100%);
    }

    .main-content {
        margin-left: 0;
    }

    .main-content.expanded {
        margin-left: 0;
    }

    .table-container {
        overflow-x: auto;
    }

    .mobile-menu-toggle {
        display: block;
        position: fixed;
        top: 20px;
        left: 20px;
        z-index: 1040;
        background: var(--primary-color);
        color: white;
        border: none;
        padding: 10px 15px;
        border-radius: 5px;
        cursor: pointer;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    }

    .mobile-menu-toggle:hover {
        background: #004d4a;
    }

    .sidebar-header {
        padding: 15px;
    }
}

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

.mobile-overlay.show {
    display: block;
}

/* Animation enhancements */
@keyframes slideInFromLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.sidebar.mobile-view.show {
    animation: slideInFromLeft 0.3s ease;
}

/* Improved focus styles for accessibility */
.sidebar-menu .nav-link:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

.sidebar-toggle:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

/* Enhanced transitions */
.sidebar-menu .nav-link {
    position: relative;
    overflow: hidden;
}

.sidebar-menu .nav-link::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.1),
        transparent
    );
    transition: left 0.5s ease;
}

.sidebar-menu .nav-link:hover::before {
    left: 100%;
}

/* Mobile responsive fixes for toggle button */
@media (max-width: 768px) {
    /* Reset toggle button positioning on mobile */
    .sidebar.collapsed .sidebar-toggle {
        position: static !important;
        right: auto !important;
        top: auto !important;
        width: auto !important;
        height: auto !important;
        border-radius: 5px !important;
        background: none !important;
        box-shadow: none !important;
    }

    .sidebar.collapsed .sidebar-toggle:hover {
        background-color: rgba(255, 255, 255, 0.1) !important;
        transform: none !important;
    }
}

/* Utility Classes */
.text-primary-custom {
    color: var(--primary-color);
}

.bg-primary-custom {
    background-color: var(--primary-color);
}

.border-primary-custom {
    border-color: var(--primary-color);
}

/* Loading Spinner */
.spinner-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
}

/* Alert Custom */
.alert-custom {
    border: none;
    border-radius: 10px;
    padding: 15px 20px;
}

/* Footer */
.footer {
    background: white;
    padding: 20px;
    text-align: center;
    border-top: 1px solid #dee2e6;
    margin-top: auto;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1050;
    }

    .sidebar.mobile-view.show {
        transform: translateX(0);
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }

    .sidebar.collapsed.mobile-view {
        transform: translateX(-100%);
    }

    .main-content {
        margin-left: 0;
    }

    .main-content.expanded {
        margin-left: 0;
    }

    .table-container {
        overflow-x: auto;
    }

    .mobile-menu-toggle {
        display: block;
        position: fixed;
        top: 20px;
        left: 20px;
        z-index: 1040;
        background: var(--primary-color);
        color: white;
        border: none;
        padding: 10px 15px;
        border-radius: 5px;
        cursor: pointer;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    }

    .mobile-menu-toggle:hover {
        background: #004d4a;
    }

    .sidebar-header {
        padding: 15px;
    }
}

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

.mobile-overlay.show {
    display: block;
}

/* Animation enhancements */
@keyframes slideInFromLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.sidebar.mobile-view.show {
    animation: slideInFromLeft 0.3s ease;
}

/* Improved focus styles for accessibility */
.sidebar-menu .nav-link:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

.sidebar-toggle:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

/* Enhanced transitions */
.sidebar-menu .nav-link {
    position: relative;
    overflow: hidden;
}

.sidebar-menu .nav-link::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.1),
        transparent
    );
    transition: left 0.5s ease;
}

.sidebar-menu .nav-link:hover::before {
    left: 100%;
}

/* Mobile responsive fixes for toggle button */
@media (max-width: 768px) {
    /* Reset toggle button positioning on mobile */
    .sidebar.collapsed .sidebar-toggle {
        position: static !important;
        right: auto !important;
        top: auto !important;
        width: auto !important;
        height: auto !important;
        border-radius: 5px !important;
        background: none !important;
        box-shadow: none !important;
    }

    .sidebar.collapsed .sidebar-toggle:hover {
        background-color: rgba(255, 255, 255, 0.1) !important;
        transform: none !important;
    }
}
