:root {
    --primary-color: #0054ab;
    /* Dark Blue/Gray - Industrial */
    --secondary-color: #f39c12;
    /* Industrial Yellow */
    --accent-color: #3498db;
    /* Blue */
    --bg-color: #f4f6f7;
    --card-bg: #ffee00;
    --text-color: #1d1d1d;
    --border-color: #f0f0f0;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --font-main: 'Cairo', sans-serif;
    --number-weight: 800;

    /* Global Classes */
    body.modal-open {
        overflow: hidden !important;
        height: 100vh !important;
        position: fixed !important;
        width: 100% !important;
    }

    /* Extra bold for numbers */
}

/* 🌐 Connectivity Banner */
.connectivity-banner {
    background: #f59e0b;
    color: white;
    padding: 6px 10px;
    text-align: center;
    font-weight: 700;
    font-size: 0.85rem;
    z-index: 100;
    display: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    animation: slideDownInFlow 0.3s ease;
    width: 100%;
    border-bottom: 2px solid rgba(0, 0, 0, 0.1);
}

@keyframes slideDownInFlow {
    from {
        max-height: 0;
        opacity: 0;
        padding: 0;
    }

    to {
        max-height: 50px;
        opacity: 1;
        padding: 6px 10px;
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Unified Modern Header System */
.main-header {
    background: #ffffff;
    padding: 10px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    /* Lighter shadow */
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.logo-area h1 {
    font-size: 1.4rem;
    font-weight: 800;
    margin: 0;
    letter-spacing: -0.5px;
    color: #2c3e50;
    /* Dark Grey (Ramady Ghameq) - slightly blueish for professional look, or strict #333 */
    text-shadow: none;
}



.main-nav {
    display: flex;
    gap: 10px;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}



.logo-area p {
    color: #555555;
    /* Dark Grey */
    opacity: 1;
    margin-top: 5px;
    font-size: 0.95rem;
}

.nav-btn {
    background: white;
    border: 1px solid #e0e0e0;
    color: var(--primary-color);
    padding: 0.6rem 1.2rem;
    border-radius: 50px;
    cursor: pointer;
    font-family: var(--font-main);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    font-size: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    position: relative;
    white-space: nowrap;
}

.nav-btn .btn-text {
    font-size: 1rem;
}

/* Specific Style for Invoice Button */
.invoice-btn {
    background: #27ae60 !important;
    /* Excel Green */
    color: white !important;
    border: 1px solid #27ae60 !important;
    box-shadow: none !important;
    /* No Shadow */
}

.invoice-btn:hover {
    background: #219150 !important;
    /* Slightly Darker Green */
    transform: none !important;
    /* Stop movement */
    box-shadow: none !important;
}

.invoice-btn .badge {
    background: white;
    color: red !important;
    /* Red Number */
    font-weight: 900;
}

.nav-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    background: #f8f9fa;
}

.facebook-btn {
    background: white;
    color: #1877F2;
    border: 1px solid #1877F2;
    box-shadow: 0 4px 12px rgba(24, 119, 242, 0.1);
}

.facebook-btn:hover {
    background: #1877F2;
    color: white;
    box-shadow: 0 6px 15px rgba(24, 119, 242, 0.3);
}

.nav-btn i {
    font-size: 1.1rem;
}

/* Badge Style */
.badge {
    background: white;
    color: black;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 800;
    margin-right: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* User Info Bar Styles */
#user-info-bar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 12px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.user-bar-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.welcome-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    color: #667eea;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
}

.user-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.user-name {
    color: white;
    font-weight: 600;
    font-size: 1rem;
}

.user-role-badge {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    width: fit-content;
}

.logout-btn-modern {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    font-family: inherit;
    font-size: 0.9rem;
}

.logout-btn-modern:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    #user-info-bar {
        padding: 8px 0;
    }

    .user-bar-content {
        padding: 0 15px;
        display: flex;
        /* Ensure flex behavior */
        flex-direction: row;
        /* Force row direction */
        justify-content: space-between;
        /* Ensure Logout (Left) and User (Right) separation in RTL */
        width: 100%;

        /* Ensure full width usage */
    }

    #status-badges-container {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    #status-badges-container span {
        width: 100%;
        display: flex !important;
        align-items: center;
        justify-content: center;
        font-size: 0.75rem !important;
        padding: 5px !important;
        white-space: normal;
        text-align: center;
        height: 100%;
    }
}

.welcome-section {
    gap: 8px;
}

.user-avatar {
    width: 35px;
    height: 35px;
    font-size: 1rem;
}

.user-name {
    font-size: 0.9rem;
}

.user-role-badge {
    font-size: 0.7rem;
}

.logout-btn-modern {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.desktop-only {
    display: none;
}


/* Mobile Adjustments */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 10px;
        padding-bottom: 5px;
    }

    .logo-area {
        width: 100%;
        display: flex;
        justify-content: center;
        padding: 0;
        margin: 0;
    }

    .logo-area h1 {
        white-space: nowrap !important;
        font-size: 3.8vw;
        display: block;
        width: 100%;
        text-align: center;
        color: #2c3e50;
        /* Dark Grey */
        /* Fallback */
        margin: 0 auto;
        padding: 0;
    }

    .main-nav {
        width: 100%;
        justify-content: center;
    }

    .nav-btn {
        padding: 0.4rem 0.9rem;
        font-size: 0.9rem;
    }

    /* 3 Column Grid for Mobile */
    .categories-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
    }

    .category-card {
        padding: 10px 5px !important;
        aspect-ratio: 1 / 1;
        /* Square Shape */
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }

    .category-card i {
        width: 45px !important;
        height: 45px !important;
        line-height: 45px !important;
        font-size: 1.2rem !important;
        margin-bottom: 10px !important;
    }

    .category-card h3 {
        font-size: 0.8rem !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* 3 Column Grid for Tools Grid (Control Tools Modal) */
    .tools-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 10px !important;
    }

    .tool-item {
        padding: 15px 8px !important;
        font-size: 0.85rem !important;
    }

    .tool-item i {
        font-size: 1.5rem !important;
        margin-bottom: 8px !important;
    }

    .tool-item h3 {
        font-size: 0.75rem !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* Controls */
.controls-section {
    margin: 12px 0;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .controls-section {
        margin: 8px 0;
    }
}

.search-box,
.filter-box {
    flex: 1;
    background: white;
    padding: 10px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow);
}

