/* --- Global Styles & Variables --- */
html {
    overflow-y: scroll;
}
:root {
    --primary-color: #6366F1; /* Indigo - Unified with Dashboard */
    --primary-hover: #5B21B6;
    --background-light: #F8F9FA; /* Light Gray */
    --surface-color: #FFFFFF;
    --text-primary: #1F2937; /* Dark Gray */
    --text-secondary: #6B7280; /* Medium Gray */
    --border-color: #E5E7EB; /* Subtle border, like #ddd */
    --green: #10B981;
    --yellow: #F59E0B;
    --red: #EF4444;

/* Dark Mode Variables -- Google AI Studio Style */
--dm-primary-color: #818CF8; /* A pleasant, readable blue like in the image */
--dm-primary-hover: #6366F1; /* A lighter version for hover */
--dm-background-light: #202124; /* The main page background (dark gray) */
--dm-surface-color: #2D3033; /* For containers, forms, headers */
--dm-text-primary: #E8EAED;   /* Primary text (soft off-white) */
--dm-text-secondary: #9AA0A6; /* Secondary text (dimmer gray) */
--dm-border-color: #3C4043;   /* Subtle borders */
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

button, input, select, textarea {
    transition: background-color 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s;
}

button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--background-light);
    margin: 0;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5; /* Increased line height */
}

/* --- Header --- */
.header {
    background-color: var(--surface-color);
    padding: 0 32px;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
}

.logo-link {
    display: flex;
    align-items: center;
    gap: 10px; /* Space between logo and text */
    text-decoration: none; /* Remove underline from link */
}
.logo-img {
    height: 36px;
}
.logo-text {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-color);
}
.logo-link:hover .logo-text {
    color: var(--primary-hover);
}
#user-info {
    display: flex;
    align-items: center;
    gap: 12px; /* This creates consistent spacing */
}

#user-name {
    font-weight: 500;
    color: var(--text-secondary);
}

#logout-button {
    background-color: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
    transition: background-color 0.2s, color 0.2s;
}

#logout-button:hover {
    background-color: var(--background-light);
    color: var(--text-primary);
}

/* --- Dark Mode Toggle --- */
#dark-mode-toggle {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    border-radius: 50%; /* Make it a circle */
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, border-color 0.2s, transform 0.2s;
}

#dark-mode-toggle:hover {
    background-color: var(--background-light);
    border-color: var(--primary-color);
    transform: scale(1.1) rotate(15deg);
}

/* --- Form Container & Elements --- */
.add-lead-container {
    max-width: 800px;
    margin: 48px auto; /* Adjusted margin */
    padding: 32px 40px;
    background-color: var(--surface-color);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
/* ===== START: NEW STYLES FOR FORM HEADER & MODAL ===== */

/* This container will hold the H2 and the "Bulk Import" button */
.form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
}

.form-header h2 {
    margin-bottom: 0; /* Remove margin from h2 as the container now handles it */
}

/* A new secondary button style */
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    height: 40px;
    background-color: var(--background-light);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background-color: #eef2ff;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

body.dark-mode .btn-secondary {
    background-color: var(--dm-background-light);
    color: var(--dm-text-primary);
    border-color: var(--dm-border-color);
}
body.dark-mode .btn-secondary:hover {
    background-color: var(--dm-surface-color);
    border-color: var(--dm-primary-color);
    color: var(--dm-primary-color);
}

/* Modal Overlay: The dark background */
#bulk-import-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(31, 41, 55, 0.6); /* Semi-transparent dark background */
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    /* Hide by default, control with .active class */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#bulk-import-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Position the modal content (the form container) */
#bulk-import-modal-overlay .add-lead-container {
    margin: 0; /* Override the auto margin */
    position: relative; /* Needed for the close button */
    transform: scale(0.95);
    transition: transform 0.3s ease;
    max-width: 600px; /* Smaller width for modal */
    width: 100%;
    max-height: 90vh; /* Limit height to viewport */
    overflow-y: auto; /* Allow scrolling if content is too tall */
    padding: 24px 28px; /* Reduced padding for modal */
}

