:root {
    --bg-color: #0f172a;
    --sidebar-bg: #1e293b;
    --card-bg: rgba(30, 41, 59, 0.7);
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass-border: rgba(255, 255, 255, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    line-height: 1.5;
}

.glass {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.main-content {
    flex: 1;
    padding: 2rem;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
}

/* Global UI */
.brand {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--primary);
    text-align: center;
    margin-bottom: 2rem;
    letter-spacing: 1px;
}

.brand-logo {
    max-width: 80%;
    height: auto;
    max-height: 60px;
    display: block;
    margin: 0 auto 1.5rem auto;
}

.mobile-top-bar .brand-logo {
    max-height: 35px;
    margin: 0;
}


.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.nav-item a {
    text-decoration: none;
    color: var(--text-muted);
    padding: 0.7rem 1rem;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: 0.2s;
    font-size: 0.9rem;
}

.nav-item a:hover,
.nav-item.active a {
    background: var(--primary);
    color: white;
}

.nav-item i {
    width: 20px;
    text-align: center;
}

.btn {
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    transition: 0.2s;
    font-size: 0.85rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    padding: 1.25rem;
    position: relative;
    overflow: hidden;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.8rem;
    display: block;
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.table-container {
    overflow-x: auto;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th,
td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--glass-border);
    text-align: left;
}

th {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Forms - FIXED "DEVASA" TEXTBOXES */
.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

input,
select,
textarea {
    width: 100%;
    padding: 0.6rem 0.85rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: white;
    outline: none;
    font-size: 0.9rem;
    transition: 0.2s;
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Auth Pages */
.auth-wrapper {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top right, #1e1b4b, var(--bg-color));
    padding: 1rem;
}

.auth-card {
    width: 100%;
    max-width: 360px;
    padding: 2rem;
}

/* POS Interface */
.pos-container {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 1.5rem;
    height: calc(100vh - 120px);
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    overflow-y: auto;
    padding-right: 5px;
}

.pos-product-card {
    cursor: pointer;
    transition: 0.2s;
    padding: 1rem !important;
}

.pos-product-card:hover {
    transform: translateY(-3px);
    border-color: var(--primary);
}

.cart-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding-right: 5px;
}

/* Mobile Utilities */
.mobile-top-bar,
.mobile-nav,
.mobile-nav-overlay,
.mobile-cart-fab,
.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .main-content {
        padding: 1rem;
        margin-top: 50px;
    }

    .mobile-top-bar {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 50px;
        background: var(--sidebar-bg);
        z-index: 1000;
        align-items: center;
        justify-content: space-between;
        padding: 0 1rem;
        border-bottom: 1px solid var(--glass-border);
    }

    .mobile-menu-toggle {
        background: none;
        border: none;
        color: white;
        font-size: 1.25rem;
    }

    .mobile-nav {
        display: flex !important;
        flex-direction: column;
        position: fixed;
        left: -260px;
        top: 0;
        width: 260px;
        height: 100%;
        background: var(--sidebar-bg);
        z-index: 3000;
        transition: 0.3s ease;
        padding: 1.5rem 1rem;
        border-right: 1px solid var(--glass-border);
    }

    .mobile-nav.open {
        left: 0;
    }

    .mobile-nav-item {
        color: var(--text-main);
        text-decoration: none;
        padding: 0.85rem 1rem;
        display: flex;
        align-items: center;
        gap: 0.75rem;
        border-radius: 10px;
        margin-bottom: 0.25rem;
        font-size: 0.95rem;
    }

    .mobile-nav-item.active {
        background: var(--primary);
    }

    .mobile-nav-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.6);
        z-index: 2999;
        display: none;
    }

    .mobile-nav-overlay.show {
        display: block;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    .pos-container {
        grid-template-columns: 1fr;
        height: auto;
    }

    .product-grid {
        grid-template-columns: 1fr 1fr;
    }

    .cart-panel {
        position: fixed;
        right: -100%;
        top: 0;
        width: 100%;
        height: 100%;
        background: var(--bg-color);
        z-index: 2000;
        transition: 0.3s;
        padding: 1.5rem;
    }

    .cart-panel.open {
        right: 0;
    }

    .mobile-cart-fab {
        display: flex !important;
        position: fixed;
        bottom: 1.5rem;
        right: 1.5rem;
        width: 55px;
        height: 55px;
        background: var(--primary);
        border-radius: 50%;
        align-items: center;
        justify-content: center;
        color: white;
        border: none;
        z-index: 1001;
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
    }

    .mobile-only {
        display: block !important;
    }
}

/* Background Animation - Bubbles */
.animation-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.bubbles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

.bubbles li {
    position: absolute;
    display: block;
    list-style: none;
    width: 20px;
    height: 20px;
    background: rgba(255, 255, 255, 0.1);
    animation: bubbleUp 25s linear infinite;
    bottom: -150px;
    border-radius: 50%;
    /* Make them perfectly round */
    box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.1);
}