.search-box input,
.filter-box select {
    border: none;
    outline: none;
    width: 100%;
    font-family: var(--font-main);
    font-size: 1rem;
}

/* Categories */
.categories-section {
    margin-bottom: 30px;
    margin-top: 12px;
}

@media (max-width: 768px) {
    .categories-section {
        margin-top: 8px;
        margin-bottom: 20px;
    }
}

.categories-section h2,
.products-section h2 {
    margin-bottom: 15px;
    border-right: 5px solid var(--secondary-color);
    padding-right: 10px;
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}

/* Category Card Updates */
.category-card {
    background: linear-gradient(135deg, #ffffff 0%, #f4f6f7 100%);
    padding: 25px 20px;
    border-radius: 15px;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px dashed color-mix(in srgb, var(--primary-color), transparent 60%);
    position: relative;
    overflow: hidden;
}

.category-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: var(--secondary-color);
    transform: scaleX(0);
    transition: transform 0.4s;
    transform-origin: left;
}

.order-card.status-received {
    background-color: #fff8e1 !important;
    /* Light Yellow/Orange Background */
    border: 2px solid #f39c12 !important;
    /* Full Orange Border */
    box-shadow: 0 4px 10px rgba(243, 156, 18, 0.2);
    /* Slight glow */
}

.order-card.status-sent {
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    /* Default border */
    border-right: 4px solid #bdc3c7 !important;
    /* Keep Right Border for Sent/Default */
}

.order-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.category-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
    border-color: rgba(243, 156, 18, 0.3);
}

.category-card:hover::before {
    transform: scaleX(1);
}

/* Update Card Special Styling */
.category-card.update-card {
    background: linear-gradient(135deg, #e6f9ff 0%, #ffffff 100%);
    border: 1px dashed var(--accent-color);
}

.category-card.update-card::before {
    background: var(--accent-color);
}

.category-card.update-card i {
    background: var(--accent-color);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.3);
}

.category-card.update-card:hover i {
    transform: rotate(360deg);
    background: #2980b9;
}

.category-card.update-card h3 {
    color: var(--accent-color);
}

.category-card i {
    font-size: 1.8rem;
    color: white;
    background: var(--primary-color);
    width: 70px;
    height: 70px;
    line-height: 70px;
    border-radius: 50%;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(44, 62, 80, 0.2);
    transition: all 0.3s;
}

.category-card:hover i {
    background: var(--secondary-color);
    color: white;
    transform: rotateY(180deg);
}

.category-card h3 {
    color: #000000;
    font-size: 1.1rem;
    font-weight: 700;
}

/* All Categories Icon - Dark Gray */
.category-card[data-category="all"] i {
    background: #546e7a !important;
    /* Dark Gray for All Categories */
}

.category-card[data-category="all"]:hover i {
    background: #607d8b !important;
    /* Lighter Gray on Hover */
}

.category-card[data-category="all"] {
    border-color: rgba(84, 110, 122, 0.4) !important;
}

/* Category-Specific Icon Colors - Harmonious Dark Tones */
.category-card[data-category*="PPR"] i,
.category-card[data-category*="ppr"] i {
    background: #06923E !important;
    /* Green for PPR */
}

.category-card[data-category*="PPR"]:hover i,
.category-card[data-category*="ppr"]:hover i {
    background: #07b34a !important;
    /* Lighter Green on Hover */
}

.category-card[data-category*="PPR"],
.category-card[data-category*="ppr"] {
    border-color: rgba(6, 146, 62, 0.4) !important;
}

.category-card[data-category*="PVC 110"] i,
.category-card[data-category*="pvc 110"] i {
    background: #0054ab !important;
    /* Keep Blue for PVC 110 */
}

.category-card[data-category*="PVC 110"]:hover i,
.category-card[data-category*="pvc 110"]:hover i {
    background: #1976d2 !important;
}

.category-card[data-category*="PVC 110"],
.category-card[data-category*="pvc 110"] {
    border-color: rgba(0, 84, 171, 0.4) !important;
}

.category-card[data-category*="PVC 114"] i,
.category-card[data-category*="pvc 114"] i {
    background: #c4161c !important;
    /* Red for PVC 114 */
}

.category-card[data-category*="PVC 114"]:hover i,
.category-card[data-category*="pvc 114"]:hover i {
    background: #e01b22 !important;
    /* Lighter Red on Hover */
}

.category-card[data-category*="PVC 114"],
.category-card[data-category*="pvc 114"] {
    border-color: rgba(196, 22, 28, 0.4) !important;
}

.category-card[data-category*="PPH"] i,
.category-card[data-category*="pph"] i {
    background: #6E026F !important;
    /* Purple for PPH */
}

.category-card[data-category*="PPH"]:hover i,
.category-card[data-category*="pph"]:hover i {
    background: #8e24aa !important;
    /* Lighter Purple on Hover */
}

.category-card[data-category*="PPH"],
.category-card[data-category*="pph"] {
    border-color: rgba(110, 2, 111, 0.4) !important;
}

.category-card[data-category*="منتجات"] i,
.category-card[data-category*="اخرى"] i,
.category-card[data-category*="أخرى"] i {
    background: #EC5228 !important;
    /* Orange for Other Products */
}

.category-card[data-category*="منتجات"]:hover i,
.category-card[data-category*="اخرى"]:hover i,
.category-card[data-category*="أخرى"]:hover i {
    background: #ff6f4a !important;
    /* Lighter Orange on Hover */
}

