/**
 * Customers Panel Stylesheet
 * Similar styling to Variations panel
 */

/* Prevent body scroll when popup is open */
body.popup-open {
    overflow: hidden;
}

#customersPopup {
    /* CSS Variables (scoped to popup) */
    --color-primary: #2d8998;
    --color-primary-dark: #246b78;
    --color-primary-light: #e3f2fd;
    --color-success: #4caf50;
    --color-error: #e74c3c;
    --color-warning: #f57f17;
    --color-info: #2196f3;
    --color-text-primary: #2c3e50;
    --color-text-secondary: #34495e;
    --color-text-muted: #7f8c8d;
    --color-text-disabled: #95a5a6;
    --bg-card: #ffffff;
    --bg-input: #f8f9fa;
    --bg-input-disabled: #ecf0f1;
    --bg-hover: #f0f7ff;
    --border-light: #e8ecef;
    --border-medium: #b0bec5;
    --border-focus: #36a4b5;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 6px 20px rgba(30, 136, 229, 0.4);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 10px;
    --radius-xl: 12px;

    /* Popup backdrop styles */
    display: none;
    position: fixed;
    z-index: 10001 !important;
    /* Above dropdowns (10000) and menu panel (500) */
    isolation: isolate;
    /* Create new stacking context */
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    overflow-y: auto;
    overflow-x: hidden;
    align-items: center;
    justify-content: center;
}

#customersPopup.show {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    /* Temporary: Add bright background to verify visibility */
    background: rgba(0, 0, 0, 0.35) !important;
}

#customersPopup .popup-content {
    width: min(100%, 1400px);
    margin: 2rem auto;
    padding: 0 1rem 2rem 1rem;
    max-height: calc(100vh - 4rem);
    position: relative;
    z-index: 1;
}

/* Form styling (scoped to popup only) */
#customersPopup .upload-form {
    border: 1px solid var(--color-border, #dddfe0);
    border-radius: 1.25rem;
    background-image: url("../../images/bg_noise.webp"), linear-gradient(180deg, var(--color-bg-gradient-top, #f8f8f7), var(--color-bg-gradient-bottom, #f1f0ee));
    background-position: 0 0, 0 0;
    background-size: auto, auto;
    padding: 2rem;
    box-shadow: var(--shadow-md);
}

#customersPopup .customers-container {
    width: 100%;
}

/* Table styling */
#customersPopup .table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    margin-bottom: 20px;
}

#customersPopup .data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
}

#customersPopup .data-table thead {
    background: var(--bg-input);
}

#customersPopup .data-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    color: var(--color-text-primary);
    border-bottom: 2px solid var(--border-light);
}

#customersPopup .data-table td {
    padding: 12px 16px;
    font-size: 11px;
    color: var(--color-text-secondary);
    border-bottom: 1px solid var(--border-light);
}

#customersPopup .data-table tbody tr:hover {
    background: var(--bg-hover);
}

#customersPopup .data-table tbody tr.customer-row {
    cursor: pointer;
}

/* Table footer */
#customersPopup .table-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

#customersPopup .table-actions {
    display: flex;
    gap: 12px;
}

#customersPopup .submit-btn {
    padding: 8px 20px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

#customersPopup .submit-btn.add-btn {
    background: var(--color-primary);
    color: white;
}

#customersPopup .submit-btn.add-btn:hover {
    background: var(--color-primary-dark);
    transform: none;
    box-shadow: none;
}

#customersPopup .table-footer-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Pagination */
#customersPopup .pagination {
    display: flex;
    gap: 4px;
    align-items: center;
}

#customersPopup .pagination-btn {
    padding: 6px 12px;
    border: 1px solid var(--border-medium);
    background: var(--bg-card);
    color: var(--color-text-primary);
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast, all 0.2s ease);
}

#customersPopup .pagination-btn:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--color-primary);
}

#customersPopup .pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#customersPopup .pagination-btn.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

#customersPopup .pagination-ellipsis {
    padding: 6px 8px;
    color: var(--color-text-muted);
}

#customersPopup .remove-btn {
    padding: 8px 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #ecf0f1;
    color: #555;
}

#customersPopup .remove-btn:hover {
    background: #bdc3c7;
    color: #555;
}

#customersPopup .trash-icon {
    width: 16px;
    height: 16px;
    filter: grayscale(100%);
    opacity: 0.8;
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}

