* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    flex: 1;
}

.header {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 30px;
}

.header h1 {
    color: #667eea;
    font-size: 2.5em;
    margin-bottom: 10px;
}

/* Base footer styles stay here */
.footer {
    background: white;
    padding: 25px 30px;
    border-radius: 15px;
    box-shadow: 0 -5px 30px rgba(0, 0, 0, 0.2);
    margin-top: 30px;
    text-align: center;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
}

.footer p {
    color: #4a5568;
    margin-bottom: 10px;
}

.footer a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s;
}

.footer a:hover {
    color: #764ba2;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.footer-divider {
    height: 1px;
    background: linear-gradient(to right, transparent, #e2e8f0, transparent);
    margin: 15px 0;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    text-decoration: none;
    display: inline-block;
    transition: all 0.3s;
    font-weight: 600;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-success {
    background: #48bb78;
    color: white;
}

.btn-success:hover {
    background: #38a169;
    transform: translateY(-2px);
}

.btn-danger {
    background: #f56565;
    color: white;
}

.btn-danger:hover {
    background: #e53e3e;
}

.btn-secondary {
    background: #718096;
    color: white;
}

.btn-secondary:hover {
    background: #4a5568;
}

.content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.messages {
    margin-bottom: 20px;
}

.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-weight: 500;
}

.alert-success {
    background: #c6f6d5;
    color: #22543d;
    border-left: 4px solid #48bb78;
}

.alert-error {
    background: #fed7d7;
    color: #742a2a;
    border-left: 4px solid #f56565;
}

.form-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 16px;
    transition: border 0.3s;
    font-family: inherit;
}

.form-input:focus {
    outline: none;
    border-color: #667eea;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #2d3748;
    font-weight: 600;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    font-size: 15px;
}

th,
td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

th {
    background: #f7fafc;
    color: #2d3748;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 13px;
}

tr:hover {
    background: #f7fafc;
}

td {
    vertical-align: middle;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.stat-card h3 {
    font-size: 2em;
    margin-bottom: 5px;
}

.stat-card p {
    opacity: 0.9;
    font-size: 14px;
}

.actions {
    display: flex;
    gap: 10px;
}

.btn-small {
    padding: 8px 16px;
    font-size: 14px;
}

.page-title {
    color: #2d3748;
    margin-bottom: 25px;
}

.section-title {
    color: #2d3748;
    margin-top: 30px;
    margin-bottom: 15px;
}

.warning-box {
    background: #fed7d7;
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid #f56565;
    margin-bottom: 25px;
}

.warning-box p {
    color: #742a2a;
    font-weight: 600;
}

.info-box {
    background: #f7fafc;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 25px;
}

.info-box p {
    margin-bottom: 8px;
}

.info-box strong {
    color: #2d3748;
}

.button-group {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

.empty-state {
    text-align: center;
    color: #718096;
    padding: 40px;
}

.error-message {
    color: #f56565;
    margin-top: 5px;
    font-size: 14px;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 30px;
    border: none;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-content h3 {
    color: #2d3748;
    margin-bottom: 20px;
    font-size: 1.5em;
}

.close-modal,
.close-supplier-modal,
.close-category-modal {
    color: #a0aec0;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
    transition: color 0.3s;
}

.close-modal:hover,
.close-modal:focus,
.close-supplier-modal:hover,
.close-supplier-modal:focus,
.close-category-modal:hover,
.close-category-modal:focus {
    color: #2d3748;
}

.modal-errors {
    color: #f56565;
    background: #fed7d7;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 14px;
    display: none;
}

.modal-errors:not(:empty) {
    display: block;
}

#reader {
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #e2e8f0;
}

/* Info button style */
.btn-info {
    background: #4299e1;
    color: white;
    white-space: nowrap;
}

.btn-info:hover {
    background: #3182ce;
    transform: translateY(-2px);
}

/* Navigation & Dropdown Styling (Unified) */
.nav-menu-container {
    display: flex;
    gap: 15px;
    margin-top: 20px;
    flex-wrap: wrap;
    align-items: center;
}

#hamburger-btn {
    display: none !important;
    background-color: #667eea !important;
    color: white !important;
    border: none !important;
    padding: 10px 14px !important;
    border-radius: 8px !important;
    font-size: 24px !important;
    cursor: pointer !important;
    position: absolute !important;
    right: 30px !important;
    top: 25px !important;
    z-index: 1000 !important;
}

#hamburger-btn i,
#hamburger-btn span {
    color: white !important;
}

.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: white;
    min-width: 210px;
    box-shadow: 0px 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    border-radius: 10px;
    top: 100%;
    margin-top: 8px;
    border: 1px solid #edf2f7;
}

/* Create an invisible bridge to prevent dropdown from closing when moving mouse from button to menu */
.dropdown-content::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 0;
    right: 0;
    height: 8px;
    background: transparent;
}

.dropdown-content a {
    color: #4a5568 !important;
    padding: 12px 20px !important;
    text-decoration: none !important;
    display: block !important;
    font-size: 14px !important;
}