#bulk-import-modal-overlay.active .add-lead-container {
    transform: scale(1);
}

/* Make status message scrollable if too long */
#bulk-import-modal-overlay #bulk-status-message {
    max-height: 400px;
    overflow-y: auto;
    word-wrap: break-word;
    padding: 12px;
    border-radius: 6px;
}

/* Reduce spacing in modal for more compact layout */
#bulk-import-modal-overlay .add-lead-container h2 {
    font-size: 22px;
    margin-bottom: 16px;
}

#bulk-import-modal-overlay .import-instructions {
    padding: 12px 16px;
    margin-bottom: 20px;
}

#bulk-import-modal-overlay .import-instructions h4 {
    font-size: 15px;
    margin-bottom: 12px;
}

#bulk-import-modal-overlay .instruction-grid {
    font-size: 12px;
    gap: 6px 12px;
}

#bulk-import-modal-overlay .form-group {
    margin-bottom: 20px;
}

/* Modal Close Button (the "X") */
.modal-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: transparent;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close-btn:hover {
    background-color: var(--background-light);
    color: var(--text-primary);
}

body.dark-mode .modal-close-btn {
    color: var(--dm-text-secondary);
}
body.dark-mode .modal-close-btn:hover {
    background-color: var(--dm-background-light);
    color: var(--dm-text-primary);
}
/* --- Styles for Bulk Import Instructions --- */
.import-instructions {
    background-color: var(--background-light);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 24px;
}
.import-instructions h4 {
    margin-top: 0;
    margin-bottom: 16px;
    font-size: 16px;
    color: var(--text-primary);
}
.instruction-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 16px;
    font-size: 13px;
    color: var(--text-secondary);
}
.instruction-grid span b {
    color: var(--text-primary);
    font-weight: 600;
}
.template-note {
    margin-top: 16px;
    margin-bottom: 0;
    font-size: 12px;
    color: var(--text-secondary);
    background-color: #f7f7f7;
    padding: 8px;
    border-radius: 4px;
    text-align: center;
}
body.dark-mode .import-instructions {
    background-color: var(--dm-background-light);
    border-color: var(--dm-border-color);
}
body.dark-mode .import-instructions h4,
body.dark-mode .instruction-grid span b {
    color: var(--dm-text-primary);
}
body.dark-mode .instruction-grid,
body.dark-mode .template-note {
    color: var(--dm-text-secondary);
}
body.dark-mode .template-note {
    background-color: var(--dm-surface-color);
}
/* ===== END: NEW STYLES FOR FORM HEADER & MODAL ===== */

.add-lead-container h2 {
    font-size: 26px;
    color: var(--primary-color);
    margin-bottom: 28px;
    text-align: center;
    font-weight: 700;
}

.form-group {
    margin-bottom: 24px; /* Increased spacing between form groups */
}

.form-group label {
    display: block;
    font-weight: 600; /* Bolder labels */
    margin-bottom: 8px; /* Spacing between label and input */
    font-size: 16px; /* Larger, mobile-friendly label */
    color: #374151; /* Darker label color */
}

/* Style asterisks in labels as red */
.form-group label .required-asterisk {
    color: var(--red);
    font-weight: bold;
}

body.dark-mode .form-group label .required-asterisk {
    color: var(--red);
}

/* Base styles for standard inputs, selects, and textareas */
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="tel"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group input[type="time"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px; /* Increased padding */
    border: 1px solid var(--border-color);
    border-radius: 8px; /* Consistent border radius */
    font-size: 16px; /* Larger input text */
    background-color: var(--background-light);
    color: var(--text-primary);
}

/* Specific height for single-line inputs for consistency */
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="tel"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group input[type="time"],
.form-group select {
    height: 52px; /* Increased height for better touch targets */
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color); /* Focus state with blue border */
    box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}
/* Hide number input spinners for a cleaner look */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