/* Modal styling */
#customerEditModal {
    display: none;
    position: fixed;
    z-index: 10003 !important;
    /* Above Customers popup (10001) */
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
}

#customerEditModal.show {
    display: flex;
}

#customerEditModal .modal-content {
    background-image: url("../../images/bg_noise.webp"), linear-gradient(180deg, #f8f8f7, #f1f0ee);
    background-position: 0 0, 0 0;
    background-size: auto, auto;
    border-radius: 1.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    max-width: 90%;
    width: 700px;
    margin: 2rem auto;
    animation: modalSlideIn 0.3s ease-out;
    border: 1px solid #dddfe0;
    max-height: calc(100vh - 4rem);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#customerEditModal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem 1rem 2rem;
    border-bottom: none;
}

#customerEditModal .modal-header h2 {
    color: #2c3e50 !important;
    margin: 0;
    font-size: 22px;
    font-weight: 600;
}

#customerEditModal .modal-header .modal-btn-cancel {
    width: auto;
    padding: 8px 16px;
    background: white;
    color: #2c3e50;
    border: 1px solid #dddfe0;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

#customerEditModal .modal-header .modal-btn-cancel:hover {
    background: #f8f9fa;
    border-color: #b0bec5;
}

#customerEditModal .modal-body {
    padding: 0 2rem 2rem 2rem;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
}

#customerEditModal .modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    padding: 1rem 2rem 1.5rem 2rem;
    border-top: 1px solid var(--border-light);
}

#customerEditModal .modal-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

#customerEditModal .modal-btn-confirm {
    background: var(--color-primary);
    color: white;
}

#customerEditModal .modal-btn-confirm:hover {
    background: var(--color-primary-dark);
}

#customerEditModal .modal-btn-cancel {
    background: #ecf0f1;
    color: #555;
}

#customerEditModal .modal-btn-cancel:hover {
    background: #bdc3c7;
}

#customerEditModal .remove-btn {
    padding: 8px 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #ecf0f1;
    color: #555;
}

#customerEditModal .remove-btn:hover {
    background: #bdc3c7;
    color: #555;
}

/* Form groups */
#customerEditModal .form-group {
    margin-bottom: 20px;
}

#customerEditModal .form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 12px;
    color: var(--color-text-primary);
}

#customerEditModal .form-group .input-container {
    width: 100%;
    padding: 0;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    background: #ffffff;
    box-sizing: border-box;
}

#customerEditModal .form-group .input-container input[type="text"],
#customerEditModal .form-group .input-container input[type="number"],
#customerEditModal .form-group .input-container input[type="date"] {
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 12px;
    background: white;
    color: var(--color-text-primary);
    transition: var(--transition-fast, all 0.2s ease);
    box-sizing: border-box;
}

#customerEditModal .form-group .input-container:hover {
    border-color: #2d8998;
}

#customerEditModal .form-group .input-container:focus-within {
    border-color: transparent;
    box-shadow: var(--shadow-focus-glow);
}

#customerEditModal .form-group .input-container input[type="text"]:disabled {
    background: var(--bg-input-disabled);
    color: var(--color-text-disabled);
    cursor: not-allowed;
}

#customerEditModal .form-group .input-container input[type="number"]:disabled {
    background: var(--bg-input-disabled);
    color: var(--color-text-disabled);
    cursor: not-allowed;
}

#customerEditModal .form-group .input-container input[type="date"]:disabled {
    background: var(--bg-input-disabled);
    color: var(--color-text-disabled);
    cursor: not-allowed;
}

#customerEditModal .hint {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 4px;
    line-height: 1.4;
}

#customerEditModal .error-message {
    padding: 10px;
    background: #fee;
    border: 1px solid var(--color-error);
    border-radius: var(--radius-sm);
    color: var(--color-error);
    font-size: 12px;
}

#customerEditModal .remove-btn .trash-icon {
    width: 16px;
    height: 16px;
    filter: grayscale(100%);
    opacity: 0.8;
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}

/* Responsive */
@media (max-width: 768px) {
    #customersPopup .popup-content {
        width: 100%;
        padding: 0 0.5rem 1rem 0.5rem;
    }

    #customerEditModal .modal-content {
        width: 95%;
        margin: 1rem auto;
    }

    #customerEditModal .modal-header,
    #customerEditModal .modal-body,
    #customerEditModal .modal-footer {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* ==================== DARK MODE ==================== */
