﻿/* ==============================
   BASE TYPOGRAPHY / LAYOUT
   ============================== */

html {
    font-size: 14px;
    height: 100%;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

body {
    margin: 0;
    height: 100%;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    overflow: hidden;
}

/* Bootstrap focus tweaks (from original) */
.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

/* Form-floating placeholder behavior (from original) */
.form-floating > .form-control-plaintext::placeholder,
.form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* Tabulator styling (from original) */
.tabulator {
    font-size: 14px;
}

#orders-table {
    width: 100% !important;
}

/* ==============================
   ICONS
   ============================== */

.icon {
    object-fit: contain;
    vertical-align: middle;
}

.icon-sm {
    width: 16px;
    height: 16px;
}

.icon-md {
    width: 24px;
    height: 24px;
}

.icon-lg {
    width: 32px;
    height: 32px;
}

.icon-xl {
    width: 48px;
    height: 48px;
}

.icon:hover {
    opacity: 0.85;
    transform: scale(1.05);
    transition: 0.15s ease-in-out;
}

/* ==============================
   SIDEBAR — EXPANDED + COLLAPSED
   ============================== */

#ow-sidebar {
    width: 240px;
    background: #5f0507;
    color: white;
    height: calc(100vh - 56px); /* full height under navbar */
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.25s ease;
    position: relative;
    flex-shrink: 0;
}

    /* Collapsed: icon-only bar */
    #ow-sidebar.collapsed {
        width: 70px;
    }

/* Apply collapsed state immediately on page load to prevent flicker */
html.sidebar-collapsed-init #ow-sidebar {
    width: 70px;
    transition: none;
}

    html.sidebar-collapsed-init #ow-sidebar .ow-sidebar-text {
        display: none;
    }

    html.sidebar-collapsed-init #ow-sidebar .ow-sidebar-header {
        justify-content: center;
    }

    html.sidebar-collapsed-init #ow-sidebar .ow-sidebar-submenu {
        display: none !important;
    }

/* ---- Header row (toggle button only) ---- */

.ow-sidebar-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.5rem;
    background: #5f0507;
}

/* Container for expand/collapse all buttons */
.ow-sidebar-expand-controls {
    display: flex;
    gap: 0.25rem;
}

/* Hide expand/collapse all buttons when sidebar is collapsed */
#ow-sidebar.collapsed .ow-sidebar-expand-controls {
    display: none;
}

/* Clean toggle buttons: no weird background */
#ow-sidebar-toggle,
#ow-sidebar-expand-all,
#ow-sidebar-collapse-all {
    width: 28px;
    height: 28px;
    border: none;
    padding: 0;
    background: transparent;
    outline: none;
    box-shadow: none;
    border-radius: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

    #ow-sidebar-toggle img,
    #ow-sidebar-expand-all img,
    #ow-sidebar-collapse-all img {
        width: 20px;
        height: 20px;
        display: block;
        background: transparent;
    }

    #ow-sidebar-toggle:hover,
    #ow-sidebar-expand-all:hover,
    #ow-sidebar-collapse-all:hover {
        background: rgba(255, 255, 255, 0.12);
        border-radius: 4px;
    }

/* ---- Groups + headers ---- */

.ow-sidebar-group {
    position: relative; /* required for flyout positioning */
}

.ow-sidebar-header {
    width: 100%;
    background: #5f0507;
    color: white;
    border: none;
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    gap: 10px;
    text-transform: uppercase;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}

    .ow-sidebar-header:hover {
        background: #77070a;
    }

/* Hide the text in collapsed mode, keep icon centered */
#ow-sidebar.collapsed .ow-sidebar-text {
    display: none;
}

#ow-sidebar.collapsed .ow-sidebar-header {
    justify-content: center;
}

/* ---- Submenus (expanded mode) ---- */

.ow-sidebar-submenu {
    display: none;
}

.ow-sidebar-group.open .ow-sidebar-submenu {
    display: block;
}

/* ---- Items inside submenus ---- */

.ow-sidebar-list {
    margin: 0;
    padding: 0;
    list-style: none;
    background: #f5f5f5;
}

    .ow-sidebar-list a {
        display: block;
        padding: 0.55rem 1.25rem;
        text-decoration: none;
        color: #333;
        background: #f5f5f5;
        transition: background 0.15s ease, padding-left 0.15s ease;
    }

        .ow-sidebar-list a:hover {
            background: #e0e0e0;
            padding-left: 1.5rem;
        }

/* ==============================
   FLYOUT SUBMENU (COLLAPSED MODE ONLY)
   ============================== */

/* In collapsed mode, NEVER show inline submenus */
#ow-sidebar.collapsed .ow-sidebar-submenu {
    display: none !important;
}

/* Flyout panel - hidden by default */
.ow-sidebar-flyout {
    display: none;
    position: fixed;
    background: #f5f5f5;
    width: 220px;
    max-height: calc(100vh - 56px - 20px);
    overflow-y: auto;
    border: 1px solid rgba(0, 0, 0, 0.15);
    z-index: 9999;
    box-shadow: 3px 3px 8px rgba(0, 0, 0, 0.3);
}

    /* When flyout is active, show it */
    .ow-sidebar-flyout.active {
        display: block;
    }

/* Flyout header styling */
.ow-sidebar-flyout-header {
    background: #5f0507;
    color: white;
    padding: 0.6rem 1rem;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    text-align: center;
}

/* Flyout items styling */
.ow-sidebar-flyout .ow-sidebar-list {
    margin: 0;
    padding: 0;
    list-style: none;
    background: #f5f5f5;
}

    .ow-sidebar-flyout .ow-sidebar-list a {
        display: block;
        padding: 0.55rem 1.15rem;
        text-decoration: none;
        color: #333;
        background: #f5f5f5;
        transition: background 0.15s ease, padding-left 0.15s ease;
    }

        .ow-sidebar-flyout .ow-sidebar-list a:hover {
            background: #e0e0e0;
            padding-left: 1.4rem;
        }

/* ==============================
   CUSTOMER SEARCH IN SIDEBAR
   ============================== */

.ow-sidebar-customer-search {
    padding: 0.5rem 0.75rem;
    background: #f5f5f5;
    border-bottom: 1px solid #e0e0e0;
    position: relative;
}

.ow-sidebar-customer-search input {
    width: 100%;
    font-size: 0.85rem;
}

.ow-customer-search-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ccc;
    border-top: none;
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.ow-customer-search-results.active {
    display: block;
}

.ow-customer-search-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    font-size: 0.85rem;
}

.ow-customer-search-item:last-child {
    border-bottom: none;
}

.ow-customer-search-item:hover,
.ow-customer-search-item.selected {
    background: #e8f4fc;
}

.ow-customer-search-item .customer-name {
    font-weight: 600;
    color: #333;
}

.ow-customer-search-item .customer-code {
    font-size: 0.75rem;
    color: #666;
    margin-left: 0.5rem;
}

.ow-customer-search-no-results {
    padding: 0.75rem;
    text-align: center;
    color: #666;
    font-size: 0.85rem;
}

/* Hide customer search in collapsed sidebar (but show in flyout) */
#ow-sidebar.collapsed .ow-sidebar-customer-search {
    display: none;
}

/* Customer search styling in flyout */
.ow-sidebar-flyout .ow-sidebar-customer-search {
    display: block;
    padding: 0.5rem 0.75rem;
    background: #f5f5f5;
    border-bottom: 1px solid #e0e0e0;
    position: relative;
}

.ow-sidebar-flyout .ow-customer-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ccc;
    border-top: none;
    max-height: 250px;
    overflow-y: auto;
    z-index: 10001;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}
