:root {
    --primary: #10b981;
    --primary-hover: #059669;
    --accent: #34d399;
    --blue: #0ea5e9;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass-bg: rgba(30, 41, 59, 0.75);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.55);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    background-color: var(--bg-dark);
    height: 100vh;
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Background Blurs */
.bg-shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    z-index: 0;
}
.shape1 {
    width: 400px;
    height: 400px;
    background: rgba(16, 185, 129, 0.15);
    top: -50px;
    left: -50px;
}
.shape2 {
    width: 500px;
    height: 500px;
    background: rgba(14, 165, 233, 0.12);
    bottom: -100px;
    right: -50px;
}

/* Header */
.hub-header {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 100;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand img {
    height: 40px;
}

.brand h1 {
    font-size: 1.4rem;
    font-weight: 800;
    background: linear-gradient(to right, #fff, #34d399);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-actions {
    display: flex;
    gap: 12px;
}

.btn-nav {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    text-decoration: none;
}

.btn-nav:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.btn-nav.primary {
    background: linear-gradient(135deg, var(--blue), #0284c7);
    border: none;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.25);
}

.btn-nav.primary:hover {
    box-shadow: 0 6px 15px rgba(14, 165, 233, 0.4);
}

/* Main Layout */
.hub-main {
    flex-grow: 1;
    display: flex;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
    gap: 1.5rem;
    position: relative;
    z-index: 10;
    height: calc(100vh - 73px);
    overflow: hidden;
}

/* Panel Containers */
.panel {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: var(--glass-shadow);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.panel-sidebar {
    width: 350px;
    flex-shrink: 0;
}

.panel-content {
    flex-grow: 1;
}

/* Sidebar Elements */
.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--glass-border);
}

.sidebar-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-wrapper {
    position: relative;
}

.search-wrapper input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.5);
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
    transition: all 0.3s ease;
}

.search-wrapper input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.15);
}

.search-wrapper i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
}

.chat-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-item {
    padding: 1rem;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.chat-item.active {
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.2);
}

.chat-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.chat-phone {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.unread-badge {
    background: #ef4444;
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 20px;
}

/* Chat & Receipt Workspace */
.workspace-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 23, 42, 0.2);
}

.client-profile h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.client-profile p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.tabs {
    display: flex;
    background: rgba(15, 23, 42, 0.6);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.tab-btn {
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 0.5rem 1.2rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.25);
}

/* Workspace Sections */
.workspace-body {
    flex-grow: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 500px;
}

.workspace-section {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.workspace-section.active {
    display: flex;
}

/* Chat Pane */
.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message-bubble {
    max-width: 70%;
    padding: 1rem;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    animation: slideUp 0.3s ease;
}

.message-bubble.incoming {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message-bubble.outgoing {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(5, 150, 105, 0.15));
    border: 1px solid rgba(16, 185, 129, 0.3);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    align-self: flex-end;
}

.chat-input-area {
    padding: 1.5rem;
    border-top: 1px solid var(--glass-border);
    display: flex;
    gap: 12px;
    background: rgba(15, 23, 42, 0.2);
}

.chat-input-area textarea {
    flex-grow: 1;
    border-radius: 14px;
    border: 1px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.5);
    color: var(--text-main);
    padding: 0.85rem 1rem;
    resize: none;
    outline: none;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.chat-input-area textarea:focus {
    border-color: var(--primary);
}

.btn-send {
    background: var(--primary);
    border: none;
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.25);
}

.btn-send:hover {
    background: var(--primary-hover);
    transform: scale(1.03);
}

/* Receipts Pane */
.receipts-pane {
    flex-grow: 1;
    overflow-y: auto;
    padding: 2rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.receipt-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: all 0.3s ease;
}

.receipt-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(16, 185, 129, 0.2);
}

.receipt-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.receipt-tag {
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.receipt-tag.avolo {
    background: rgba(14, 165, 233, 0.12);
    color: #38bdf8;
    border: 1px solid rgba(14, 165, 233, 0.2);
}

.receipt-tag.saas {
    background: rgba(168, 85, 247, 0.12);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.2);
}

.receipt-amount {
    font-size: 1.5rem;
    font-weight: 800;
    color: #34d399;
}