/* Enhanced File Input Styles */
.form-group input[type="file"] {
    width: 100%;
    min-height: 60px; /* Taller upload box */
    padding: 8px;
    border: 2px dashed var(--border-color); /* Dashed border */
    border-radius: 8px;
    background-color: var(--background-light);
    color: var(--text-secondary);
    font-size: 14px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}
.form-group input[type="file"]:hover {
    border-color: var(--primary-color);
    background-color: #f7f7ff;
}
.form-group input[type="file"]::-webkit-file-upload-button {
    padding: 8px 16px;
    margin-right: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--surface-color);
    color: var(--text-primary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}
.form-group input[type="file"]:hover::-webkit-file-upload-button {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    margin-bottom: 24px; /* Consistent margin */
}

.form-row .form-group {
    margin-bottom: 0; 
    flex-grow: 1;
    flex-shrink: 1;
    flex-basis: 0;
    min-width: 0;
}

/* Column Widths */
.col-100 { flex-basis: 100%; }
.col-60 { flex-basis: calc(60% - 12px); }
.col-50 { flex-basis: calc(50% - 12px); }
.col-40 { flex-basis: calc(40% - 12px); }
.col-33 { flex-basis: calc(33.333% - 16px); }

/* Make intl-tel-input take full height and match other inputs */
.iti { width: 100%; display: block; }
.iti .iti__input { height: 52px !important; }

/* --- Custom Multi-Select for Add Lead Form --- */
.custom-multiselect { position: relative; user-select: none; }
.custom-select-toggle { 
    border: 1px solid var(--border-color); 
    border-radius: 8px; 
    background: var(--background-light); 
    padding: 0 40px 0 16px;
    font-size: 16px; 
    font-weight: 500; 
    color: var(--text-primary); 
    transition: border-color 0.2s; 
    cursor: pointer; 
    text-align: left;
    height: 52px;
    line-height: 50px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.custom-select-toggle:after { 
    content: ""; 
    position: absolute; 
    right: 15px; 
    top: 50%; 
    width: 20px; /* Larger arrow */
    height: 20px; /* Larger arrow */
    transform: translateY(-50%); 
    pointer-events: none; 
    background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236B7280'%3e%3cpath fill-rule='evenodd' d='M5.22 8.22a.75.75 0 0 1 1.06 0L10 11.94l3.72-3.72a.75.75 0 1 1 1.06 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L5.22 9.28a.75.75 0 0 1 0-1.06Z' clip-rule='evenodd' /%3e%3c/svg%3e") no-repeat center;
}
.custom-select-toggle:hover { border-color: var(--primary-color); }
.custom-select-toggle.active { 
    background-color: #eef2ff; 
    border-color: var(--primary-color); 
    color: var(--primary-color); 
    font-weight: 600; 
}
.custom-select-options { 
    display: none; 
    position: absolute; 
    background: var(--surface-color); 
    border: 1px solid var(--border-color); 
    box-shadow: 0 8px 36px rgba(50,60,80,0.12); 
    border-radius: 10px; 
    margin-top: 4px; 
    width: 100%; 
    z-index: 22; 
    max-height: 220px; 
    overflow-y: auto; 
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}
.custom-option { 
    padding: 12px 18px; /* More padding in options */
    cursor: pointer; 
    font-size: 15px; 
    color: var(--text-primary); 
    transition: background 0.13s; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
}
.custom-option:hover { background: #eef2ff; color: var(--primary-color); }
.custom-option .checkmark { opacity: 0; color: var(--primary-color); }
.custom-option.selected .checkmark { opacity: 1; }
.custom-option.selected { font-weight: 600; background-color: #f3f4f6; }

/* --- Form Actions & Messages --- */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 16px; /* Increased gap */
    margin-top: 30px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.form-actions button {
    padding: 0 32px; /* Increased padding */
    height: 52px; /* Larger button height */
    border-radius: 8px;
    font-weight: 600; /* Semi-bold */
    font-size: 16px; /* Larger font size */
    cursor: pointer;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
/* Style for the new inline phone check button */
#check-phone-btn {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-color);
    background-color: #eef2ff;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    user-select: none; /* Prevents text selection on click */
}

#check-phone-btn:hover {
    background-color: #e0e7ff;
}

#check-phone-btn:active {
    transform: scale(0.95);
}

#check-phone-btn[disabled] {
    cursor: not-allowed;
    background-color: var(--border-color);
    color: var(--text-secondary);
}