.category-card[data-category*="منتجات"],
.category-card[data-category*="اخرى"],
.category-card[data-category*="أخرى"] {
    border-color: rgba(236, 82, 40, 0.4) !important;
}


/* Tools Grid (Control Tools Modal) */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
}

.tool-item {
    background: linear-gradient(135deg, #ffffff 0%, #f4f6f7 100%);
    padding: 25px 20px;
    border-radius: 15px;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px dashed color-mix(in srgb, var(--primary-color), transparent 60%);
    position: relative;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.tool-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
    border-color: rgba(243, 156, 18, 0.3);
}

.tool-item i {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 15px;
}

.tool-item h3 {
    color: var(--primary-color);
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
}

/* Products */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 50px;
}

.product-card {
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    transition: transform 0.2s;
}

.product-card:hover {
    transform: translateY(-3px);
}

.product-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    /* Square */
    object-fit: contain;
    background-color: #fff;
    padding: 10px;
    border: 1px dashed color-mix(in srgb, var(--primary-color), transparent 70%);
    /* 30% Opacity */
    border-radius: var(--radius);
}

.product-info {
    padding: 15px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.product-category {
    font-size: 0.8rem;
    color: #777;
    margin-bottom: 5px;
}

.product-name {
    font-weight: bold;
    margin-bottom: 10px;
    flex-grow: 1;
}

.product-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

.product-price {
    font-size: 1.1rem;
    color: var(--primary-color);
    font-weight: bold;
}

.add-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.add-btn:hover {
    background: var(--secondary-color);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.3s ease;
    pointer-events: none;
    opacity: 0;
}

.modal:not(.hidden) {
    background: rgba(0, 0, 0, 0.6);
    pointer-events: auto;
    opacity: 1;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    width: 95%;
    max-width: 800px;
    max-height: 90vh;
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    border: 1px solid #ddd;
    transform: translateY(30px) scale(0.95);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
    opacity: 0;
}

@media (max-width: 768px) {
    .modal-content {
        max-height: 80vh !important;
        margin-bottom: 20px;
    }
}

.modal:not(.hidden) .modal-content {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.modal-header {
    padding: 15px;
    background: var(--primary-color);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex-grow: 1;
    -webkit-overflow-scrolling: touch;
    /* Smooth scroll on iOS */
}

@media (max-width: 768px) {
    .modal-body {
        padding-bottom: 80px;
        /* Space for bottom nav */
    }
}

.invoice-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 20px;
    border: 1px solid #eee;
    border-radius: 8px;
    overflow: hidden;
}

.invoice-table th,
.invoice-table td {
    padding: 10px;
    border-bottom: 1px solid #eee;
    border-left: 1px solid #eee;
    text-align: center !important;
    vertical-align: middle;
}

.invoice-table th {
    background-color: var(--primary-color);
    color: white;
    font-weight: bold;
}

.invoice-table tr:last-child td {
    border-bottom: none;
}

.qty-input {
    width: 90px;
    padding: 5px;
    text-align: center;
}

.remove-btn {
    color: red;
    background: none;
    border: none;
    cursor: pointer;
}

/* Invoice Styling Updates */
.product-cell-content {
    display: flex;
    display: flex;
    justify-content: flex-start;
    /* Right Align */
    /* Center horizontally */
    align-items: center;
    gap: 8px;
    /* Space between name and size */
    flex-wrap: wrap;
    /* Allow wrapping if too long */
}

.invoice-product-name {
    font-weight: bold;
}

.invoice-product-size {
    font-size: 0.9rem;
    color: #27ae60;
    /* Green text */
    font-weight: bold;
    white-space: nowrap;
    border: 2px solid #27ae60;
    padding: 2px 8px;
    border-radius: 6px;
    background-color: rgba(39, 174, 96, 0.1);
    /* Light green bg */
    display: inline-block;
}

/* Force Table Centering */
.invoice-table th,
.invoice-table td {
    padding: 4px 8px !important;
    /* Compressed padding */
    border-bottom: 1px solid #eee;
    border-left: 1px solid #eee;
    text-align: center !important;
    vertical-align: middle;
    font-weight: var(--number-weight);
    font-size: 0.95rem;
    /* Slightly smaller text */
}

/* Mobile Invoice Cards */
/* Mobile Invoice Cards - CSS Grid Layout */
@media (max-width: 768px) {
    .invoice-table thead {
        display: none;
    }

    .invoice-table tbody {
        display: flex;
        flex-direction: column;
        gap: 15px;
        /* Space between cards */
    }

    .invoice-table tr {
        display: grid;
        grid-template-columns: 1.5fr 1fr;
        /* Product column wider */
        gap: 8px;
        background: #fff;
        border: 2px solid #546e7a;
        /* Darker border as requested */
        border-radius: 8px;
        padding: 10px;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
        position: relative;
    }

    /* Grid Area Assignments */
    /* Row 1: Product | Price */
    .invoice-table td:nth-of-type(1) {
        grid-column: 1 / 2;
        grid-row: 1;
        position: relative;
        padding-bottom: 8px !important;
        margin-bottom: 8px;
    }

    /* Separator Line for Row 1 */
    .invoice-table td:nth-of-type(1)::after,
    .invoice-table td:nth-of-type(2)::after {
        content: "";
        position: absolute;
        bottom: 0;
        left: 5%;
        /* Start 5% from left */
        width: 90%;
        /* Width 90% -> doesn't touch borders */
        height: 1px;
        background-color: #f1f5f9;
    }

    .invoice-table td:nth-of-type(2) {
        grid-column: 2 / 3;
        grid-row: 1;
        position: relative;
        padding-bottom: 8px !important;
        margin-bottom: 8px;
        justify-content: center;
        /* Center Price */
    }

    /* Row 2: Piece (Qty) | Carton */
    .invoice-table td:nth-of-type(3) {
        grid-column: 1 / 2;
        grid-row: 2;
        position: relative;
        padding-bottom: 8px !important;
        margin-bottom: 8px;
    }

    /* Separator Line for Row 2 */
    .invoice-table td:nth-of-type(3)::after,
    .invoice-table td:nth-of-type(4)::after {
        content: "";
        position: absolute;
        bottom: 0;
        left: 5%;
        width: 90%;
        height: 1px;
        background-color: #f1f5f9;
    }

    .invoice-table td:nth-of-type(4) {
        grid-column: 2 / 3;
        grid-row: 2;
        position: relative;
        padding-bottom: 8px !important;
        margin-bottom: 8px;
    }

    /* Row 3: Total | Delete */
    .invoice-table td:nth-of-type(5) {
        grid-column: 1 / 2;
        grid-row: 3;
        background: #f8f9fa;
        /* Restore Gray Background */
        border-radius: 4px;
        /* Rounded corners */
        justify-content: center;
        align-items: center;
        /* Center alignment looks better with background */
        padding: 8px !important;
        /* Add padding for the background */
        margin: 2px;
        /* Margin for spacing */
    }

    .invoice-table td:nth-of-type(6) {
        grid-column: 2 / 3;
        grid-row: 3;
        display: flex;
        justify-content: flex-end;
        /* Align delete button to edge */
        align-items: center;
    }

    /* Cell Styling - Flex to stack Label + Value */
    .invoice-table td {
        display: flex;
        flex-direction: column;
        align-items: center;
        /* Center content */
        text-align: center !important;
        padding: 4px !important;
        border: none !important;
        /* Grid handles separation */
        font-size: 0.9rem;
    }

    /* Clean Labels */
    .invoice-table td::before {
        font-size: 0.8rem;
        color: #7f8c8d;
        margin-bottom: 2px;
        font-weight: bold;
    }

    /* 1. Product Name */
    .invoice-table td:nth-of-type(1) {
        align-items: flex-start;
        /* Right align (RTL) */
        text-align: right !important;
    }

    /* Ensure Product Name, Piece, and Total are vertically aligned on the right (RTL start) */
    .invoice-table td:nth-of-type(1),
    .invoice-table td:nth-of-type(3),
    .invoice-table td:nth-of-type(5) {
        align-items: flex-start;
        /* Right align in RTL */
    }

    .invoice-table td:nth-of-type(1)::before {
        content: "المنتج:";
        display: none;
    }

    /* 2. Price */
    .invoice-table td:nth-of-type(2)::before {
        content: "السعر:";
    }

    /* 3. Piece */
    .invoice-table td:nth-of-type(3)::before {
        content: "الكمية:";
        display: block;
        /* Show Label */
        font-weight: bold;
        color: #7f8c8d;
        margin-bottom: 2px;
    }

    /* We want the input to have a label perhaps? Or just rely on the input's internal label if we add one in JS?
        User asked to align "Product Name" with "Piece" and "Total"
        So we align items: flex-start (Right in RTL).
     */

    /* 4. Carton */
    /* 4. Carton */
    .invoice-table td:nth-of-type(4)::before {
        content: "عدد الكراتين:";
        display: block;
        /* Show Label */
        font-weight: bold;
        color: #7f8c8d;
        margin-bottom: 2px;
    }

    /* Reset .box-label since we now have a main label */
    .box-label {
        font-size: 0.85rem !important;
        /* Restore if needed or keep hidden if redundant */
        display: none !important;
        /* Hide the inner label to avoid duplication */
    }

    /* 5. Total */
    .invoice-table td:nth-of-type(5)::before {
        content: "الإجمالي:";
        display: block;
    }

    .invoice-table td:nth-of-type(5) {
        font-weight: bold;
        color: #2c3e50;
    }

    /* 6. Delete */
    .invoice-table td:nth-of-type(6)::before {
        content: "";
        display: none;
    }


    /* Adjustments for inputs in grid */
    .qty-input {
        width: 100% !important;
        max-width: 110px;
        /* Increased from 80px */
        padding: 8px !important;
        /* Increased padding */
        font-size: 1.1rem !important;
        /* Increased font size */
        height: 45px;
        /* Fixed height for better touch */
    }

    .box-input-wrapper {
        justify-content: center;
        flex-direction: column;
        /* Stack input and badge */
        gap: 2px;
    }

    .box-qty-input {
        width: 100% !important;
        max-width: 90px;
        /* Increased from 60px */
        padding: 8px !important;
        font-size: 1.1rem !important;
        height: 45px;
    }

    .remove-btn {
        width: 100%;
        background: #ffebee;
        color: #c0392b;
        border-radius: 4px;
        padding: 5px;
    }
}


/* Box Input Alignment */
.box-input-wrapper {
    display: flex;
    flex-direction: row;
    /* One row */
    align-items: center;
    justify-content: flex-start;
    /* Right Align in RTL */
    gap: 10px;
    width: 100%;
}

.box-input-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: auto;
}

