/* ==========================================================================
   📦 CORE FRAMEWORK LAYOUT SHELL
   ========================================================================== */
:root {
    --sidebar-width: 260px;
    --bg-dark: #0f172a;
    --border-color: #1e293b;
    --text-muted: #94a3b8;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    display: flex;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    font-family: system-ui, -apple-system, sans-serif;
}

#app-viewport {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#app-framework-root {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
}

.hub-main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    background-color: #f8fafc;
    position: relative;
}

/* Dashboard Utility Bar Elements Styles Matrix */
.dashboard-utility-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.btn-util {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid transparent;
    padding: 0.5rem 0.85rem;
    font-size: 0.825rem;
    font-weight: 700;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
}

/* Clear Selection Layout Theme */
.btn-util.btn-clear-matrix {
    background-color: #f8fafc;
    border-color: #cbd5e1;
    color: #475569;
}
.btn-util.btn-clear-matrix:hover {
    background-color: #f1f5f9;
    color: #0f172a;
    border-color: #94a3b8;
}

/* Logout Actions Theme */
.btn-util.btn-system-logout {
    background-color: #fef2f2;
    border-color: #fee2e2;
    color: #dc2626;
}
.btn-util.btn-system-logout:hover {
    background-color: #fee2e2;
    color: #b91c1c;
    border-color: #fca5a5;
}

/* --- Mobile Top Bar Header --- */
#mobile-top-bar {
    display: none; /* Managed by media queries */
    height: 50px;
    background-color: #0f172a;
    border-bottom: 1px solid var(--border-color);
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    z-index: 60;
    color: white;
}

#mobile-top-bar #mobile-toggle-btn {
    background: transparent;
    border: 1px solid #334155;
    color: white;
    font-size: 1.25rem;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    cursor: pointer;
}

#mobile-top-bar .brand-title {
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

#mobile-top-bar .version-tag {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --- Navigation Sidebar Base & Inner Blocks --- */
.hub-sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    height: 100%;
    background-color: var(--bg-dark);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    z-index: 50;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.hub-sidebar .sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: #0b0f19;
}

.hub-sidebar .sidebar-header h1 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #ffffff;
}

.hub-sidebar .sidebar-header span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.hub-sidebar nav {
    flex: 1;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    overflow-y: auto;
}

.hub-sidebar nav .nav-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.hub-sidebar nav .nav-item:hover,
.hub-sidebar nav .nav-item.active {
    color: #ffffff;
    background: #1e293b;
}

.hub-sidebar .sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: #64748b;
    background: #0f1d4f;
}

/* 🚪 Sidebar Logout Trigger Styling */
.sidebar-logout-trigger:hover {
    background-color: #fee2e2 !important;
    color: #b91c1c !important;
    border-color: #fca5a5 !important;
}

/* 🔄 Dashboard Ribbon Reset Matrix Button Styling */
.utility-clear-trigger {
    transition: all 0.15s ease-in-out;
}
.utility-clear-trigger:hover {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
    border-color: #94a3b8 !important;
}

/* --- Main Workspace Content Framing --- */
.hub-content-frame {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    position: relative;
}

/* Metric Display Strip / Live Ribbon Pipeline Window */
.dashboard-volume-ribbon {
    height: 70px;
    min-height: 70px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background-color: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    gap: 1.5rem;
    z-index: 40;
}

.dashboard-volume-ribbon .metrics-container-wrapper {
    display: flex;
    gap: 2rem;
    align-items: center;
    overflow-x: auto;
}

.dashboard-volume-ribbon .metric-block {
    border-right: 1px solid #e2e8f0;
    padding-right: 2rem;
    white-space: nowrap;
}

.dashboard-volume-ribbon .metric-block:last-child {
    border-right: none;
    padding-right: 0;
}

.dashboard-volume-ribbon .metric-label {
    display: block;
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.dashboard-volume-ribbon strong {
    font-size: 1.15rem;
    color: #0f172a;
    font-weight: 700;
}

#ribbon-total-bv {
    color: #16a34a;
}

.dashboard-volume-ribbon .action-block {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#btn-generate-invoice {
    background: #cbd5e1;
    color: #64748b;
    border: none;
    padding: 0.625rem 1.25rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: not-allowed;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

/* Mounting Frame Node Template styling targets */
.matrix-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    -webkit-overflow-scrolling: touch;
}

.matrix-container .loading-placeholder {
    color: #64748b;
    font-size: 0.875rem;
    font-style: italic;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-3px); }
    to { opacity: 1; transform: translateY(0); }
}
/* ==========================================================================
   📱 CROSS-DEVICE RESPONSIVE OVERLAY (TABLETS & PHONES)
   ========================================================================== */

/* --- 1. TABLET PLATFORMS (Max-Width: 1024px) --- */
@media screen and (max-width: 1024px) {
    .catalog-grid-mode {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 1rem !important;
    }
}

/* --- 2. TABLET & MOBILE VIEWPORT SEPARATION BRIDGE (Max-Width: 768px) --- */
@media screen and (max-width: 768px) {
    #mobile-top-bar { 
        display: flex !important; 
    }
    
    .hub-sidebar {
        position: absolute !important;
        left: 0;
        top: 50px;
        height: calc(100vh - 50px) !important;
        transform: translateX(-100%);
        box-shadow: 4px 0 15px rgba(0, 0, 0, 0.25);
        z-index: 9999 !important;
    }
    
    .hub-sidebar.mobile-open { 
        transform: translateX(0) !important; 
    }
}