/* Styles for the dedicated phone status message */
#phone-status-message {
    padding: 8px 12px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 13px;
    line-height: 1.4;
}

#phone-status-message.success { background-color: var(--green); color: white; }
#phone-status-message.error { background-color: var(--red); color: white; }
#phone-status-message.info { background-color: var(--yellow); color: var(--text-primary); }

.btn-submit { background-color: var(--primary-color); color: white; }
.btn-submit:hover { background-color: var(--primary-hover); }
.btn-submit:disabled { background-color: var(--text-secondary); cursor: not-allowed; }
.btn-back {
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
    font-weight: 600;
}
.btn-back:hover {
    background-color: var(--background-light);
    color: var(--text-primary);
    border-color: var(--border-color);
}

#status-message, #bulk-status-message {
    margin-top: 15px;
    padding: 10px;
    border-radius: 6px;
    font-weight: 500;
}
#status-message.success, #bulk-status-message.success { background-color: var(--green); color: white; }
#status-message.error, #bulk-status-message.error { background-color: var(--red); color: white; }
#status-message.info, #bulk-status-message.info { background-color: var(--yellow); color: var(--text-primary); }

#selected-files-preview { margin-top: 10px; font-size: 13px; color: var(--text-secondary); }
#selected-files-preview div { padding: 3px 0; }

body.dark-mode {
    color-scheme: dark;
    background-color: var(--dm-background-light);
    color: var(--dm-text-primary);
}
body.dark-mode .header { background-color: var(--dm-surface-color); border-color: var(--dm-border-color); }
body.dark-mode .logo-img {
    filter: brightness(1.1); /* Slightly brighten the logo image */
}
body.dark-mode .logo-text {
    color: var(--dm-primary-color);
}
body.dark-mode .logo-link:hover .logo-text {
    color: var(--dm-primary-hover);
}
body.dark-mode #user-name, body.dark-mode #logout-button { color: var(--dm-text-secondary); }
body.dark-mode #logout-button:hover { background-color: var(--dm-surface-color); color: var(--dm-text-primary); }
body.dark-mode #dark-mode-toggle { border-color: var(--dm-border-color); color: var(--dm-text-secondary); }
body.dark-mode #dark-mode-toggle:hover { background-color: var(--dm-surface-color); border-color: var(--dm-primary-color); }
body.dark-mode .add-lead-container { background-color: var(--dm-surface-color); border-color: var(--dm-border-color); }
body.dark-mode .add-lead-container h2 { color: var(--dm-primary-color); }
body.dark-mode .form-group label { color: var(--dm-text-primary); } /* Brighter label for contrast */
body.dark-mode .form-group input[type="text"],
body.dark-mode .form-group input[type="email"],
body.dark-mode .form-group input[type="tel"],
body.dark-mode .form-group input[type="number"],
body.dark-mode .form-group input[type="date"],
body.dark-mode .form-group input[type="time"],
body.dark-mode .form-group select,
body.dark-mode .form-group textarea {
    background-color: var(--dm-background-light);
    color: var(--dm-text-primary);
    border-color: var(--dm-border-color);
}
body.dark-mode .form-group input:focus,
body.dark-mode .form-group select:focus,
body.dark-mode .form-group textarea:focus {
    border-color: var(--dm-primary-color);
    box-shadow: 0 0 0 3px rgba(138, 180, 248, 0.25); /* Updated to match the new blue primary color */
}
body.dark-mode ::-webkit-input-placeholder { /* Chrome, Opera, Safari */
    color: var(--dm-text-secondary);
    opacity: 0.8;
}
body.dark-mode ::-moz-placeholder { /* Firefox 19+ */
    color: var(--dm-text-secondary);
    opacity: 0.8;
}
body.dark-mode :-ms-input-placeholder { /* IE 10+ */
    color: var(--dm-text-secondary);
    opacity: 0.8;
}
body.dark-mode ::-ms-input-placeholder { /* Edge */
    color: var(--dm-text-secondary);
    opacity: 0.8;
}
body.dark-mode ::placeholder { /* modern browsers */
    color: var(--dm-text-secondary);
    opacity: 0.8;
}
/* Dark Mode File Input */
body.dark-mode .form-group input[type="file"] { border-color: var(--dm-border-color); background-color: var(--dm-background-light); color: var(--dm-text-secondary); }
body.dark-mode .form-group input[type="file"]:hover { border-color: var(--dm-primary-color); background-color: var(--dm-surface-color); }
body.dark-mode .form-group input[type="file"]::-webkit-file-upload-button { background-color: var(--dm-surface-color); color: var(--dm-text-primary); border-color: var(--dm-border-color); }
body.dark-mode .form-group input[type="file"]:hover::-webkit-file-upload-button { background-color: var(--dm-primary-color); color: var(--dm-text-primary); border-color: var(--dm-primary-color); }