.box-qty-input {
    width: 90px;
    text-align: center;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Hide Spinners */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    margin: 0;
}

input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
}

@media (max-width: 768px) {
    .variant-item {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .variant-field {
        flex-direction: row;
        justify-content: space-between;
    }
}


.box-label {
    font-size: 0.9rem;
}

.excess-badge {
    font-size: 0.8rem;
    color: white;
    background-color: #e67e22;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
    min-width: 60px;
    text-align: center;
}

.excess-placeholder {
    min-height: 20px;
}

/* Modern Invoice Footer */
.invoice-footer {
    margin-top: 20px;
    background: linear-gradient(to bottom, #ffffff, #f7f9fa);
    border: 1px solid #eee;
    padding: 30px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.02);
}

.invoice-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.1rem;
    color: #555;
    padding: 0 10px;
}

.summary-value {
    font-weight: var(--number-weight);
    color: #333;
}

.invoice-summary-divider {
    height: 1px;
    background-color: #eee;
    margin: 5px 0;
}

.discount-row {
    color: #c0392b;
    display: none;
    background-color: rgba(192, 57, 43, 0.05);
    padding: 5px 10px;
    border-radius: 4px;
}

.discount-row.active {
    display: flex;
}

.discount-row .summary-value {
    color: #c0392b;
}

