:root {
    --primary: #4F46E5;
    --primary-hover: #4338ca;
    --font-family: 'Outfit', sans-serif;
}

body {
    font-family: var(--font-family);
}

/* Override Bootstrap Colors */
.text-primary {
    color: var(--primary) !important;
}

.bg-primary {
    background-color: var(--primary) !important;
}

.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}

/* Sidebar Overrides */
.nav-pills .nav-link {
    color: #6B7280;
    font-weight: 500;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

@media (min-width: 992px) {
    .nav-pills .nav-link {
        justify-content: flex-start;
    }
}

.nav-pills .nav-link:hover {
    background-color: #EEF2FF;
    color: var(--primary);
}

.nav-pills .nav-link.active {
    background-color: #EEF2FF;
    color: var(--primary);
    font-weight: 600;
}

.nav-pills .nav-link span {
    margin-right: 0.75rem;
    font-size: 1.2rem;
}

html[dir="rtl"] .nav-pills .nav-link span {
    margin-right: 0;
    margin-left: 0.75rem;
}

/* Form Styles */
.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.25rem rgba(79, 70, 229, 0.1);
}

/* Accordion Customization */
.accordion-button:not(.collapsed) {
    color: var(--primary);
    background-color: #EEF2FF;
    box-shadow: none;
}

.accordion-button:focus {
    box-shadow: none;
    border-color: rgba(0, 0, 0, .125);
}

/* Dashed Border Utility */
.border-dashed {
    border-style: dashed !important;
}

.whitespace-nowrap {
    white-space: nowrap;
}

.scrollbar-hide::-webkit-scrollbar {
    display: none;
}

.scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Height Fixes for Desktop Layout */
.no-overflow-wrapper {
    overflow: hidden;
    /* Contains the scroll area */
}

/* RTL Support Fixes */
html[dir="rtl"] .ms-auto {
    margin-left: 0 !important;
    margin-right: auto !important;
}

html[dir="rtl"] .me-2 {
    margin-right: 0 !important;
    margin-left: 0.5rem !important;
}

/* Fix Button Group Borders in RTL */
html[dir="rtl"] .btn-group>.btn:first-child {
    border-top-right-radius: 0.2rem;
    border-bottom-right-radius: 0.2rem;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

html[dir="rtl"] .btn-group>.btn:last-child {
    border-top-left-radius: 0.2rem;
    border-bottom-left-radius: 0.2rem;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

/* Fix Input Group Addon in RTL (Social Media) */
html[dir="rtl"] .input-group .input-group-text {
    border-radius: 0 0.25rem 0.25rem 0;
    border-left: 0;
    border-right: 1px solid #ced4da;
}

html[dir="rtl"] .input-group .form-control {
    border-radius: 0.25rem 0 0 0.25rem;
}

@media (max-width: 992px) {

    /* Mobile Layout Adjustments */
    .sidebar-desktop {
        height: auto !important;
        border-right: none !important;
        border-bottom: 1px solid #dee2e6;
    }

    .no-overflow-wrapper {
        height: auto !important;
        overflow: visible !important;
    }

    #main-scroll-area {
        height: auto !important;
        overflow: visible !important;
        padding-bottom: 280px !important;
        /* Reduced space for compact preview */
    }

    .preview-column {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 1020;
        height: auto;
        max-height: 35vh;
        /* Tighter height constraint */
        border-start: 0 !important;
        border-top: 1px solid #dee2e6 !important;
        border-left: none !important;
        box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
        overflow-y: auto;
        padding: 0.75rem !important;
        /* Compact padding */
        background-color: rgba(255, 255, 255, 0.95);
        /* Slight transparency */
        backdrop-filter: blur(5px);
    }

    .sticky-top {
        position: static;
        padding-top: 0 !important;
        display: flex;
        /* Horizontal Layout for Mobile */
        align-items: center;
        gap: 1rem;
        justify-content: space-between;
    }

    /* Adjust Preview Content for Sticky Mode */
    .preview-column h3 {
        display: block;
        /* Restore visibility */
        font-size: 1rem;
        /* Compact size */
        margin-bottom: 0 !important;
        margin-right: auto;
        /* Push to left if flex row */
    }

    .preview-column p.text-muted {
        display: none;
    }

    .qr-canvas-wrapper {
        padding: 0.5rem !important;
        margin-bottom: 0 !important;
        border: none !important;
        background: transparent !important;
        box-shadow: none !important;
        flex: 0 0 auto;
    }

    /* Limit QR size in compact mode */
    .qr-canvas-wrapper canvas,
    .qr-canvas-wrapper img {
        max-height: 120px;
        /* Small footprint */
        width: auto !important;
        /* maintain aspect ratio */
    }

    /* Button Container */
    .d-grid {
        display: flex !important;
        flex-direction: column;
        gap: 0.25rem !important;
        flex: 1;
        /* Take remaining space */
    }

    /* Make buttons smaller/compact */
    .preview-column .btn {
        padding: 0.25rem 0.5rem !important;
        font-size: 0.9rem;
    }

    .preview-column .btn-primary {
        margin-bottom: 0.25rem;
    }

    /* Mobile Flex Column Helper */
    .mobile-flex-column {
        flex-direction: column !important;
    }
}

/* Landscape Mobile Fixes */
@media (max-width: 992px) and (orientation: landscape) and (max-height: 500px) {
    #main-scroll-area {
        padding-bottom: 150px !important;
    }

    .preview-column {
        max-height: 100vh;
        /* Full height sidebar style? Or keep bottom? */
        /* Let's keep bottom but wider/shorter? detailed user request was generic "responsive" */
        /* Actually for landscape phone, sticky bottom eats too much height. */
        /* Let's make it a sidebar on the right if width allows, or just very small bar. */
        /* Simple fix: Hide sticky preview on super short landscape screens to allow editing? 
           Or make it a small floating toggle? 
           Let's try to keep it sticky but very minimal. 
        */
        padding: 0.25rem !important;
    }

    .qr-canvas-wrapper canvas,
    .qr-canvas-wrapper img {
        max-height: 80px;
    }
}

/* Ensure QR Content Scales (Global base) */
.qr-canvas-wrapper canvas,
.qr-canvas-wrapper img {
    max-width: 100% !important;
    height: auto !important;
}