/* Desktop behaviors: Show on hover OR when .active class is present */
/* Only show direct child dropdown-content, not nested ones */
.dropdown:hover>.dropdown-content,
.dropdown.active>.dropdown-content {
    display: block !important;
}

/* Nested dropdown styles */
.dropdown-submenu {
    position: relative;
}

.dropdown-submenu>a::after {
    content: "\f0d7";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    float: right;
    margin-left: 10px;
}

.dropdown-submenu>.dropdown-content {
    display: none !important;
    top: 0;
    left: 100%;
    margin-top: 0;
    margin-left: -1px;
}

.dropdown-submenu:hover>.dropdown-content {
    display: block !important;
}

.dropdown-submenu>a:hover {
    background-color: #f3f4f6;
}

/* Mobile Responsiveness */
@media (max-width: 1024px) {
    .header {
        position: relative !important;
        padding-top: 60px !important;
    }

    #hamburger-btn {
        display: block !important;
    }

    /* Target by ID for higher specificity to override default flex */
    #nav-menu.nav-menu-container {
        display: none !important;
        width: 100% !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 5px !important;
        margin-top: 20px !important;
    }

    #nav-menu.nav-menu-container.active {
        display: flex !important;
    }

    .nav-menu-container .btn,
    .nav-menu-container .dropdown {
        width: 100% !important;
        margin-bottom: 5px !important;
    }

    .nav-menu-container .dropdown button {
        width: 100% !important;
        text-align: left !important;
        display: flex !important;
        justify-content: space-between;
        align-items: center;
    }

    /* Accordion logic: hide content by default on mobile */
    #nav-menu.nav-menu-container .dropdown .dropdown-content {
        position: static !important;
        width: 100% !important;
        box-shadow: none !important;
        background-color: #f8fafc !important;
        display: none !important;
        padding-left: 20px !important;
        border: none !important;
        margin: 0 !important;
    }

    /* Show only when the parent dropdown is active */
    #nav-menu.nav-menu-container .dropdown.active .dropdown-content {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        height: auto !important;
    }

    /* Visual feedback: Darken button when active on mobile */
    #nav-menu.nav-menu-container .dropdown.active>button {
        background-color: #2d3748 !important;
        border-bottom-left-radius: 0 !important;
        border-bottom-right-radius: 0 !important;
    }

    /* Rotate caret when active */
    #nav-menu.nav-menu-container .dropdown.active button .fa-caret-down {
        transform: rotate(180deg);
    }

    #nav-menu.nav-menu-container .dropdown button .fa-caret-down {
        transition: transform 0.3s ease;
    }

    /* Ensure desktop hover doesn't interfere */
    .dropdown:hover .dropdown-content {
        display: none !important;
    }
}

@media (max-width: 640px) {
    .header h1 {
        font-size: 1.4em !important;
    }

    #hamburger-btn {
        right: 15px !important;
        top: 15px !important;
    }
}

/* Sortable Table Headers */
.sortable-header {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease;
}

.sortable-header:hover {
    opacity: 0.8;
}

th .sortable-header {
    font-weight: 700;
    text-transform: uppercase;
    font-size: 13px;
}

@media (max-width: 640px) {
    .header h1 {
        font-size: 1.4em !important;
    }

    #hamburger-btn {
        right: 15px !important;
        top: 15px !important;
    }
}

/* Styles from home.html moved here */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4);
}

.modal-content {
    background-color: #fefefe;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 500px;
    border-radius: 8px;
}

.close-stock-scanner,
.close-cart-modal {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-stock-scanner:hover,
.close-stock-scanner:focus,
.close-cart-modal:hover,
.close-cart-modal:focus {
    color: black;
}

.stock-input {
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 4px;
    text-align: center;
}

#stock-reader {
    border-radius: 8px;
    overflow: hidden;
}

#scan-feedback.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

#scan-feedback.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.feedback-highlight {
    background-color: #d4edda;
    transition: background-color 0.3s ease;
}

/* Icon-only buttons */
.btn-icon {
    padding: 0 !important;
    font-size: 0.7rem !important;
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 4px !important;
    /* meaningful border radius */
}

/* Sortable table headers (overriding previous definitions if any) */
.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

#product-table th {
    text-transform: uppercase;
    font-weight: 700;
    font-size: 0.8rem;
    vertical-align: middle;
}

#product-table {
    table-layout: fixed !important;
    width: 100% !important;
}

#product-table td {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    vertical-align: middle;
}

/* Enforce column widths for consistency */
#product-table th:nth-child(1) {
    width: 8%;
}

/* SKU */
#product-table th:nth-child(2) {
    width: 10%;
}

/* Brand */
#product-table th:nth-child(3) {
    width: 25%;
}

/* Name */
#product-table th:nth-child(8) {
    width: 14%;
}

/* Stock Control */
#product-table th:nth-child(9) {
    width: 12%;
}

/* Actions */

.sortable:hover {
    background-color: #f3f4f6;
}

.sortable i {
    margin-left: 5px;
    opacity: 0.5;
    font-size: 0.75rem;
}

.sortable.asc i::before {
    content: "\f0de";
}

.sortable.desc i::before {
    content: "\f0dd";
}

.sortable.asc i,
.sortable.desc i {
    opacity: 1;
}