/* Hero Total Section */
.total-row-hero {
    margin: 15px auto;
    /* Center it */
    width: 75%;
    /* 3/4 Width */
    background: #e9ecef;
    /* Light Gray */
    color: black;
    /* Black Text */
    padding: 15px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-shadow: none;
    /* Remove heavy shadow or keep subtle */
    border: 1px solid #ccc;
}

.total-label-hero {
    font-size: 1.1rem;
    margin-bottom: 5px;
    opacity: 1;
    color: #333;
    font-weight: bold;
}

.total-value-hero {
    font-size: 2.2rem;
    /* Slightly smaller to fit */
    font-weight: var(--number-weight);
    line-height: 1;
    letter-spacing: 0;
    color: #000;
}

.modal-footer {
    padding: 15px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.action-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--font-main);
    display: flex;
    align-items: center;
    gap: 5px;
}

.action-btn.primary {
    background: var(--primary-color);
    color: white;
}

.action-btn.secondary {
    background: var(--accent-color);
    color: white;
}

.action-btn.danger {
    background: #e74c3c;
    color: white;
}

/* Toast */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 59, 107, 0.95);
    color: white;
    padding: 10px 20px;
    border-radius: 12px;
    z-index: 99999;
    animation: fadeInOut 2.5s ease-in-out;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    width: 85%;
    max-width: 300px;
    height: auto !important;
    /* Force auto height */
    max-height: fit-content;
    overflow: hidden;
    transition: background-color 0.3s ease;
    pointer-events: none;
}

@media (max-width: 768px) {
    .toast {
        top: 10px;
        padding: 8px 15px;
    }

    .toast h4 {
        font-size: 1rem !important;
        /* Smaller text on mobile */
        margin-bottom: 3px !important;
    }

    .toast p {
        font-size: 0.9rem !important;
        margin: 0 !important;
    }
}

@media print {
    @page {
        size: A4;
        margin: 0;
    }

    body {
        background-color: white;
        margin: 0;
        padding: 0;
    }

    /* Hide everything by default */
    body>* {
        display: none !important;
    }

    /* Show only the modal/invoice */
    #invoice-modal,
    #invoice-modal .modal-content,
    #invoice-modal .modal-body,
    #invoice-modal .invoice-details {
        display: block !important;
        position: static !important;
        width: 100% !important;
        height: auto !important;
        max-width: none !important;
        max-height: none !important;
        overflow: visible !important;
        background: white !important;
        box-shadow: none !important;
        border: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Specific visibility fixes */
    #invoice-modal {
        display: block !important;
        position: absolute !important;
        top: 0;
        left: 0;
        z-index: 9999;
    }

    /* Hide control elements within the modal */
    .modal-header,
    .modal-footer,
    .close-btn,
    .no-print,
    .remove-btn,
    .action-btn {
        display: none !important;
    }

    /* Table Styling for Print */
    .invoice-table {
        width: 100% !important;
        border-collapse: collapse;
    }

    .invoice-table th,
    .invoice-table td {
        border: 1px solid #ddd !important;
        padding: 8px !important;
        color: #000 !important;
    }

    .invoice-table th {
        background-color: #f0f0f0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Content Layout */
    .invoice-header-info {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 20px;
        padding-top: 20px;
    }

    /* Ensure Inputs print as text */
    input {
        border: none !important;
        background: transparent !important;
        padding: 0 !important;
    }

    /* Footer positioning */
    .invoice-footer {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}


.toast.alt-color {
    background: rgba(243, 156, 18, 0.95);
    color: #333;
    /* Secondary Color */
}


.toast.alt-color h4 {
    color: #000;
}

.toast h4 {
    margin-bottom: 5px;
    font-size: 1.2rem;
    color: #f39c12;
}

.toast p {
    font-size: 1.1rem;
}

.hidden {
    display: none;
}

@keyframes fadeInOut {
    0% {
        opacity: 0;
        transform: translate(-50%, -20px);
    }

    10% {
        opacity: 1;
        transform: translate(-50%, 0);
    }

    90% {
        opacity: 1;
        transform: translate(-50%, 0);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -20px);
    }
}

/* Spinner */
.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--secondary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Variants Modal Specifics */
.small-modal {
    max-width: 500px;
}

.variants-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.variant-item {
    display: flex;
    flex-direction: column;
    padding: 15px;
    border: 1px solid #eee;
    border-radius: var(--radius);
    background: #f9f9f9;
    gap: 10px;
}

.variant-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    gap: 10px;
}

.variant-size {
    font-weight: bold;
    font-size: 1.1rem;
    color: #27ae60;
    border: 2px solid #27ae60;
    padding: 2px 8px;
    border-radius: 6px;
    background-color: rgba(39, 174, 96, 0.1);
    white-space: nowrap;
    flex: 1;
    /* Take 1/3 space */
    text-align: right;
    /* RTL Start */
    max-width: fit-content;
    /* Don't stretch the box itself */
}

/* Wrapper for center item to allowing centering in flex:1 area */
.variant-center-info {
    flex: 1;
    /* Take 1/3 space */
    display: flex;
    justify-content: center;
}

.variant-price {
    color: #c0392b;
    font-weight: bold;
    font-size: 1.4rem;
    flex: 1;
    /* Take 1/3 space */
    text-align: left;
    /* RTL End */
}

.variant-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.action-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.action-label {
    width: 60px;
    font-weight: bold;
    font-size: 0.9rem;
}

/* .variant-size and .variant-price handled above */

.carton-badge {
    background-color: #e67e22;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: bold;
    margin-right: 5px;
    display: inline-block;
}

.variant-add-btn {
    flex-grow: 1;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--font-main);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: opacity 0.2s;
}