.bubbles li:nth-child(1) {
    left: 25%;
    width: 80px;
    height: 80px;
    animation-delay: 0s;
    background: rgba(99, 102, 241, 0.2);
    /* Primary tint */
}

.bubbles li:nth-child(2) {
    left: 10%;
    width: 20px;
    height: 20px;
    animation-delay: 2s;
    animation-duration: 12s;
    background: rgba(16, 185, 129, 0.2);
    /* Success tint */
}

.bubbles li:nth-child(3) {
    left: 70%;
    width: 20px;
    height: 20px;
    animation-delay: 4s;
    background: rgba(245, 158, 11, 0.2);
    /* Warning tint */
}

.bubbles li:nth-child(4) {
    left: 40%;
    width: 60px;
    height: 60px;
    animation-delay: 0s;
    animation-duration: 18s;
    background: rgba(255, 255, 255, 0.15);
}

.bubbles li:nth-child(5) {
    left: 65%;
    width: 20px;
    height: 20px;
    animation-delay: 0s;
    background: rgba(99, 102, 241, 0.2);
}

.bubbles li:nth-child(6) {
    left: 75%;
    width: 110px;
    height: 110px;
    animation-delay: 3s;
    background: rgba(255, 255, 255, 0.1);
}

.bubbles li:nth-child(7) {
    left: 35%;
    width: 150px;
    height: 150px;
    animation-delay: 7s;
    background: rgba(100, 116, 139, 0.2);
    /* Secondary */
}

.bubbles li:nth-child(8) {
    left: 50%;
    width: 25px;
    height: 25px;
    animation-delay: 15s;
    animation-duration: 45s;
    background: rgba(255, 255, 255, 0.15);
}

.bubbles li:nth-child(9) {
    left: 20%;
    width: 15px;
    height: 15px;
    animation-delay: 2s;
    animation-duration: 35s;
    background: rgba(255, 255, 255, 0.2);
}

.bubbles li:nth-child(10) {
    left: 85%;
    width: 150px;
    height: 150px;
    animation-delay: 0s;
    animation-duration: 11s;
    background: rgba(255, 255, 255, 0.1);
}

@keyframes bubbleUp {
    0% {
        transform: translateY(0) scale(0);
        opacity: 0;
    }

    10% {
        opacity: 0.7;
    }

    100% {
        transform: translateY(-120vh) scale(1.5);
        opacity: 0;
    }
}

/* Chat Interface */
.chat-page-wrapper {
    margin: -2rem;
    /* Override main-content padding */
}

.chat-container {
    height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    background: #0b141a url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
    overflow: hidden;
    position: relative;
    border-left: 1px solid rgba(255, 255, 255, 0.05);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    scroll-behavior: smooth;
    padding-bottom: 2rem;
}

.message {
    max-width: 75%;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    font-size: 0.95rem;
    position: relative;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
}

.message.sent {
    align-self: flex-end;
    background: #005c4b;
    color: #e9edef;
    border-top-right-radius: 0;
}

.message.received {
    align-self: flex-start;
    background: #202c33;
    color: #e9edef;
    border-top-left-radius: 0;
}

.message-info {
    font-size: 0.7rem;
    margin-bottom: 0.2rem;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.message.sent .message-info {
    color: rgba(255, 255, 255, 0.6);
}

.message.received .message-info {
    color: #8696a0;
}

.message-text {
    word-break: break-word;
    line-height: 1.4;
}

/* ==========================================================================
   ULTRA-PREMIUM STEALTH PRO CHAT SYSTEM
   ========================================================================== */
:root {
    --ch-bg: #09090b;
    --ch-surface: #121216;
    --ch-accent: #6366f1;
    --ch-accent-glow: rgba(99, 102, 241, 0.2);
    --ch-text: #fafafa;
    --ch-muted: #71717a;
    --ch-border: rgba(255, 255, 255, 0.04);
}

/* Structural Enforcement */
.main-content:has(.stealth-chat-container) {
    padding: 0 !important;
    max-width: none !important;
    height: 100vh !important;
    overflow: hidden !important;
    background: var(--ch-bg);
}

.stealth-chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    position: relative;
    background-image:
        radial-gradient(circle at 0% 0%, rgba(99, 102, 241, 0.03) 0, transparent 50%),
        radial-gradient(circle at 100% 100%, rgba(139, 92, 246, 0.03) 0, transparent 50%);
}

/* FIXED HEADER: Minimalist Pro */
.ch-header {
    height: 75px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2.5rem;
    background: rgba(9, 9, 11, 0.85);
    backdrop-filter: blur(30px);
    border-bottom: 1px solid var(--ch-border);
    z-index: 100;
}

