/**
 * Zoho CRM Enrichment - Frontend Styles
 */

/* ========================================
   Variables & Reset
   ======================================== */
.zoho-frontend {
    --zoho-primary: #3498db;
    --zoho-primary-dark: #2980b9;
    --zoho-success: #27ae60;
    --zoho-danger: #e74c3c;
    --zoho-warning: #f39c12;
    --zoho-gray-100: #f8f9fa;
    --zoho-gray-200: #e9ecef;
    --zoho-gray-300: #dee2e6;
    --zoho-gray-400: #ced4da;
    --zoho-gray-500: #adb5bd;
    --zoho-gray-600: #6c757d;
    --zoho-gray-700: #495057;
    --zoho-gray-800: #343a40;
    --zoho-gray-900: #212529;
    --zoho-border-radius: 8px;
    --zoho-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --zoho-shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
    --zoho-transition: all 0.2s ease;
    
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--zoho-gray-800);
}

.zoho-frontend *,
.zoho-frontend *::before,
.zoho-frontend *::after {
    box-sizing: border-box;
}

/* ========================================
   Login Required & Access Denied
   ======================================== */
.zoho-frontend-login-required,
.zoho-frontend-access-denied {
    padding: 60px 20px;
    text-align: center;
}

.zoho-login-box,
.zoho-access-box {
    max-width: 400px;
    margin: 0 auto;
    padding: 40px;
    background: #fff;
    border-radius: var(--zoho-border-radius);
    box-shadow: var(--zoho-shadow-lg);
}

.zoho-login-icon,
.zoho-access-icon {
    font-size: 48px;
    width: 80px;
    height: 80px;
    line-height: 80px;
    border-radius: 50%;
    margin: 0 auto 20px;
    display: block;
}

.zoho-login-icon {
    background: var(--zoho-gray-100);
    color: var(--zoho-primary);
}

.zoho-access-icon {
    background: #fdecea;
    color: var(--zoho-danger);
}

.zoho-login-box h3,
.zoho-access-box h3 {
    margin: 0 0 10px;
    font-size: 1.5rem;
    color: var(--zoho-gray-800);
}

.zoho-login-box p,
.zoho-access-box p {
    margin: 0 0 20px;
    color: var(--zoho-gray-600);
}

.zoho-access-hint {
    font-size: 0.875rem;
    color: var(--zoho-gray-500);
}

/* ========================================
   Buttons
   ======================================== */
.zoho-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    border: none;
    border-radius: var(--zoho-border-radius);
    cursor: pointer;
    transition: var(--zoho-transition);
}

.zoho-btn-primary {
    background: var(--zoho-primary);
    color: #fff;
}

.zoho-btn-primary:hover {
    background: var(--zoho-primary-dark);
    color: #fff;
}

.zoho-btn-secondary {
    background: var(--zoho-gray-200);
    color: var(--zoho-gray-700);
}

.zoho-btn-secondary:hover {
    background: var(--zoho-gray-300);
}

.zoho-btn-success {
    background: var(--zoho-success);
    color: #fff;
}

.zoho-btn-success:hover {
    background: #219a52;
}

.zoho-btn-small {
    padding: 6px 12px;
    font-size: 0.875rem;
}

.zoho-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.zoho-btn .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

/* ========================================
   Dashboard
   ======================================== */