body.dark-mode .form-actions { border-top-color: var(--dm-border-color); }
body.dark-mode .btn-submit { background-color: var(--dm-primary-color); color: var(--dm-text-primary); }
body.dark-mode .btn-submit:hover { background-color: var(--dm-primary-hover); }
body.dark-mode .btn-submit:disabled { background-color: var(--dm-text-secondary); }
body.dark-mode .btn-back {
    background-color: transparent;
    color: var(--dm-text-secondary);
    border-color: transparent;
}
body.dark-mode .btn-back:hover {
    background-color: var(--dm-surface-color);
    color: var(--dm-text-primary);
    border-color: var(--dm-border-color);
}
body.dark-mode #status-message.info,
body.dark-mode #bulk-status-message.info { background-color: var(--dm-yellow); color: var(--dm-text-primary); }
/* Dark mode for the phone check button */
body.dark-mode #check-phone-btn {
    color: var(--dm-primary-color);
    background-color: var(--dm-surface-color);
}

body.dark-mode #check-phone-btn:hover {
    background-color: var(--dm-background-light);
}

body.dark-mode #check-phone-btn[disabled] {
    background-color: var(--dm-border-color);
    color: var(--dm-text-secondary);
}

/* Dark mode for the phone status message */
body.dark-mode #phone-status-message.info {
    background-color: #f59e0b;
    color: #1f2937;
}
body.dark-mode #selected-files-preview { color: var(--dm-text-secondary); }
/* Dark Mode for Custom Select */
body.dark-mode .custom-select-toggle { background: var(--dm-background-light); color: var(--dm-text-primary); border-color: var(--dm-border-color); }
body.dark-mode .custom-select-toggle:hover { border-color: var(--dm-primary-color); }
body.dark-mode .custom-select-toggle:after { background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23A0AEC0'%3e%3cpath fill-rule='evenodd' d='M5.22 8.22a.75.75 0 0 1 1.06 0L10 11.94l3.72-3.72a.75.75 0 1 1 1.06 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L5.22 9.28a.75.75 0 0 1 0-1.06Z' clip-rule='evenodd' /%3e%3c/svg%3e") no-repeat center; }
body.dark-mode .custom-select-toggle.active { background-color: #2c334f; border-color: var(--dm-primary-color); }
body.dark-mode .custom-select-options { background-color: var(--dm-surface-color); border-color: var(--dm-border-color); }
body.dark-mode .custom-option { color: var(--dm-text-primary); }
body.dark-mode .custom-option:hover { background: #2a2e3a; color: var(--dm-primary-color); }
body.dark-mode .custom-option.selected { background-color: var(--dm-background-light); }

/* --- Responsive Design --- */
@media (max-width: 768px) {
    /* Header mobile styles are handled in trustcrm-mobile-enhancements.css */

    .add-lead-container {
        margin: 0 auto 30px auto;
        padding: 24px 20px;
        border-radius: 0;
        border-left: none;
        border-right: none;
        box-shadow: none;
    }

    .form-row {
        flex-direction: column;
        gap: 24px; /* Consistent gap for mobile */
        margin-bottom: 0; 
    }

    /* Reset flex properties so columns take full width on mobile */
    .col-60, .col-50, .col-40, .col-33 {
        flex-basis: 100%;
    }

    .form-actions {
        flex-direction: column-reverse; /* Stack buttons, primary on top */
        gap: 16px;
    }

    .form-actions button {
        width: 100%;
    }

    /* Mobile dropdowns appear from bottom */
    .custom-multiselect .custom-select-options {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        border-radius: 20px 20px 0 0 !important;
        border-left: none !important;
        border-right: none !important;
        border-bottom: none !important;
        max-height: 60vh !important;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15) !important;
        animation: dropdownSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1000 !important;
    }

    @keyframes dropdownSlideUp {
        from {
            transform: translateY(100%);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }

    /* Mobile dropdown header */
    .mobile-dropdown-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px 20px;
        border-bottom: 1px solid var(--border-color);
        background-color: var(--surface-color);
        position: sticky;
        top: 0;
        z-index: 2;
        border-radius: 20px 20px 0 0;
    }

    .mobile-dropdown-header-title {
        font-size: 18px;
        font-weight: 600;
        color: var(--text-primary);
        flex: 1;
    }

    .mobile-dropdown-close-btn {
        background: transparent;
        border: none;
        padding: 8px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        transition: background-color 0.2s ease;
        color: var(--text-secondary);
        font-size: 24px;
        line-height: 1;
    }

    .mobile-dropdown-close-btn:hover,
    .mobile-dropdown-close-btn:active {
        background-color: var(--background-light);
        color: var(--text-primary);
    }

    /* Dark mode for mobile dropdown header */
    body.dark-mode .mobile-dropdown-header {
        background-color: var(--dm-surface-color);
        border-bottom-color: var(--dm-border-color);
    }

    /* Dark mode for search input on mobile */
    body.dark-mode .custom-select-search {
        background-color: var(--dm-surface-color) !important;
    }

    body.dark-mode .mobile-dropdown-header-title {
        color: var(--dm-text-primary);
    }

    body.dark-mode .mobile-dropdown-close-btn {
        color: var(--dm-text-secondary);
    }

    body.dark-mode .mobile-dropdown-close-btn:hover,
    body.dark-mode .mobile-dropdown-close-btn:active {
        background-color: var(--dm-background-light);
        color: var(--dm-text-primary);
    }

    /* Backdrop overlay for mobile dropdowns */
    .mobile-dropdown-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 999;
        animation: fadeIn 0.3s ease;
        display: none;
    }

    .mobile-dropdown-backdrop.active {
        display: block;
    }

    @keyframes fadeIn {
        from {
            opacity: 0;
        }
        to {
            opacity: 1;
        }
    }

    /* Position search input below mobile header when header is present */
    .custom-select-search {
        position: sticky !important;
        top: 73px !important; /* Header height: 16px padding + 40px button + 16px padding + 1px border */
        z-index: 1 !important;
        background-color: var(--surface-color) !important;
    }
}
/* --- Dark Mode for Intl Tel Input Dropdown --- */
body.dark-mode .iti__country-list {
    background-color: var(--dm-surface-color);
    border-color: var(--dm-border-color);
    box-shadow: 0 8px 36px rgba(0,0,0,0.3);
}

body.dark-mode .iti__country {
    color: var(--dm-text-primary);
}

body.dark-mode .iti__country:hover,
body.dark-mode .iti__active {
    background-color: var(--dm-background-light);
}

body.dark-mode .iti__dial-code {
    color: var(--dm-text-secondary);
}

body.dark-mode .iti__search-input {
    background-color: var(--dm-background-light) !important;
    color: var(--dm-text-primary) !important;
    border-color: var(--dm-border-color) !important;
}
/* --- START OF ADDITION: Dark Mode for Unit Form Sections --- */

body.dark-mode .add-lead-container h3 {
    color: var(--dm-primary-color);
    border-bottom-color: var(--dm-border-color);
}

body.dark-mode .form-group select[multiple] option {
    background-color: var(--dm-background-light);
    color: var(--dm-text-primary);
}

/* --- END OF ADDITION --- */
/* --- START OF ADDITION: Styles for Unit Form Sections --- */

/* Style the h3 headers to act as section dividers */
.add-lead-container h3 {
    font-size: 20px;
    color: var(--primary-color);
    margin-top: 40px;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
}

/* Style for multi-select boxes so they look consistent */
.form-group select[multiple] {
    height: auto; /* Let the browser determine the height */
    min-height: 150px; /* Give it a decent minimum height */
    padding: 12px; /* Add some internal padding */
}

.form-group select[multiple] option {
    padding: 8px 12px; /* Style the options inside */
}

/* --- END OF ADDITION --- */
.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
/* Radio Button Group Styling */
.radio-group {
    display: flex;
    gap: 16px;
    background-color: var(--background-light);
    border-radius: 8px;
    padding: 8px;
    border: 1px solid var(--border-color);
}
.radio-label {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
}
.radio-label input {
    display: none; /* Hide the default radio button */
}
.radio-label span {
    position: relative;
    padding-left: 28px;
}
.radio-label span::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    background-color: var(--surface-color);
}
.radio-label span::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 50%;
    transform: translateY(-50%) scale(0);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--primary-color);
    transition: transform 0.2s ease;
}
.radio-label input:checked + span::before {
    border-color: var(--primary-color);
}
.radio-label input:checked + span::after {
    transform: translateY(-50%) scale(1);
}
body.dark-mode .radio-group {
    background-color: var(--dm-background-light);
    border-color: var(--dm-border-color);
}
body.dark-mode .radio-label span::before {
    border-color: var(--dm-border-color);
    background-color: var(--dm-surface-color);
}
body.dark-mode .radio-label input:checked + span::before {
    border-color: var(--dm-primary-color);
}
body.dark-mode .radio-label input:checked + span::after {
    background-color: var(--dm-primary-color);
}@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}
/* Image Gallery Styles - Now handled by TrustCRM.Lightbox in trustcrm-shared.js */

