:root {
    --primary: #4361ee;
    --primary-hover: #3a56d4;
    --secondary: #3f37c9;
    --success: #2ecc71;
    --info: #4cc9f0;
    --warning: #f72585;
    --danger: #e63946;
    --dark: #2b2d42;
    --light: #f8f9fa;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --sidebar-width: 260px;
    --topbar-height: 70px;
    --card-radius: 12px;
    --btn-radius: 8px;
    --font-heading: 'Inter', sans-serif;
    --font-body: 'Inter', sans-serif;
}

body {
    font-family: var(--font-body);
    background-color: #f4f7fa;
    color: var(--dark);
    line-height: 1.6;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    color: #1a1a1a;
}

/* Layout */
.wrapper {
    display: flex;
    width: 100%;
    align-items: stretch;
    overflow-x: hidden;
}

#sidebar {
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    background: #ffffff;
    color: #555;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.03);
    min-height: 100vh;
    z-index: 1000;
}

#sidebar.active {
    margin-left: calc(var(--sidebar-width) * -1);
}

#sidebar .sidebar-header {
    padding: 24px;
    background: #ffffff;
    display: flex;
    align-items: center;
    gap: 12px;
}

#sidebar ul.components {
    padding: 10px 0;
}

#sidebar ul li a {
    padding: 12px 24px;
    font-size: 0.95rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #64748b;
    text-decoration: none;
    transition: all 0.2s ease;
    border-right: 3px solid transparent;
}

#sidebar ul li a:hover {
    color: var(--primary);
    background-color: #f8fafc;
}

#sidebar ul li a.active {
    color: var(--primary);
    background-color: #eef2ff;
    border-right-color: var(--primary);
}

#sidebar ul li a i {
    width: 24px;
    text-align: center;
}

#content {
    width: 100%;
    min-width: 0; /* Prevents flex child from overflowing parent due to intrinsic width */
    min-height: 100vh;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
}

/* Navbar */
.navbar {
    padding: 0 24px;
    background: #ffffff;
    border: none;
    border-radius: 0;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    height: var(--topbar-height);
    display: flex;
    align-items: center;
}

.navbar-btn {
    box-shadow: none;
    outline: none !important;
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 1.2rem;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.navbar-btn:hover {
    background-color: #f1f5f9;
    color: var(--dark);
}

/* Page Components */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
    padding-top: 10px;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    color: #1e293b;
    display: flex;
    align-items: center;
}

.page-title i {
    color: var(--primary);
    margin-right: 12px;
}

/* Cards */
.card {
    border: none;
    border-radius: var(--card-radius);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    background: #ffffff;
    margin-bottom: 24px;
    transition: transform 0.2s, box-shadow 0.2s;
    overflow: hidden;
    /* Ensure content like tables doesn't spill rounded corners */
}

/* Exception for cards that need sticky children (e.g. inventory table headers) */
.card.card-sticky-overflow {
    overflow: visible;
}

/* Standardize Card Header */
.card-header {
    background-color: #ffffff;
    border-bottom: 1px solid #f1f5f9;
    padding: 16px 24px;
    font-weight: 600;
    font-size: 1.1rem;
    color: #334155;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body {
    padding: 24px;
}

/* Standardize Table Styles globally to force consistency */
.table {
    margin-bottom: 0;
    width: 100%;
}

.table th {
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    background-color: #f8fafc !important;
    /* Force light gray header */
    border-bottom: 1px solid #e2e8f0;
    padding: 16px 24px !important;
    /* Consistent padding */
    white-space: nowrap;
}

.table td {
    padding: 16px 24px !important;
    /* Consistent padding */
    vertical-align: middle;
    color: #334155;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.95rem;
}

.table-hover tbody tr:hover {
    background-color: #f8fafc;
}

/* Fix for tables inside cards to remove double padding */
.card .table-responsive {
    margin: 0;
    border-radius: 0 0 var(--card-radius) var(--card-radius);
}

.card .card-body.p-0 .table th,
.card .card-body.p-0 .table td {
    border-left: none;
    border-right: none;
}


/* Login */
.login-page {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f0f4ff 0%, #dbe4ff 100%);
}

.login-box {
    width: 100%;
    max-width: 420px;
    padding: 48px;
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
}

/* Utilities & Helpers */
.text-primary {
    color: var(--primary) !important;
}

.bg-primary {
    background-color: var(--primary) !important;
}

/* Sync Progress Alert Animation */
.alert-sync-progress {
    position: relative;
    overflow: hidden;
}

.alert-sync-progress::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background-image: linear-gradient(45deg,
            rgba(255, 255, 255, 0.2) 25%,
            transparent 25%,
            transparent 50%,
            rgba(255, 255, 255, 0.2) 50%,
            rgba(255, 255, 255, 0.2) 75%,
            transparent 75%,
            transparent);
    background-size: 1rem 1rem;
    animation: progress-stripes 1s linear infinite;
    z-index: 1;
    pointer-events: none;
}

@keyframes progress-stripes {
    from {
        background-position: 1rem 0;
    }

    to {
        background-position: 0 0;
    }
}

/* Responsive */
@media (max-width: 768px) {
    #sidebar {
        margin-left: calc(var(--sidebar-width) * -1);
    }

    #sidebar.active {
        margin-left: 0;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .page-header .btn {
        width: 100%;
    }
}

/* CRM WhatsApp Module Styles */
.crm-view {
    display: flex;
    width: 100%;
    height: 100%;
    /* Relative to parent posApp container */
    overflow: hidden;
    background-color: #f0f2f5;
}

/* 1. Chat List (Left) */
.crm-list-panel {
    width: 350px;
    background: white;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
}

.crm-list-item {
    padding: 15px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s;
}

.crm-list-item:hover,
.crm-list-item.active {
    background-color: #f5f6f6;
}

.crm-unread-badge {
    background-color: #25d366;
    color: white;
    border-radius: 50%;
    padding: 2px 6px;
    font-size: 0.75rem;
}

/* 2. Chat Area (Center) */
.crm-chat-panel {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-color: #efe7dd;
    /* background-image: url('...'); Add pattern if needed */
}

.crm-chat-header {
    background: #f0f2f5;
    padding: 10px 20px;
    border-bottom: 1px solid #d1d7db;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.crm-messages-area {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.crm-message {
    max-width: 60%;
    padding: 8px 12px;
    border-radius: 7.5px;
    font-size: 0.95rem;
    position: relative;
    word-wrap: break-word;
}

.crm-message.in {
    align-self: flex-start;
    background-color: white;
    border-top-left-radius: 0;
}

.crm-message.out {
    align-self: flex-end;
    background-color: #d9fdd3;
    border-top-right-radius: 0;
}

.crm-message-time {
    font-size: 0.7rem;
    color: #999;
    float: right;
    margin-left: 10px;
    margin-top: 5px;
}

.crm-input-area {
    background: #f0f2f5;
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* 3. Order Panel (Right) */
.crm-order-panel {
    width: 350px;
    background: white;
    border-left: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.crm-toggle-btn {
    transition: all 0.3s;
}

.crm-toggle-btn.active {
    background-color: #25d366 !important;
    color: white !important;
    border-color: #25d366 !important;
}