.zoho-frontend-dashboard {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.zoho-dashboard-header {
    margin-bottom: 30px;
}

.zoho-dashboard-header h2 {
    margin: 0 0 10px;
    font-size: 1.75rem;
    color: var(--zoho-gray-800);
}

.zoho-dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.zoho-dashboard-card {
    background: #fff;
    border-radius: var(--zoho-border-radius);
    box-shadow: var(--zoho-shadow);
    padding: 24px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: var(--zoho-transition);
}

.zoho-dashboard-card:hover {
    box-shadow: var(--zoho-shadow-lg);
    transform: translateY(-2px);
}

.zoho-card-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.zoho-card-icon .dashicons {
    font-size: 28px;
    width: 28px;
    height: 28px;
    color: #fff;
}

.zoho-card-icon.accounts {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.zoho-card-icon.prospects {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.zoho-card-content h3 {
    margin: 0 0 8px;
    font-size: 1.125rem;
    color: var(--zoho-gray-800);
}

.zoho-card-content p {
    margin: 0 0 16px;
    color: var(--zoho-gray-600);
    font-size: 0.9375rem;
}

/* ========================================
   Search Box
   ======================================== */
.zoho-search-section {
    background: #fff;
    border-radius: var(--zoho-border-radius);
    box-shadow: var(--zoho-shadow);
    padding: 24px;
    margin-bottom: 30px;
}

.zoho-search-section h3 {
    margin: 0 0 16px;
    font-size: 1.125rem;
    color: var(--zoho-gray-800);
}

.zoho-search-form {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.zoho-search-form select,
.zoho-search-form input[type="text"] {
    padding: 10px 14px;
    font-size: 1rem;
    border: 1px solid var(--zoho-gray-300);
    border-radius: var(--zoho-border-radius);
    transition: var(--zoho-transition);
}

.zoho-search-form input[type="text"] {
    flex: 1;
    min-width: 200px;
}

.zoho-search-form select:focus,
.zoho-search-form input[type="text"]:focus {
    outline: none;
    border-color: var(--zoho-primary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

.zoho-search-results {
    margin-top: 20px;
}

.zoho-search-results-list {
    border: 1px solid var(--zoho-gray-200);
    border-radius: var(--zoho-border-radius);
    overflow: hidden;
}

.zoho-search-result-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: #fff;
    border-bottom: 1px solid var(--zoho-gray-200);
    text-decoration: none;
    color: inherit;
    transition: var(--zoho-transition);
}

.zoho-search-result-item:last-child {
    border-bottom: none;
}

.zoho-search-result-item:hover {
    background: var(--zoho-gray-100);
}

.zoho-search-result-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--zoho-primary) 0%, #764ba2 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.zoho-search-result-icon .dashicons {
    color: #fff;
    font-size: 20px;
    width: 20px;
    height: 20px;
}

.zoho-search-result-content {
    flex: 1;
    min-width: 0;
}

.zoho-search-result-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--zoho-gray-800);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.zoho-search-result-subtitle {
    font-size: 0.875rem;
    color: var(--zoho-gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.zoho-search-result-arrow {
    color: var(--zoho-gray-400);
    flex-shrink: 0;
}

/* ========================================
   Data List / Table
   ======================================== */
.zoho-frontend-list {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.zoho-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
}

.zoho-list-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--zoho-gray-800);
}

.zoho-list-toolbar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.zoho-list-search {
    display: flex;
    gap: 8px;
}

.zoho-list-search input {
    padding: 8px 14px;
    font-size: 0.9375rem;
    border: 1px solid var(--zoho-gray-300);
    border-radius: var(--zoho-border-radius);
    min-width: 220px;
}

.zoho-list-search input:focus {
    outline: none;
    border-color: var(--zoho-primary);
}

.zoho-list-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.zoho-list-actions select {
    padding: 8px 12px;
    font-size: 0.9375rem;
    border: 1px solid var(--zoho-gray-300);
    border-radius: var(--zoho-border-radius);
}

/* Table */
.zoho-data-table-wrapper {
    background: #fff;
    border-radius: var(--zoho-border-radius);
    box-shadow: var(--zoho-shadow);
    overflow: hidden;
}

.zoho-data-table {
    width: 100%;
    border-collapse: collapse;
}

.zoho-data-table th {
    background: var(--zoho-gray-100);
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--zoho-gray-700);
    border-bottom: 2px solid var(--zoho-gray-200);
    white-space: nowrap;
}

.zoho-data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--zoho-gray-200);
    font-size: 0.9375rem;
    color: var(--zoho-gray-700);
}

.zoho-data-table tr:last-child td {
    border-bottom: none;
}

.zoho-data-table tr:hover td {
    background: var(--zoho-gray-100);
}

.zoho-data-table a {
    color: var(--zoho-primary);
    text-decoration: none;
    font-weight: 500;
}

.zoho-data-table a:hover {
    text-decoration: underline;
}

.zoho-no-data {
    text-align: center;
    padding: 40px 20px !important;
    color: var(--zoho-gray-500);
}

/* Status Badge */
.zoho-status-badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: 20px;
    background: var(--zoho-gray-200);
    color: var(--zoho-gray-700);
}

