/* Modern Color Scheme */
:root {
    --primary-green: #4CAF50;
    --primary-dark: #2E7D32;
    --primary-light: #f0fdf4;
    --accent-green: #66BB6A;
    --bg-gradient-start: #f0fdf4;
    --bg-gradient-end: #ffffff;
    --text-primary: #1a1a1a;
    --text-secondary: #666;
    --border-color: #e0e0e0;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.12);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    color: var(--text-primary);
}

h2 {
    color: #333;
}

table {
    border-collapse: collapse;
    width: 100%;
    margin-top: 20px;
    font-size: 12px; /* Reduced from default 16px */
}

.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 20px;
}

thead th {
    pointer-events: auto !important;
    cursor: pointer;
}

th, td {
    border: 1px solid #ccc;
    padding: 4px 6px; /* Reduced from 8px */
    text-align: left;
}

/* Status column specific styling */
td[data-field="halal status"],
th:nth-child(4) {
    text-align: center;
    width: 100px;
    max-width: 100px;
}

.thumb {
    width: 30px; /* Reduced from 40px */
    height: 30px; /* Reduced from 40px */
    object-fit: cover;
    cursor: pointer;
    border-radius: 5px;
}

.login-box {
    margin: auto;
    width: 500px;
    max-width: 90%;
    padding: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 0 5px #ccc;
}

.login-box input {
    width: 100%;
    padding: 12px;
    margin: 8px 0;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-sizing: border-box;
}

.login-box button {
    width: 100%;
    padding: 12px;
    margin-top: 10px;
    font-size: 16px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

.login-box button:hover {
    background-color: #45a049;
}

.login-box h2 {
    text-align: center;
    margin-bottom: 20px;
}

.login-box .error {
    color: #F44336;
    text-align: center;
    margin-top: 10px;
}

/* ===== MODERN BRANDING STYLES ===== */

/* Login Page Branding */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 450px;
}

.brand-header {
    text-align: center;
    margin-bottom: 30px;
}

.brand-icon {
    margin: 0 auto 15px;
    width: 50px;
    height: 50px;
}

.brand-title {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-green);
    margin: 10px 0;
    letter-spacing: -0.5px;
}

.brand-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 5px 0 0;
}

.login-form .form-group {
    margin-bottom: 15px;
}

.login-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--accent-green) 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow-sm);
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.login-btn:active {
    transform: translateY(0);
}

.alert-error, .alert-danger {
    background: #ffebee;
    color: #c62828;
    padding: 12px;
    border-radius: 6px;
    margin-top: 15px;
    text-align: center;
    font-size: 14px;
    border-left: 4px solid #c62828;
}

.alert-success {
    background: #e8f5e9;
    color: #2e7d32;
    padding: 12px;
    border-radius: 6px;
    margin-top: 15px;
    text-align: center;
    font-size: 14px;
    border-left: 4px solid #4CAF50;
}

/* Main Header (Index Page) */
.main-header {
    background: white;
    box-shadow: var(--shadow-sm);
    padding: 15px 0;
    margin-bottom: 20px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon-small {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.brand-info {
    display: flex;
    flex-direction: column;
}

.app-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-green);
    margin: 0;
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.user-welcome {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 2px 0 0;
}

.username {
    font-weight: 600;
    color: var(--text-primary);
}

.user-badge {
    display: inline-block;
    background: var(--primary-light);
    color: var(--primary-dark);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    margin-left: 5px;
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Info Icon and Popup Styles */
.info-icon-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 1000;
}

.info-button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1976D2 0%, #1565C0 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(25, 118, 210, 0.4);
    transition: all 0.3s;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(25, 118, 210, 0.4);
    }
    50% {
        box-shadow: 0 4px 20px rgba(25, 118, 210, 0.6);
    }
}

.info-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(25, 118, 210, 0.5);
}

.info-button:active {
    transform: scale(0.95);
}

.info-popup {
    position: absolute;
    top: 54px;
    right: 0;
    width: 320px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    padding: 20px;
    opacity: 1;
    transform: translateY(0);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.info-popup.hidden {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
}

.info-popup::before {
    content: '';
    position: absolute;
    top: -8px;
    right: 12px;
    width: 16px;
    height: 16px;
    background: white;
    transform: rotate(45deg);
    box-shadow: -2px -2px 4px rgba(0, 0, 0, 0.05);
}

.info-popup-content {
    position: relative;
    z-index: 1;
}

.info-popup-title {
    color: #1976D2;
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #E3F2FD;
}

.info-popup-text {
    color: #424242;
    font-size: 14px;
    line-height: 1.6;
    margin: 0 0 10px 0;
}

.info-popup-text:last-child {
    margin-bottom: 0;
}

.instagram-link {
    color: #C13584;
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    padding: 2px 6px;
    border-radius: 4px;
}

.instagram-link:hover {
    background: rgba(193, 53, 132, 0.1);
    transform: translateY(-1px);
}

.instagram-icon {
    width: 16px;
    height: 16px;
    vertical-align: middle;
}

/* Feedback Notification Styles */
.feedback-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 24px;
    background: #4CAF50;
    color: white;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    opacity: 0;
    transform: translateX(100px);
    transition: all 0.3s ease;
}