/* Inventory Images in Details Modal */
.unit-images-preview {
    margin: 24px 0;
    padding: 20px;
    background: var(--background-light);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.unit-images-preview h4 {
    margin: 0 0 16px 0;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
}

.unit-images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
}

.unit-image-preview {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid var(--border-color);
    background: var(--surface-color);
}

.unit-image-preview:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-color: var(--primary-color);
}

.unit-image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s ease;
}

.unit-image-preview:hover img {
    transform: scale(1.05);
}

.unit-image-preview .image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.unit-image-preview:hover .image-overlay {
    opacity: 1;
}

.unit-image-preview .play-icon {
    color: white;
    font-size: 24px;
    font-weight: bold;
}

/* Dark Mode */
body.dark-mode .unit-images-preview {
    background: var(--dm-background-light);
    border-color: var(--dm-border-color);
}

body.dark-mode .unit-images-preview h4 {
    color: var(--dm-text-primary);
}

body.dark-mode .unit-image-preview {
    border-color: var(--dm-border-color);
    background: var(--dm-surface-color);
}

body.dark-mode .unit-image-preview:hover {
    border-color: var(--dm-primary-color);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .image-gallery-container {
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    .gallery-header {
        padding: 16px 20px;
    }

    .gallery-main-container {
        padding: 16px;
    }

    .gallery-nav-btn {
        width: 44px;
        height: 44px;
    }

    .gallery-prev {
        left: 12px;
    }

    .gallery-next {
        right: 12px;
    }

    .gallery-thumbnails-container {
        padding: 12px 20px;
    }

    .gallery-thumbnail {
        width: 60px;
        height: 60px;
    }

    .unit-images-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 8px;
    }
}
/* Image Upload Section Styles */
.image-upload-section {
    margin: 20px 0;
    padding: 20px;
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    background: var(--surface-color);
    transition: all 0.3s ease;
}