.piece-btn {
    background: var(--accent-color);
}

.carton-btn {
    background: var(--primary-color);
}

.variant-add-btn:hover {
    opacity: 0.9;
}

/* Invoice Header Inputs */
.invoice-header-info {
    margin-bottom: 20px;
}

.invoice-inputs {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 15px;
}

.invoice-row {
    display: flex;
    gap: 20px;
}

.input-group {
    display: flex;
    align-items: center;
    gap: 5px;
}

.input-group input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-family: var(--font-main);
    transition: border-color 0.3s;
}

.input-group input:focus {
    border-color: var(--secondary-color);
    outline: none;
}

/* Customer Name Specific Styling */
.customer-input-group {
    flex: 2;
    /* Give it more space */
}

.customer-name-input {
    font-size: 1.1rem !important;
    font-weight: bold;
    color: var(--primary-color);
    border: 2px solid #e0e0e0 !important;
    background-color: #fcfcfc;
    width: 100%;
}

.customer-name-input:focus {
    border-color: var(--secondary-color) !important;
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.1);
}


/* Mobile Grid Override */
@media (max-width: 768px) {


    .invoice-header-info h3 {
        display: block;
        max-width: 200px;
        margin: 0 auto 15px auto;
        line-height: 1.4;
        text-align: center;
        white-space: normal;
    }

    .products-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 5px;
    }

    .product-card {
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }

    .product-info {
        padding: 5px;
    }

    .product-name {
        font-size: 0.75rem;
        margin-bottom: 5px;
    }

    .product-price {
        font-size: 0.8rem;
    }

    .add-btn {
        padding: 4px 8px;
        font-size: 0.7rem;
    }

    .add-btn i {
        font-size: 0.7rem;
    }
}

/* Category Export Buttons */
.category-export-btns {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 15px;
}

.cat-export-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    font-family: var(--font-main);
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s;
    color: white;
    margin-top: 2px;
}

.cat-export-btn.pdf {
    background-color: #e74c3c;
}

.cat-export-btn.excel {
    background-color: #27ae60;
}

.cat-export-btn:hover {
    transform: scale(1.05);
    filter: brightness(1.1);
}

/* Control Tools Modal */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 15px;
    padding: 10px;
}

.tool-item {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px;
    background: #f8f9fa;
    border: 1px solid #eee;
    border-radius: 12px;
    text-decoration: none;
    color: var(--primary-color);
    font-weight: bold;
    font-size: 1.1rem;
    transition: all 0.3s;
}

.tool-item:hover {
    background: var(--accent-color);
    color: white;
    transform: translateX(-5px);
}

.tool-item i {
    font-size: 1.5rem;
}

/* Login Overlay Styles */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--primary-color);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.login-card {
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-card i {
    font-size: 3rem;
    color: var(--secondary-color);
    margin-bottom: 20px;
}

.login-card h2 {
    margin-bottom: 30px;
    color: var(--primary-color);
}

.login-group {
    margin-bottom: 20px;
    text-align: right;
}

.login-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
}

.login-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #eee;
    border-radius: 10px;
    font-family: var(--font-main);
    font-size: 1rem;
    outline: none;
}

.login-group input:focus {
    border-color: var(--secondary-color);
}

.login-btn {
    width: 100%;
    padding: 15px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 10px;
    font-family: var(--font-main);
    font-weight: bold;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.3s;
}

.login-btn:hover {
    background: #1a252f;
}

.login-error {
    color: #e74c3c;
    margin-bottom: 15px;
    font-weight: bold;
    display: none;
}

/* Modern Login Page Styles - Professional */
body.login-page {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Cairo', sans-serif;
}

.login-wrapper {
    width: 100%;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.login-container-modern {
    background: white;
    padding: 3.5rem 3rem;
    border-radius: 28px;
    box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.25),
        0 18px 36px -18px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 460px;
    text-align: center;
    position: relative;
    z-index: 10;
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header {
    margin-bottom: 2.5rem;
}

.login-header i {
    font-size: 3.5rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, #6366f1 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1.2rem;
    display: inline-block;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

.login-header h2 {
    font-size: 2.2rem;
    color: #1e293b;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.login-header p {
    color: #64748b;
    margin-bottom: 0;
    font-size: 1rem;
}

.modern-input-group {
    margin-bottom: 1.8rem;
    text-align: right;
}

.modern-input-group label {
    display: block;
    margin-bottom: 10px;
    color: #334155;
    font-weight: 600;
    font-size: 0.95rem;
}

.modern-input {
    width: 100%;
    padding: 16px 18px;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: #f8fafc;
    font-family: 'Cairo', sans-serif;
}

.modern-input:focus {
    border-color: #667eea;
    background: white;
    outline: none;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
    transform: translateY(-2px);
}

.modern-input::placeholder {
    color: #94a3b8;
}

.modern-btn {
    width: 100%;
    padding: 18px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 14px;
    font-size: 1.15rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    font-family: 'Cairo', sans-serif;
    box-shadow: 0 10px 20px -10px rgba(102, 126, 234, 0.5);
}

.modern-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 30px -10px rgba(102, 126, 234, 0.6);
}

.modern-btn:active {
    transform: translateY(-1px);
}

#error-message {
    background: #fee2e2;
    color: #991b1b;
    padding: 12px;
    border-radius: 10px;
    margin-top: 1.5rem;
    font-size: 0.9rem;
    border-left: 4px solid #dc2626;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .login-container-modern {
        padding: 2.5rem 1.8rem;
        border-radius: 24px;
    }

    .login-header h2 {
        font-size: 1.8rem;
    }

    .login-header i {
        font-size: 2.8rem;
    }
}

/* Ensure no conflicts with old styles */
.login-box,
.login-container {
    display: none !important;
}