@media (prefers-color-scheme: dark) {
    #customersPopup {
        --color-text-primary: #e5e7eb;
        --color-text-secondary: #cbd5e1;
        --color-text-muted: #94a3b8;
        --color-text-disabled: #64748b;
        --bg-card: #0f1113;
        --bg-input: #111315;
        --bg-input-disabled: #0a0b0c;
        --bg-hover: #1a1d21;
        --border-light: rgba(255, 255, 255, 0.08);
        --border-medium: rgba(255, 255, 255, 0.14);
    }

    #customersPopup .upload-form {
        border-color: rgba(255, 255, 255, 0.12);
        background-image: none;
        background-color: #0f1113;
    }

    #customersPopup .table-wrapper {
        border-color: rgba(255, 255, 255, 0.08);
        background: #0f1113;
    }

    #customersPopup .data-table {
        background: #0f1113;
    }

    #customersPopup .data-table thead {
        background: #111214;
    }

    #customersPopup .data-table th {
        color: #e5e7eb;
        border-bottom-color: rgba(255, 255, 255, 0.08);
    }

    #customersPopup .data-table td {
        color: #cbd5e1;
        border-bottom-color: rgba(255, 255, 255, 0.08);
    }

    #customersPopup .data-table tbody tr:hover {
        background: #1a1d21;
    }

    #customersPopup .pagination-btn {
        background: #111315;
        color: #e5e7eb;
        border-color: rgba(255, 255, 255, 0.14);
    }

    #customersPopup .pagination-btn:hover:not(:disabled) {
        background: #1a1d21;
        border-color: #2d8998;
    }

    #customersPopup .pagination-btn.active {
        background: #2d8998;
        color: white;
        border-color: #2d8998;
    }

    #customersPopup .pagination-ellipsis {
        color: #94a3b8;
    }

    #customersPopup .remove-btn {
        background: #374151;
        color: #e5e7eb;
    }

    #customersPopup .remove-btn:hover {
        background: #4b5563;
        color: #f3f4f6;
    }

    /* Customer Edit Modal Dark Mode */
    #customerEditModal {
        background: rgba(0, 0, 0, 0.6);
    }

    #customerEditModal .modal-content {
        background-image: none;
        background-color: #1f2937;
        border-color: rgba(255, 255, 255, 0.12);
    }

    #customerEditModal .modal-header h2 {
        color: #f3f4f6 !important;
    }

    #customerEditModal .modal-header .modal-btn-cancel {
        background: #374151;
        color: #e5e7eb;
        border-color: #4b5563;
    }

    #customerEditModal .modal-header .modal-btn-cancel:hover {
        background: #4b5563;
        border-color: #6b7280;
    }

    #customerEditModal .modal-body {
        background: #1f2937;
    }

    #customerEditModal .modal-footer {
        border-top-color: #374151;
        background: #111827;
    }

    #customerEditModal .modal-btn-confirm {
        background: #2d8998;
        color: white;
    }

    #customerEditModal .modal-btn-confirm:hover {
        background: #246b78;
    }

    #customerEditModal .modal-btn-cancel {
        background: #374151;
        color: #e5e7eb;
    }

    #customerEditModal .modal-btn-cancel:hover {
        background: #4b5563;
    }

    #customerEditModal .remove-btn {
        background: #374151;
        color: #e5e7eb;
    }

    #customerEditModal .remove-btn:hover {
        background: #4b5563;
        color: #f3f4f6;
    }

    #customerEditModal .form-group label {
        color: #e5e7eb;
    }

    #customerEditModal .form-group .input-container {
        border-color: rgba(255, 255, 255, 0.14);
        background: #111315;
    }

    #customerEditModal .form-group .input-container:hover {
        border-color: #2d8998;
    }

    #customerEditModal .form-group .input-container:focus-within {
        border-color: transparent;
    }

    #customerEditModal .form-group .input-container input[type="text"],
    #customerEditModal .form-group .input-container input[type="number"],
    #customerEditModal .form-group .input-container input[type="date"] {
        background: transparent;
        color: #e5e7eb;
    }

    #customerEditModal .form-group .input-container input[type="text"]:disabled,
    #customerEditModal .form-group .input-container input[type="number"]:disabled,
    #customerEditModal .form-group .input-container input[type="date"]:disabled {
        background: #0a0b0c;
        color: #64748b;
    }

    #customerEditModal .hint {
        color: #94a3b8;
    }

    #customerEditModal .error-message {
        background: #450a0a;
        border-color: #dc2626;
        color: #fca5a5;
    }
}