/* --- 3. SMARTPHONE PORTS (Max-Width: 640px) --- */
@media screen and (max-width: 640px) {
    .matrix-container {
        padding: 0.75rem !important;
    }

    /* Scaling content typography smaller for structural clean fit */
    body, p, span, button, input, select {
        font-size: 0.85rem !important;
    }

    /* Shrink grid layouts down tightly */
    .catalog-grid-mode {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 0.5rem !important;
    }

    /* Tight micro-paddings inside catalog component frames */
    .product-card, .catalog-item {
        padding: 0.5rem !important;
    }
    
    .product-card img, .catalog-item-image {
        height: 95px !important;
    }

    /* Convert Line Mode Matrix rows into readable, ultra-compact blocks */
    .catalog-line-mode-table, 
    .catalog-line-mode-table thead, 
    .catalog-line-mode-table tbody, 
    .catalog-line-mode-table tr, 
    .catalog-line-mode-table td {
        display: block !important;
        width: 100% !important;
    }

    .catalog-line-mode-table thead {
        display: none !important;
    }

    .catalog-line-mode-table tr {
        margin-bottom: 0.5rem;
        border: 1px solid #e2e8f0;
        border-radius: 6px;
        padding: 0.5rem;
        background: #ffffff;
    }

    .catalog-line-mode-table td {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        padding: 0.25rem 0 !important;
        border: none !important;
        font-size: 0.8rem !important;
    }

    .catalog-line-mode-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #64748b;
        font-size: 0.75rem;
    }

    /* Compact UI Volume Ribbon Configuration */
    .dashboard-volume-ribbon {
        flex-direction: column !important;
        height: auto !important;
        min-height: auto !important;
        gap: 0.5rem !important;
        padding: 0.5rem 0.75rem !important;
    }

    .dashboard-volume-ribbon .metrics-container-wrapper {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: space-between !important;
        gap: 0.5rem !important;
        width: 100%;
    }
    
    .dashboard-volume-ribbon .metric-block {
        border-right: none !important;
        padding-right: 0 !important;
        flex: 1 1 calc(33.33% - 0.5rem);
        min-width: 80px;
        text-align: center;
    }

    .dashboard-volume-ribbon .metric-label {
        font-size: 0.65rem !important;
    }

    .dashboard-volume-ribbon strong {
        font-size: 0.9rem !important;
    }

    .dashboard-volume-ribbon .action-block {
        width: 100%;
    }

    #btn-generate-invoice {
        width: 100% !important;
        text-align: center !important;
        justify-content: center;
        padding: 0.5rem !important;
        font-size: 0.8rem !important;
    }
}

/* ==========================================================================
   📄 INVOICE BILLING SHEET & COVER LAYOUT ENGINE
   ========================================================================== */
.invoice-container {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 2rem;
    margin: 1rem auto;
    max-width: 850px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    color: #0f172a;
}

/* Document Header Matrix Split */
.invoice-header-block {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 1.5rem;
    margin-bottom: 1.5rem;
    gap: 2rem;
}

.invoice-company-meta h2 {
    margin: 0 0 0.5rem 0;
    font-size: 1.5rem;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.025em;
}

.invoice-company-meta p,
.invoice-doc-meta p {
    margin: 0.25rem 0;
    font-size: 0.875rem;
    color: #475569;
    line-height: 1.4;
}

.invoice-doc-meta {
    text-align: right;
}

.invoice-doc-meta h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.25rem;
    color: #64748b;
    font-weight: 600;
}

/* User & System Recipient Split Pipeline */
.invoice-billing-party-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
    margin-bottom: 2rem;
    background: #f8fafc;
    padding: 1.25rem;
    border-radius: 6px;
    border: 1px solid #f1f5f9;
}

.billing-col h4 {
    margin: 0 0 0.5rem 0;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
}

.billing-col p {
    margin: 0.25rem 0;
    font-size: 0.9rem;
    color: #1e293b;
    font-weight: 500;
}

.billing-col span {
    display: block;
    font-size: 0.85rem;
    color: #64748b;
}

/* ==========================================================================
   📱 INVOICE RESPONSIVE COMPRESSION OVERLAYS
   ========================================================================== */
@media screen and (max-width: 640px) {
    .invoice-container {
        padding: 1rem !important;
        margin: 0.5rem !important;
        border: none !important;
        box-shadow: none !important;
    }

    .invoice-header-block {
        flex-direction: column !important;
        gap: 1rem !important;
    }

    .invoice-doc-meta {
        text-align: left !important;
        border-top: 1px dashed #e2e8f0;
        padding-top: 1rem;
        width: 100%;
    }

    .invoice-billing-party-grid {
        grid-template-columns: 1fr !important;
        gap: 1.25rem !important;
        padding: 0.85rem !important;
    }
}

@media print {
    body * {
        visibility: hidden;
    }
    .invoice-container, .invoice-container * {
        visibility: visible;
    }
    .invoice-container {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        border: none;
        padding: 0;
    }
}