/*
 * Toolana Custom Bootstrap Styles
 * Replaces TailwindCSS with Bootstrap 5 components
 */

/* Custom Button Styles (replacing Tailwind btn classes) */
.btn-primary {
    --bs-btn-bg: #2563eb;
    --bs-btn-border-color: #2563eb;
    background-color: var(--bs-btn-bg);
    border-color: var(--bs-btn-border-color);
}

.btn-primary:hover:not(:disabled) {
    --bs-btn-bg: #1d4ed8;
    --bs-btn-border-color: #1d4ed8;
    background-color: var(--bs-btn-bg);
    border-color: var(--bs-btn-border-color);
    transform: translateY(-1px);
    transition: all 0.2s ease-in-out;
}

.btn-primary:disabled {
    transform: none !important;
    opacity: 0.65;
}

.btn-secondary {
    background-color: #6b7280;
    border-color: #6b7280;
    color: #ffffff;
}

.btn-secondary:hover {
    background-color: #4b5563;
    border-color: #4b5563;
    color: #ffffff;
}

.btn-success {
    background-color: #059669;
    border-color: #059669;
}

.btn-success:hover {
    background-color: #047857;
    border-color: #047857;
}

.btn-danger {
    background-color: #dc2626;
    border-color: #dc2626;
}

.btn-danger:hover {
    background-color: #b91c1c;
    border-color: #b91c1c;
}

.btn-warning {
    background-color: #d97706;
    border-color: #d97706;
    color: #ffffff;
}

.btn-warning:hover {
    background-color: #b45309;
    border-color: #b45309;
    color: #ffffff;
}

/* Custom Card Styles */
.card {
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    border: 1px solid #e5e7eb;
}

.card-header {
    background-color: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    padding: 1rem 1.25rem;
    border-radius: 0.5rem 0.5rem 0 0;
}

/* Custom Form Styles */
.form-control:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.25);
}

.form-label {
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.5rem;
}

/* Header Styles */
.navbar-brand {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Dropdown Menu Styles */
.dropdown-menu {
    border-radius: 0.375rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border: 1px solid #e5e7eb;
}

.dropdown-item:hover {
    background-color: #3b82f6;
    color: #ffffff;
}

/* Table Styles */
.table-custom {
    background-color: #ffffff;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.table-custom thead th {
    background-color: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    font-weight: 600;
    color: #374151;
}

/* Flash Message Styles */
.alert-custom {
    border-radius: 0.375rem;
    border: none;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border-left: 4px solid #10b981;
}

.alert-danger {
    background-color: #fee2e2;
    color: #991b1b;
    border-left: 4px solid #ef4444;
}

.alert-warning {
    background-color: #fef3c7;
    color: #92400e;
    border-left: 4px solid #f59e0b;
}

.alert-info {
    background-color: #dbeafe;
    color: #1e40af;
    border-left: 4px solid #3b82f6;
}

/* Background and Text Utilities */
.bg-gray-100 {
    background-color: #f3f4f6;
}

.bg-blue-600 {
    background-color: #2563eb;
}

.text-gray-800 {
    color: #1f2937;
}

.text-gray-600 {
    color: #4b5563;
}

/* Spacing Utilities (commonly used) */
.space-x-4 > * + * {
    margin-left: 1rem;
}

.space-y-4 > * + * {
    margin-top: 1rem;
}

/* Flex Utilities */
.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Custom Scrollbar (from original style.css) */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Animation for flash messages */
.flash-message {
    transition: opacity 0.3s ease-in-out;
}

/* JSON Editor Styles */
.jsoneditor {
    border: 1px solid #d1d5db !important;
    border-radius: 0.375rem !important;
}

.jsoneditor-menu {
    background-color: #3b82f6 !important;
    border-bottom: 1px solid #2563eb !important;
}

/* Template field styles */
.template-field {
    transition: box-shadow 0.2s ease-in-out;
}

.template-field:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Modal Styles */
.modal-content {
    border-radius: 0.5rem;
    border: none;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-header {
    border-bottom: 1px solid #e5e7eb;
    background-color: #f9fafb;
}

.modal-footer {
    border-top: 1px solid #e5e7eb;
    background-color: #f9fafb;
}

/* Pagination Styles */
.pagination .page-link {
    color: #374151;
    border-color: #e5e7eb;
}

.pagination .page-link:hover {
    background-color: #f3f4f6;
    border-color: #d1d5db;
}

.pagination .page-item.active .page-link {
    background-color: #3b82f6;
    border-color: #3b82f6;
}

/* Badge Styles */
.badge-custom {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
}

.badge-success {
    background-color: #10b981;
    color: #ffffff;
}

.badge-warning {
    background-color: #f59e0b;
    color: #ffffff;
}

.badge-danger {
    background-color: #ef4444;
    color: #ffffff;
}

.badge-info {
    background-color: #3b82f6;
    color: #ffffff;
}

.badge-secondary {
    background-color: #6b7280;
    color: #ffffff;
}

/* Authentication Pages Styles */
.auth-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.auth-card {
    max-width: 400px;
    margin: 0 auto;
    border: none;
    border-radius: 1rem;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1), 0 5px 15px rgba(0, 0, 0, 0.07);
    overflow: hidden;
}

.auth-card .card-header {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border: none;
    padding: 2rem 1.5rem 1.5rem;
    border-radius: 0;
}

.auth-card .card-body {
    padding: 2rem 1.5rem;
}

.auth-card .card-footer {
    background-color: #f8f9fa;
    border: none;
    padding: 1rem 1.5rem;
}

.auth-card .input-group-text {
    background-color: #f8f9fa;
    border-right: none;
    color: #6c757d;
}

.auth-card .form-control {
    border-left: none;
    padding-left: 0.5rem;
}

.auth-card .form-control:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.25);
}