.image-upload-section.dragover {
    border-color: var(--primary-color);
    background: #eef2ff;
}

.upload-area {
    text-align: center;
    padding: 20px;
}

.upload-button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.upload-button:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
}

.upload-button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
}

.image-previews {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.image-preview {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface-color);
    border: 2px solid var(--border-color);
}

.preview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.remove-image {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--red);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
}

.compression-info {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 8px;
    text-align: center;
}

.upload-progress {
    margin-top: 12px;
    padding: 12px;
    background: #eef2ff;
    border-radius: 8px;
    display: none;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 8px;
    text-align: center;
}

/* ===================================
   START: MIXED LANGUAGE (RTL/LTR) FIX FOR FORMS
   =================================== */

/* Ensures textareas in forms handle mixed Arabic/English correctly */
.form-group textarea {
    unicode-bidi: plaintext;
}

/* --- END: MIXED LANGUAGE FIX FOR FORMS --- */
/* --- START: Button Loading Spinner --- */
.btn-submit.loading {
    cursor: not-allowed;
    position: relative;
    color: transparent !important; /* Hide the button text */
}

.btn-submit.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-top: -10px;
    margin-left: -10px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
/* --- END: Button Loading Spinner --- */
/* --- START OF EXISTING CODE --- */
.col-50 { flex-basis: calc(50% - 12px); }
.col-40 { flex-basis: calc(40% - 12px); }
.col-33 { flex-basis: calc(33.333% - 16px); }
/* --- END OF EXISTING CODE --- */