/* Pagination */
.zoho-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: #fff;
    border-top: 1px solid var(--zoho-gray-200);
}

.zoho-pagination button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 0.9375rem;
    background: var(--zoho-gray-100);
    border: 1px solid var(--zoho-gray-300);
    border-radius: var(--zoho-border-radius);
    cursor: pointer;
    transition: var(--zoho-transition);
}

.zoho-pagination button:hover:not(:disabled) {
    background: var(--zoho-gray-200);
}

.zoho-pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.zoho-page-info {
    font-size: 0.9375rem;
    color: var(--zoho-gray-600);
}

/* Loader */
.zoho-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px 20px;
    color: var(--zoho-gray-600);
}

.zoho-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--zoho-gray-300);
    border-top-color: var(--zoho-primary);
    border-radius: 50%;
    animation: zoho-spin 0.8s linear infinite;
}

@keyframes zoho-spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   Edit Form
   ======================================== */
.zoho-frontend-form {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

.zoho-form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}

.zoho-form-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--zoho-gray-800);
    display: flex;
    align-items: center;
    gap: 12px;
}

.zoho-back-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--zoho-gray-100);
    border-radius: 50%;
    color: var(--zoho-gray-600);
    text-decoration: none;
    transition: var(--zoho-transition);
}

.zoho-back-link:hover {
    background: var(--zoho-gray-200);
    color: var(--zoho-gray-800);
}

.zoho-form-actions {
    display: flex;
    gap: 12px;
}

/* Form Sections */
.zoho-form-section {
    background: #fff;
    border-radius: var(--zoho-border-radius);
    box-shadow: var(--zoho-shadow);
    margin-bottom: 24px;
    overflow: hidden;
}

.zoho-section-header {
    padding: 16px 20px;
    background: var(--zoho-gray-100);
    border-bottom: 1px solid var(--zoho-gray-200);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.zoho-section-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--zoho-gray-700);
    display: flex;
    align-items: center;
    gap: 10px;
}

.zoho-section-toggle {
    color: var(--zoho-gray-500);
    transition: var(--zoho-transition);
}

.zoho-section-header.collapsed .zoho-section-toggle {
    transform: rotate(-90deg);
}

.zoho-section-body {
    padding: 20px;
}

/* Form Fields */
.zoho-field-row {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 16px;
    align-items: start;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--zoho-gray-100);
}

.zoho-field-row:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.zoho-field-label {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--zoho-gray-700);
    padding-top: 10px;
}

.zoho-field-label .required-indicator {
    color: var(--zoho-danger);
    margin-left: 4px;
}

.zoho-field-input-wrapper {
    width: 100%;
}

/* Input Styles */
.zoho-front-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 1rem;
    border: 1px solid var(--zoho-gray-300);
    border-radius: var(--zoho-border-radius);
    transition: var(--zoho-transition);
    background: #fff;
}