/* Screen Rotation for Invoice */
.invoice-rotated {
    transform: rotate(90deg);
    transform-origin: center;
    width: 100vh !important;
    height: 100vw !important;
    position: fixed;
    top: 50%;
    left: 50%;
    translate: -50% -50%;
    z-index: 10000;
    background: white;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    box-sizing: border-box;
}

/* Hide header/buttons in rotated view to save space if needed */
.invoice-rotated .modal-header,
.invoice-rotated .modal-footer {
    padding: 10px;
}

/* Ensure the rotate button is visible */
.icon-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
    transition: transform 0.3s;
}

.icon-btn:hover {
    transform: rotate(45deg);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* User Info Area */
.user-nav-area {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-right: 15px;
}

.user-info-chip {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 5px 15px;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
}

.user-name {
    font-size: 0.95rem;
    font-weight: 600;
}

.logout-btn {
    background: none;
    border: none;
    color: #ff4757;
    margin-right: 10px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
}

.logout-btn:hover {
    transform: scale(1.2);
}

.dashboard-link:hover,
.login-link:hover {
    color: #ffffff !important;
    text-shadow: 0 0 10px rgba(255, 204, 0, 0.5);
}

@media (max-width: 768px) {
    .user-nav-area {
        margin-right: 0;
        width: 100%;
        justify-content: center;
        margin-top: 10px;
    }

    .user-info-chip {
        width: 100%;
        justify-content: space-between;
    }
}

/* User Info Bar (New Modern Design) */
.user-info-bar {
    background: #ffffff;
    border-bottom: 1px solid #eef1f5;
    padding: 8px 0;
    margin-bottom: 5px;
    box-shadow: none;
    display: flex;
    justify-content: center;
    /* Center initially */
    align-items: center;
    direction: rtl;
    min-height: 45px;
    animation: slideDown 0.4s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-bar-content {
    width: 90%;
    max-width: 1200px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.user-welcome {
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    padding: 6px 15px;
    border-radius: 30px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid #eee;
}

.user-welcome i {
    font-size: 1.1rem;
    color: #3498db;
    background: #e1f0ff;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.user-details {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.user-name {
    font-weight: 700;
    color: #2c3e50;
    font-size: 0.85rem;
}

.user-role-badge {
    font-size: 0.75rem;
    color: #7f8c8d;
    background: #f0f2f5;
    padding: 2px 8px;
    border-radius: 10px;
    width: fit-content;
    margin-top: 2px;
}

.user-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Dashboard Button (Sales) */
.dashboard-link-btn {
    text-decoration: none;
    background: linear-gradient(135deg, #8e44ad, #9b59b6);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 3px 6px rgba(142, 68, 173, 0.2);
    border: none;
    cursor: pointer;
}

.dashboard-link-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 12px rgba(142, 68, 173, 0.3);
    background: linear-gradient(135deg, #732d91, #8e44ad);
}

/* Logout Button */
.logout-bar-btn {
    background: white;
    color: #e74c3c;
    border: 1px solid #fadbd8;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.logout-bar-btn:hover {
    background: #feebec;
    border-color: #e74c3c;
    transform: translateY(-1px);
}

/* Mobile Tweaks */
@media (max-width: 600px) {
    .user-bar-content {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .user-welcome {
        width: 100%;
        justify-content: center;
    }

    .user-actions {
        width: 100%;
        justify-content: center;
    }
}

/* Permissions Bar */
.permissions-bar {
    background: #2c3e50;
    /* Hide old bar */
}

/* Permissions Bar - Legacy Cleanup */
.permissions-bar-legacy {
    display: none;
}

/* Modern User Bar & Dashboard Styles */
:root {
    --glass-bg: rgba(255, 255, 255, 0.95);
    --glass-border: 1px solid rgba(255, 255, 255, 0.2);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --primary-gradient: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}

#user-info-bar {
    background: #ffffff;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #eef1f5;
    padding: 8px 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: none;
    margin-bottom: 5px;
    border-radius: 0 0 10px 10px;
    min-height: 45px;
}

.user-bar-content {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    width: 100%;
    justify-content: space-between;
}

.welcome-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-avatar {
    width: 45px;
    height: 45px;
    background: var(--primary-gradient);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: var(--shadow-md);
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 700;
    color: #1e293b;
    font-size: 1rem;
}

.user-role-badge {
    font-size: 0.75rem;
    background: #e0f2fe;
    color: #0369a1;
    padding: 2px 8px;
    border-radius: 12px;
    width: fit-content;
    margin-top: 2px;
}

.logout-btn-modern {
    background: #fee2e2;
    color: #991b1b;
    border: none;
    padding: 8px 16px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.logout-btn-modern:hover {
    background: #fecaca;
    transform: translateY(-1px);
}

/* Dashboard Grid (Permissions Bar) */
#permissions-bar {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, 140px);
    justify-content: center;
    gap: 20px;
    padding: 20px;
    margin-bottom: 2rem;
}

.dashboard-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 1.5rem;
    text-align: center;
    text-decoration: none;
    color: #475569;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-sm);
}

/* End of Modern Styles */

.dashboard-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
    border-color: #3b82f6;
    color: #3b82f6;
}

.dashboard-card i {
    font-size: 1.8rem;
    margin-bottom: 5px;
    color: inherit;
}

.dashboard-card span {
    font-weight: 600;
    font-size: 0.9rem;
}


/* End of Modern Styles */

.permissions-bar.hidden {
    display: none;
}

.perm-link {
    color: white;
    text-decoration: none;
    font-size: 0.9rem;
    padding: 5px 12px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.perm-link:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
}

.perm-link i {
    font-size: 1rem;
}

/* Dashboard Cards (Main Menu Buttons) - Square Style */
.dashboard-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    background: white;
    padding: 15px;
    border-radius: 12px;
    text-decoration: none;
    color: var(--primary-color);
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);

    /* Square Shape Requirement */
    width: 100%;
    aspect-ratio: 1 / 1;
    border: 1.5px dotted rgba(211, 84, 0, 0.5) !important;
    /* Smaller Dark Orange Dotted Border with 50% opacity */
}