.feedback-notification.show {
    opacity: 1;
    transform: translateX(0);
}

.feedback-notification.error {
    background: #f44336;
}

.feedback-notification.success {
    background: #4CAF50;
}

.btn-logout,
.btn-danger {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-logout {
    background: var(--primary-green);
    color: white;
}

.btn-logout:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-danger {
    background: #f44336;
    color: white;
}

.btn-danger:hover {
    background: #d32f2f;
    transform: translateY(-1px);
}

.btn-analytics {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-analytics:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-back {
    background: #00a651;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-back:hover {
    background: #008a43;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 166, 81, 0.3);
}

.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Table Actions */
.table-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin: 20px 0 16px 0;
    padding: 12px 0;
    border-top: 1px solid var(--border-color);
}

.btn-delete-action {
    background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    box-shadow: 0 2px 8px rgba(244, 67, 54, 0.3);
}

.btn-delete-action:hover {
    background: linear-gradient(135deg, #d32f2f 0%, #b71c1c 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(244, 67, 54, 0.4);
}

.btn-delete-action:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(244, 67, 54, 0.3);
}

.btn-delete-action:disabled {
    background: #ccc;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* Halal Status Text Color Only */
.halal-status.halal {
    color: #2E7D32;
    font-weight: 600;
}

.halal-status.haram {
    color: #C62828;
    font-weight: 600;
}

.halal-status:not(.halal):not(.haram) {
    color: #E65100;
    font-weight: 600;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    padding-top: 60px;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.8);
}

.modal-content {
    margin: auto;
    display: block;
    width: 80%;
    max-width: 600px;
    border-radius: 10px;
}

.close {
    position: absolute;
    top: 30px;
    right: 50px;
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}

/* AUTOCOMPLETE HINTS */
.autocomplete-hints {
    position: absolute;
    top: 100%; /* directly below input */
    left: 0;
    width: 100%; /* match wrapper width */
    border: 1px solid #ccc;
    background: white;
    max-height: 150px;
    overflow-y: auto;
    z-index: 10;
    display: none;
    box-sizing: border-box;
}

.autocomplete-hint {
    padding: 5px;
    cursor: pointer;
    text-transform: uppercase;
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.autocomplete-kind {
    font-size: 10px;
    color: #888;
    text-transform: none;
    flex-shrink: 0;
}

.autocomplete-hint:hover {
    background-color: #eee;
}

/* INPUT FIELDS */
#searchBox {
    padding: 10px;
    font-size: 12px;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-sizing: border-box;
}

td[data-field="Brand"],
td[data-field="product"] {
    text-transform: uppercase;
}

/* INPUT WRAPPER + CLEAR BUTTON */
.input-wrapper {
    flex: 0 0 40%; /* adjust width for other inputs */
    position:relative;
}

.input-wrapper input {
    width: 100%;
    padding-right: 30px; /* space for clear icon */
}

.input-wrapper#brandWrapper {
    flex: 0 0 20%; /* ~1/3 of the row */
}

.input-wrapper#statusWrapper {
    flex: 0 0 7%;
}

.clear-btn {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    display: none;
}

.input-wrapper input:not(:placeholder-shown) + .clear-btn {
    display: inline;
}

/* FLEX ROW FOR INPUTS + BUTTONS */
.input-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

/* BUTTONS */
.button-wrapper {
    display: flex;
    flex-direction: row;
    gap: 10px;
    align-items: center;
}

.button-wrapper button {
    padding: 10px 20px;
    cursor: pointer;
    border-radius: 5px;
    border: 1px solid #ccc;
    background-color: #f0f0f0;
}

.button-wrapper button:hover {
    background-color: #ddd;
}

.bg-green-50 {
    --tw-bg-opacity: 1;
    background-color: rgb(240 253 244 / var(--tw-bg-opacity, 1));
}

/* MULTISELECT DROPDOWN STYLES */
.multiselect-container {
    position: relative;
    width: max-content;
}

.multiselect-header {
    display: block;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: white;
    border: 1px solid #ccc;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.multiselect-header:hover {
    border-color: #999;
    background-color: #f9f9f9;
}

.multiselect-header svg {
    transition: transform 0.2s;
}

.multiselect-header.open svg {
    transform: rotate(180deg);
}

.multiselect-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
}