.receipt-detail {
    font-size: 0.88rem;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.receipt-detail strong {
    color: var(--text-main);
}

.btn-action {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 0.6rem 1rem;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    text-decoration: none;
    margin-top: auto;
}

.btn-action:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Lightbox Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    justify-content: center;
    align-items: center;
}

.modal.open {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    max-width: 90%;
    max-height: 90%;
    padding: 1.5rem;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    animation: fadeIn 0.3s ease;
}

.modal-close {
    position: absolute;
    right: 1.5rem;
    top: 1rem;
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-muted);
    cursor: pointer;
}

.modal-body img {
    max-width: 100%;
    max-height: 70vh;
    border-radius: 12px;
}

/* Empty States */
.empty-state {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-muted);
    text-align: center;
    gap: 1rem;
}

.empty-state i {
    font-size: 3.5rem;
    color: var(--glass-border);
}

/* Quick messages style */
.btn-quick-msg {
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-quick-msg:not([disabled]) {
    background: rgba(16, 185, 129, 0.08) !important;
    border-color: rgba(16, 185, 129, 0.25) !important;
    color: var(--primary) !important;
}
.btn-quick-msg:not([disabled]):hover {
    background: rgba(16, 185, 129, 0.15) !important;
    transform: translateY(-1px);
}

/* Search results dropdown inside POS modal */
.search-results-dropdown {
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
}
.search-results-dropdown .saas-search-result-item, 
.search-results-dropdown .search-result-item {
    padding: 10px 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.search-results-dropdown .saas-search-result-item:hover, 
.search-results-dropdown .search-result-item:hover {
    background: rgba(16, 185, 129, 0.1);
}
.search-results-dropdown .saas-search-result-item .price, 
.search-results-dropdown .search-result-item .price {
    font-weight: 600;
    color: #10b981;
}

/* Cart items in POS modal */
.sale-cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.88rem;
}
.sale-cart-item .qty-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}
.sale-cart-item .qty-controls button {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sale-cart-item .qty-controls button:hover {
    background: rgba(255, 255, 255, 0.15);
}
.sale-cart-item .remove-btn {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 0.95rem;
    padding: 4px;
}

/* Responsive */
/* Sub-header App Name Bar */
.app-sub-bar {
    background: rgba(15, 23, 42, 0.4);
    border-bottom: 1px solid var(--glass-border);
    padding: 0.6rem 2rem;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 90;
    position: relative;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Adjust hub-main layout to sub-header bar */
.hub-main {
    height: calc(100vh - 110px); /* 100vh - headerHeight - subHeaderHeight */
}

@media (max-width: 768px) {
    .hub-header {
        padding: 0.75rem 1rem;
    }
    .header-actions {
        gap: 8px;
        align-items: center;
    }
    #user-display-name {
        display: none !important;
    }
    .btn-nav span {
        display: none !important;
    }
    .btn-nav {
        padding: 0.6rem !important;
        border-radius: 50% !important;
        width: 38px;
        height: 38px;
        justify-content: center;
        align-items: center;
    }
    .app-sub-bar {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }
    .hub-main {
        padding: 0;
        gap: 0;
        height: calc(100vh - 98px);
    }
    .panel-sidebar, .panel-content {
        width: 100% !important;
        height: 100% !important;
        border-radius: 0;
        border: none;
    }
    
    /* Display toggles */
    .hub-main.show-workspace #sidebar-panel {
        display: none;
    }
    .hub-main.show-workspace #workspace-panel {
        display: flex;
    }
    
    .hub-main:not(.show-workspace) #sidebar-panel {
        display: flex;
    }
    .hub-main:not(.show-workspace) #workspace-panel {
        display: none;
    }
    
    #btn-back-sidebar {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        background: rgba(255,255,255,0.08);
        border: 1px solid var(--glass-border);
        color: var(--text-main);
        width: 38px;
        height: 38px;
        border-radius: 50%;
        cursor: pointer;
    }

    /* Force the workspace layout to fit exactly on small screens */
    .workspace-body {
        min-height: 0 !important;
        flex-grow: 1;
    }
    .receipts-pane {
        padding: 1rem !important;
        grid-template-columns: 1fr !important;
    }
}