.dashboard-card i {
    font-size: 2.2rem;
    color: #d35400;
    /* Dark Orange Icons */
    margin-bottom: 8px;
}

.dashboard-card span {
    font-weight: bold;
    font-size: 1rem;
    color: #333;
}

.dashboard-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px rgba(211, 84, 0, 0.15);
    background: #fffdfa;
    border-color: #e67e22 !important;
}


#permissions-bar.hidden {
    display: none !important;
}

/* Notification Badge */
.notification-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #e74c3c;
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
    min-width: 22px;
    height: 22px;
    padding: 0 4px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    border: 2px solid white;
    z-index: 10;
    animation: badge-pulse 2s infinite;
}

@keyframes badge-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.4);
    }

    70% {
        transform: scale(1.1);
        box-shadow: 0 0 0 10px rgba(231, 76, 60, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0);
    }
}

/* --- New Phase 2 Styles --- */

/* Unified Modern Refresh Button */
.refresh-dashboard-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    background: linear-gradient(135deg, #d35400, #e67e22);
    color: white !important;
    border: none;
    border-radius: 50px;
    font-weight: 700;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 15px rgba(211, 84, 0, 0.3);
    text-decoration: none;
    margin: 5px;
}

.refresh-dashboard-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(211, 84, 0, 0.4);
    filter: brightness(1.1);
}

.refresh-dashboard-btn i {
    font-size: 1.3rem;
    transition: transform 0.6s ease;
}

.refresh-dashboard-btn:active i {
    transform: rotate(360deg);
}

/* External Order Highlighting */
.external-order-customer {
    color: #8e44ad !important;
    /* Deep Purple */
    font-weight: 900 !important;
    text-shadow: 0 0 1px rgba(142, 68, 173, 0.2);
}

/* Restricted Editing & Locking */
.locked-field {
    background-color: #f1f3f5 !important;
    cursor: not-allowed !important;
    opacity: 0.65;
    pointer-events: none;
}

/* Fixed Mobile Media Queries (Moved to end to avoid override conflicts) */
@media (max-width: 768px) {
    #permissions-bar {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 10px !important;
        padding: 15px !important;
        /* Created margin from screen edges */
        margin-bottom: 1.5rem;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .dashboard-card {
        padding: 0.8rem 0.3rem !important;
        aspect-ratio: 1 / 1.1;
        /* Slightly taller for better label fitting */
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 5px !important;
        border-radius: 12px !important;
    }

    .dashboard-card i {
        font-size: 2.1rem !important;
        /* Restored large, clear size */
        margin-bottom: 3px !important;
    }

    .dashboard-card span {
        font-size: 0.75rem !important;
        /* Slightly larger text for readability */
        line-height: 1.2;
        text-align: center;
        word-break: break-word;
        font-weight: 700;
    }

    .refresh-dashboard-btn {
        padding: 12px 20px;
        font-size: 1.05rem;
        width: calc(100% - 30px);
        /* Match container padding */
        margin: 10px 15px !important;
        justify-content: center;
    }
}

/* Update Carton Badge Alignment */
.carton-badge {
    display: inline-flex !important;
    justify-content: center !important;
    align-items: center !important;
    text-align: center !important;
    height: 100%;
    /* Ensure full height if container is flex */
}

/* Force Customer Name to be Black */
.external-order-customer {
    color: #000000 !important;
    font-weight: 800 !important;
}

/* User Info Bar - Mobile Improvements */
@media (max-width: 768px) {
    .user-bar-content {
        flex-direction: row !important;
        /* Keep in row */
        gap: 10px !important;
        align-items: center !important;
        justify-content: space-between !important;
        /* Spread them apart */
        text-align: right !important;
        padding: 5px 15px !important;
    }

    .welcome-section {
        flex-direction: row-reverse;
        /* Avatar then Name */
        justify-content: flex-end;
        /* Align to right */
        width: auto;
        /* Allow it to shrink/grow as needed */
        margin-bottom: 0;
        flex: 1;
        /* Take available space */
    }

    .logout-btn-modern {
        width: auto;
        /* Fit content */
        justify-content: center;
        margin-top: 0;
        background: rgba(255, 0, 0, 0.1) !important;
        border: 1px solid rgba(255, 0, 0, 0.2) !important;
        color: #d32f2f !important;
        padding: 6px 12px;
        /* Standard padding */
    }

    .logout-btn-modern span {
        display: none;
        /* Hide text on mobile to save space if needed, or keep short */
    }

    .logout-btn-modern i {
        color: #d32f2f !important;
        margin: 0;
    }
}

/* 📱 Luxury Segmented Bottom Navigation (New Classes to bypass cache) */
.modern-nav-bar {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 380px;
    background: #f1f3f5;
    padding: 6px;
    border-radius: 100px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
    z-index: 5000;
    justify-content: space-between;
    align-items: center;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.nav-item-box {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #495057;
    font-size: 0.9rem;
    font-weight: 700;
    transition: all 0.3s ease;
    flex: 1;
    padding: 10px 15px;
    border-radius: 100px;
    gap: 8px;
    position: relative;
    z-index: 2;
}

.nav-divider {
    width: 1px;
    height: 25px;
    background: rgba(0, 0, 0, 0.1);
}

.nav-item-box i {
    font-size: 1.2rem;
}

.nav-item-box.active {
    background: #ffffff;
    color: #0054ab;
    /* Shared primary color */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.icon-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.badge-mini {
    position: absolute;
    top: -8px;
    right: -12px;
    background: #e74c3c;
    color: white;
    font-size: 0.65rem;
    font-weight: 800;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #ffffff;
}

@keyframes pulse-dot {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.5);
        opacity: 0.5;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@media (max-width: 768px) {
    .modern-nav-bar {
        display: flex;
    }

    body {
        padding-bottom: 110px;
    }

    .toast {
        bottom: 110px !important;
        top: auto !important;
    }
}