.ch-user-box {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.ch-avatar {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.4rem;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
}

.ch-info h2 {
    font-size: 1.1rem;
    margin: 0;
    font-weight: 700;
    color: #fff;
}

.ch-info p {
    font-size: 0.8rem;
    color: #10b981;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* FEED: Scrollable hub */
.ch-feed {
    flex: 1;
    overflow-y: auto;
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
    scrollbar-width: none;
}

.ch-feed::-webkit-scrollbar {
    display: none;
}

/* REFINED NODES */
.ch-msg {
    display: flex;
    flex-direction: column;
    max-width: 65%;
    animation: ch-fade-up 0.5s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

.ch-msg.self {
    align-self: flex-end;
    align-items: flex-end;
}

.ch-msg.other {
    align-self: flex-start;
    align-items: flex-start;
}

.ch-bubble {
    padding: 1rem 1.5rem;
    border-radius: 20px;
    font-size: 0.95rem;
    line-height: 1.6;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.self .ch-bubble {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.other .ch-bubble {
    background: #18181b;
    color: #e4e4e7;
    border: 1px solid var(--ch-border);
    border-bottom-left-radius: 4px;
}

.ch-meta {
    font-size: 0.7rem;
    color: var(--ch-muted);
    margin-top: 8px;
    font-weight: 600;
    letter-spacing: 0.05em;
}

/* COMMAND BAR (FOOTER) */
.ch-footer {
    height: 100px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 2rem;
    background: linear-gradient(to top, var(--ch-bg) 40%, transparent);
    z-index: 100;
}

.ch-input-bar {
    width: 100%;
    max-width: 750px;
    background: #18181b;
    border: 1px solid var(--ch-border);
    border-radius: 24px;
    display: flex;
    align-items: center;
    padding: 10px 20px;
    gap: 14px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.ch-input-bar:focus-within {
    border-color: var(--ch-accent);
    transform: translateY(-8px);
    box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.8), 0 0 20px var(--ch-accent-glow);
}

.ch-input-field {
    flex: 1;
    background: transparent !important;
    border: none !important;
    color: #fff !important;
    font-size: 1rem !important;
    outline: none !important;
    padding: 8px 0 !important;
}

.ch-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: transparent;
    color: var(--ch-muted);
    border: none;
    transition: 0.3s;
}

.ch-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
    transform: translateY(-2px);
}

.ch-send {
    background: var(--ch-accent) !important;
    color: white !important;
    border-radius: 14px;
    box-shadow: 0 4px 12px var(--ch-accent-glow);
}

@keyframes ch-fade-up {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (max-width: 768px) {
    .main-content:has(.stealth-chat-container) {
        height: calc(100vh - 60px) !important;
        margin-top: 60px !important;
    }
}

/* ==========================================================================
   NOTIFICATION SYSTEM
   ========================================================================== */
#chat-badge,
#chat-badge-mobile {
    display: none;
    align-items: center;
    justify-content: center;
    background: #ef4444 !important;
    /* Premium Red */
    color: white !important;
    font-size: 10px !important;
    font-weight: 800 !important;
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    padding: 0 4px;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
    pointer-events: none;
    margin-left: auto;
}

.pulse-animation {
    animation: badge-pulse-animation 2s infinite ease-in-out;
}

@keyframes badge-pulse-animation {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }

    70% {
        transform: scale(1.2);
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* ==========================================================================
   STEALTH MESSAGE BOX & TOAST (MODERN MODAL)
   ========================================================================== */
.st-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.st-modal-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.st-modal {
    max-width: 450px;
    width: 90%;
    padding: 2.5rem;
    text-align: center;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid var(--glass-border);
}

.st-modal-overlay.active .st-modal {
    transform: scale(1);
}

.st-modal-icon {
    font-size: 3.5rem;
    margin-bottom: 1.5rem;
}

.st-modal-icon.success {
    color: var(--success);
}

.st-modal-icon.error {
    color: var(--danger);
}

.st-modal-icon.info {
    color: var(--primary);
}

.st-modal h3 {
    margin-bottom: 1rem;
    font-size: 1.5rem;
    color: white;
}

.st-modal p {
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 2rem;
}

.st-modal-actions {
    display: flex;
    justify-content: center;
}

/* TOAST SYSTEM */
#st-toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.st-toast {
    padding: 1rem 1.5rem;
    border-radius: 12px;
    background: rgba(24, 24, 27, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    color: white;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    min-width: 280px;
    animation: toast-in 0.4s cubic-bezier(0.075, 0.82, 0.165, 1) forwards;
}

@keyframes toast-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.st-toast.error {
    border-left: 4px solid var(--danger);
}

.st-toast.success {
    border-left: 4px solid var(--success);
}

.st-toast.info {
    border-left: 4px solid var(--primary);
}

/* EMOJI & UTILS */
.emoji-item {
    cursor: pointer;
    font-size: 1.5rem;
    text-align: center;
    transition: 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.emoji-item:hover {
    transform: scale(1.4) rotate(5deg);
}

#emojiPicker {
    background: #18181b !important;
    border: 1px solid var(--ch-border) !important;
    backdrop-filter: blur(20px);
}

#filePreview {
    backdrop-filter: blur(20px);
    border: 1px solid var(--ch-accent);
}