.auth-card .input-group .form-control:focus {
    border-left: none;
}

.auth-card .btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border: none;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.auth-card .btn-primary:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    transform: translateY(-1px);
    transition: all 0.2s ease-in-out;
    box-shadow: 0 5px 15px rgba(59, 130, 246, 0.3);
}

/* Animation for page load */
.auth-card {
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===================================================================
 * Desktop Sidebar Styles - Bootstrap 5 Implementation
 * ===================================================================
 * Responsive sidebar navigation for desktop screens ≥1920px
 * Mobile and tablet devices continue using horizontal navigation
 */

/* Sidebar Base Styles */
.sidebar {
    width: 280px;
    transition: all 0.3s ease-in-out;
    background: #f8faff;
    border-right: 1px solid #e9ecef;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.05);
}

/* Sidebar minimized state */
.sidebar.minimized {
    width: 60px !important;
    min-width: 60px !important;
    max-width: 60px !important;
    overflow: hidden;
}

.sidebar.minimized .sidebar-text {
    display: none !important;
    opacity: 0;
}

.sidebar.minimized .sidebar-section-title {
    display: none !important;
}

.sidebar.minimized .sidebar-user-info {
    display: none !important;
}

.sidebar.minimized .sidebar-link {
    justify-content: center;
    padding: 0.75rem 0.5rem;
}

.sidebar.minimized .sidebar-footer {
    padding: 0.5rem;
}

.sidebar.minimized .sidebar-footer .d-flex {
    justify-content: center;
}

.sidebar.minimized .dropdown {
    position: static;
}

.sidebar.minimized .sidebar-header {
    padding: 0.5rem !important;
    text-align: center;
}

.sidebar.minimized .sidebar-header .d-flex {
    justify-content: center !important;
    flex-direction: column !important;
    align-items: center !important;
}

.sidebar.minimized .sidebar-header .navbar-brand {
    display: none !important;
}

.sidebar.minimized .sidebar-toggle {
    margin-top: 0 !important;
}

/* Sidebar Header */
.sidebar-header {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-toggle {
    border: 1px solid rgba(255, 255, 255, 0.5) !important;
    background-color: rgba(255, 255, 255, 0.1) !important;
    color: white !important;
    transition: all 0.2s ease;
    padding: 0.375rem 0.5rem !important;
    min-width: 32px;
    min-height: 32px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    z-index: 10;
    position: relative;
    cursor: pointer;
}

.sidebar-toggle:hover {
    background-color: rgba(255, 255, 255, 0.2) !important;
    border-color: rgba(255, 255, 255, 0.7) !important;
    color: white !important;
}

/* Sidebar Navigation */
.sidebar-nav {
    height: 100%;
}

.sidebar-section {
    margin-bottom: 1rem;
}

.sidebar-section-title {
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
    padding: 0 1rem;
    opacity: 0.7;
}

/* Sidebar Links */
.sidebar-link {
    color: #374151;
    padding: 0.75rem 1rem;
    margin: 0.125rem 0.5rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    text-decoration: none;
    transition: all 0.2s ease;
    position: relative;
    font-size: 0.875rem;
}

.sidebar-link:hover {
    background-color: #f3f4f6;
    color: #2563eb;
    text-decoration: none;
}

.sidebar-link.active,
.sidebar-link[aria-current="page"] {
    background-color: #dbeafe;
    color: #2563eb;
    font-weight: 600;
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 70%;
    background-color: #2563eb;
    border-radius: 0 2px 2px 0;
}

/* Super Admin Links */
.sidebar-link.text-danger {
    color: #dc2626 !important;
}

.sidebar-link.text-danger:hover {
    background-color: #fef2f2;
    color: #dc2626 !important;
}

/* Sidebar Footer */
.sidebar-footer {
    background-color: #f1f5f9;
    border-top: 1px solid #e2e8f0;
}

.sidebar-user-info {
    line-height: 1.3;
}

/* Main Content Layout Adjustments */
@media (min-width: 1920px) {
    /* Only apply sidebar layout on large desktop screens */
    body.sidebar-active .main-content {
        margin-left: 280px !important;
        transition: margin-left 0.3s ease-in-out;
    }
    
    body.sidebar-minimized .main-content {
        margin-left: 60px !important;
        transition: margin-left 0.3s ease-in-out;
    }
    
    /* Hide horizontal navigation on desktop when sidebar is active */
    body.sidebar-active header nav.d-none.d-md-flex {
        display: none !important;
    }
    
    /* Fallback for browsers without :has() support */
    body:has(.sidebar:not(.d-none)) .main-content {
        margin-left: 280px;
        transition: margin-left 0.3s ease-in-out;
    }
    
    body:has(.sidebar.minimized) .main-content {
        margin-left: 60px;
    }
    
    body:has(.sidebar:not(.d-none)) header nav.d-none.d-md-flex {
        display: none !important;
    }
}

/* Sidebar animations */
@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.sidebar {
    animation: slideInLeft 0.3s ease-out;
}

/* Responsive behavior - hide sidebar on smaller screens */
@media (max-width: 1919px) {
    .sidebar {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
    }
}

/* Tooltips for minimized sidebar */
.sidebar.minimized .nav-link {
    position: relative;
}

.sidebar.minimized .nav-link:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background-color: #1f2937;
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    white-space: nowrap;
    margin-left: 0.5rem;
    z-index: 1000;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Smooth transitions for all sidebar elements */
.sidebar * {
    transition: all 0.2s ease;
}

/* Focus states for accessibility */
.sidebar-link:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

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

/* Dark mode compatibility (if needed in future) */
@media (prefers-color-scheme: dark) {
    .sidebar {
        background: #1f2937;
        border-right-color: #374151;
    }
    
    .sidebar-link {
        color: #d1d5db;
    }
    
    .sidebar-link:hover {
        background-color: #374151;
        color: #60a5fa;
    }
    
    .sidebar-footer {
        background-color: #111827;
        border-top-color: #374151;
    }
}