.zoho-front-input:focus {
    outline: none;
    border-color: var(--zoho-primary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

.zoho-front-input.readonly {
    background: var(--zoho-gray-100);
    color: var(--zoho-gray-600);
    cursor: not-allowed;
}

.zoho-front-input:disabled {
    background: var(--zoho-gray-100);
    color: var(--zoho-gray-500);
}

textarea.zoho-front-input {
    resize: vertical;
    min-height: 100px;
}

select.zoho-front-input {
    cursor: pointer;
}

/* Checkbox */
.zoho-checkbox-label {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.zoho-front-checkbox {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.zoho-checkbox-custom {
    width: 22px;
    height: 22px;
    background: #fff;
    border: 2px solid var(--zoho-gray-300);
    border-radius: 4px;
    transition: var(--zoho-transition);
    position: relative;
}

.zoho-front-checkbox:checked + .zoho-checkbox-custom {
    background: var(--zoho-primary);
    border-color: var(--zoho-primary);
}

.zoho-front-checkbox:checked + .zoho-checkbox-custom::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 6px;
    height: 12px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Lookup Field */
.zoho-front-lookup {
    display: flex;
    gap: 8px;
}

.zoho-front-lookup .zoho-front-input {
    flex: 1;
}

.zoho-lookup-search {
    flex-shrink: 0;
}

/* Validation Errors */
.zoho-field-invalid {
    border-color: var(--zoho-danger) !important;
    background-color: #fef2f2 !important;
}

.zoho-field-error {
    display: block;
    margin-top: 6px;
    font-size: 0.875rem;
    color: var(--zoho-danger);
}

/* ========================================
   Toast Notifications
   ======================================== */
.zoho-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 16px 20px;
    background: #fff;
    border-radius: var(--zoho-border-radius);
    box-shadow: var(--zoho-shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10000;
    transform: translateX(120%);
    transition: transform 0.3s ease;
    max-width: 400px;
}

.zoho-toast.show {
    transform: translateX(0);
}

.zoho-toast-success {
    border-left: 4px solid var(--zoho-success);
}

.zoho-toast-error {
    border-left: 4px solid var(--zoho-danger);
}

.zoho-toast-info {
    border-left: 4px solid var(--zoho-primary);
}

.zoho-toast-icon {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

.zoho-toast-success .zoho-toast-icon {
    color: var(--zoho-success);
}

.zoho-toast-error .zoho-toast-icon {
    color: var(--zoho-danger);
}

.zoho-toast-message {
    flex: 1;
    font-size: 0.9375rem;
    color: var(--zoho-gray-700);
}

/* ========================================
   Modal
   ======================================== */
.zoho-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.zoho-modal-content {
    background: #fff;
    border-radius: var(--zoho-border-radius);
    box-shadow: var(--zoho-shadow-lg);
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.zoho-modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--zoho-gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.zoho-modal-header h3 {
    margin: 0;
    font-size: 1.125rem;
}

.zoho-modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    font-size: 24px;
    color: var(--zoho-gray-500);
    cursor: pointer;
    border-radius: 50%;
    transition: var(--zoho-transition);
}

.zoho-modal-close:hover {
    background: var(--zoho-gray-100);
    color: var(--zoho-gray-700);
}

.zoho-modal-body {
    padding: 20px;
    overflow-y: auto;
}

.zoho-modal-search {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.zoho-modal-search input {
    flex: 1;
}

.zoho-lookup-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--zoho-gray-200);
    cursor: pointer;
    transition: var(--zoho-transition);
}

.zoho-lookup-item:hover {
    background: var(--zoho-gray-100);
}

.zoho-lookup-item:last-child {
    border-bottom: none;
}

/* ========================================
   Error Message
   ======================================== */
.zoho-frontend-error {
    padding: 20px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--zoho-border-radius);
    color: var(--zoho-danger);
    text-align: center;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
    .zoho-list-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .zoho-list-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .zoho-list-search {
        flex-direction: column;
    }
    
    .zoho-list-search input {
        min-width: auto;
        width: 100%;
    }
    
    .zoho-data-table-wrapper {
        overflow-x: auto;
    }
    
    .zoho-data-table {
        min-width: 600px;
    }
    
    .zoho-field-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .zoho-field-label {
        padding-top: 0;
    }
    
    .zoho-form-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .zoho-form-actions {
        width: 100%;
    }
    
    .zoho-form-actions .zoho-btn {
        flex: 1;
    }
    
    .zoho-search-form {
        flex-direction: column;
    }
    
    .zoho-search-form input[type="text"] {
        min-width: auto;
    }
    
    .zoho-dashboard-cards {
        grid-template-columns: 1fr;
    }
}

/* Résultats de recherche rapide */
.zoho-search-results-list {
    list-style: none;
    padding: 0;
    margin: 10px 0 0 0;
}

.zoho-search-result-item {
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
}

.zoho-search-result-item:last-child {
    border-bottom: none;
}

.zoho-search-result-item a {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #333;
}

.zoho-search-result-item a:hover {
    color: #1976D2;
}

.zoho-search-result-item .result-type {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    white-space: nowrap;
}

.zoho-search-result-item .result-type.type-account {
    background: #e3f2fd;
    color: #1565c0;
}

.zoho-search-result-item .result-type.type-lead {
    background: #fce4ec;
    color: #c2185b;
}

.zoho-search-result-item .result-name {
    font-weight: 500;
}

.zoho-search-result-item .result-subtitle {
    color: #666;
    font-size: 13px;
    margin-left: auto;
}