.multiselect-dropdown.hidden {
    display: none;
}

.multiselect-option {
    display: inline-flex;
    align-items: left;
    padding: 10px;
    cursor: pointer;
    font-size: 10px;
    transition: background-color 0.2s;
}

.multiselect-option:hover {
    background-color: #f0f0f0;
}

.multiselect-option input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
}

/* PAGINATION STYLES */
#pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin: 30px 0;
    flex-wrap: wrap;
}

.pagination-btn {
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    background: white;
    color: var(--text-primary);
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 44px;
    box-shadow: var(--shadow-sm);
}

.pagination-btn:hover:not(:disabled) {
    background: var(--primary-light);
    border-color: var(--primary-green);
    color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-btn.active {
    background: var(--primary-green);
    color: white;
    border-color: var(--primary-green);
    font-weight: 600;
}

.pagination-prev,
.pagination-next {
    padding: 10px 20px;
    font-weight: 600;
}

.pagination-dots {
    color: var(--text-secondary);
    padding: 0 8px;
    font-weight: 600;
    user-select: none;
}

/* MOBILE RESPONSIVE STYLES */
@media screen and (max-width: 768px) {
    body {
        margin: 0;
        padding: 0;
    }

    /* Info Icon and Popup responsive styles */
    .info-icon-container {
        top: 70px;
        right: 15px;
    }

    .info-button {
        width: 40px;
        height: 40px;
    }

    .info-popup {
        width: 280px;
        padding: 16px;
    }

    .info-popup-title {
        font-size: 15px;
    }

    .info-popup-text {
        font-size: 13px;
    }

    /* Login page styles */
    .login-page {
        padding: 10px;
    }

    .login-box {
        width: 100%;
        max-width: 100%;
        padding: 20px 15px;
        margin: 0;
    }

    .brand-title {
        font-size: 28px;
    }

    .brand-subtitle {
        font-size: 13px;
    }

    .login-box input {
        padding: 14px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .login-box button {
        padding: 14px;
        font-size: 18px;
    }

    .login-box h2 {
        font-size: 24px;
    }

    /* Index page - Stack search inputs vertically */
    .input-row {
        flex-direction: column;
        gap: 15px;
    }

    .input-wrapper {
        flex: 1 1 100% !important;
        width: 100%;
    }

    .button-wrapper {
        width: 100%;
        flex-direction: column;
    }

    .button-wrapper button {
        width: 100%;
        padding: 14px;
        font-size: 16px;
    }

    /* Touch-friendly inputs */
    #searchBox {
        padding: 14px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Table mobile improvements */
    table {
        font-size: 14px;
    }

    th, td {
        padding: 8px 6px;
        min-width: 100px;
    }

    .thumb {
        width: 40px;
        height: 40px;
    }

    /* Pagination */
    #pagination {
        gap: 6px;
        margin: 20px 0;
    }

    .pagination-btn {
        padding: 12px 14px;
        font-size: 14px;
        min-width: 44px;
        min-height: 44px;
    }

    .pagination-prev,
    .pagination-next {
        padding: 12px 16px;
    }

    /* Table actions - mobile */
    .table-actions {
        margin: 15px 0 12px 0;
    }

    .btn-delete-action {
        width: 100%;
        justify-content: center;
        font-size: 16px;
        padding: 14px 20px;
    }

    /* Admin form */
    #addProductForm input,
    #addProductForm select,
    #addProductForm button {
        width: 100%;
        padding: 14px;
        font-size: 16px;
        margin: 10px 0;
        box-sizing: border-box;
    }

    #addProductForm label {
        display: block;
        margin-top: 10px;
        font-weight: bold;
    }

    /* Header improvements */
    h2 {
        font-size: 20px;
    }

    h3 {
        font-size: 18px;
    }

    /* Main header mobile */
    .header-content {
        flex-direction: column;
        gap: 15px;
        padding: 0 10px;
    }

    .brand-section {
        width: 100%;
        justify-content: center;
    }

    .app-title {
        font-size: 20px;
    }

    .user-welcome {
        font-size: 12px;
        text-align: center;
    }

    .header-actions {
        width: 100%;
        flex-direction: row;
        justify-content: center;
    }

    .btn-logout,
    .btn-danger {
        padding: 10px 16px;
        font-size: 13px;
    }

    .main-content {
        padding: 15px 10px;
    }
}

@media screen and (max-width: 480px) {
    body {
        margin: 5px;
    }

    .login-box {
        padding: 15px 10px;
    }

    .login-box input,
    .login-box button {
        padding: 16px;
    }

    /* Even smaller screens */
    table {
        font-size: 13px;
    }

    th, td {
        padding: 6px 4px;
        min-width: 80px;
    }

    h2 {
        font-size: 18px;
    }
}