/* ===== START OF ADDITION ===== */
.col-25 { flex-basis: calc(25% - 18px); }
/* ===== END OF ADDITION ===== */

/* --- START OF EXISTING CODE --- */
/* Make intl-tel-input take full height and match other inputs */
.iti { width: 100%; display: block; }
/* --- END OF EXISTING CODE --- */
/* --- START: Custom Dropdown Search Bar --- */
.custom-select-search {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    position: sticky; /* This makes the search bar stick to the top */
    top: 0;
    background-color: var(--surface-color);
    z-index: 1; /* Ensures it stays above the scrolling options */
}

.search-input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 16px;
    outline: none;
    box-sizing: border-box; /* Ensures padding doesn't affect width */
}

.search-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

/* Dark Mode Styles */
body.dark-mode .custom-select-search {
    background-color: var(--dm-surface-color);
    border-bottom-color: var(--dm-border-color);
}

body.dark-mode .search-input {
    background-color: var(--dm-background-light);
    border-color: var(--dm-border-color);
    color: var(--dm-text-primary);
}

body.dark-mode .search-input:focus {
    border-color: var(--dm-primary-color);
    box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.1);
}
/* --- END: Custom Dropdown Search Bar --- */
/* --- START: Hidden Input for Validation --- */
.hidden-validation-input {
    position: absolute;
    opacity: 0;
    height: 0;
    width: 0;
    pointer-events: none; /* Makes it unclickable */
    margin: 0;
    padding: 0;
    border: none;
}
/* --- END: Hidden Input for Validation --- */
/* =================================================================== */
/* ========== START: PUBLIC FORM HEADER OPTIMIZATION ========== */
/* =================================================================== */

/* Target the header only on the public form page */
.public-form-page .header {
    justify-content: center;
    padding: 16px 0;
}

/* Make the logo link not clickable */
.public-form-page .logo-link {
    pointer-events: none;
}

/* Style the logo image itself */
.public-form-page .logo-img {
    height: 55px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Add a specific, better-looking shadow for dark mode */
body.dark-mode .public-form-page .logo-img {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

/* =============================================================== */
/* ========== END: PUBLIC FORM HEADER OPTIMIZATION ========== */
/* =============================================================== */
