/**
 * Zoho CRM Enrichment - Styles des formulaires Frontend
 * Design moderne et responsive
 */

/* ==========================================================================
   Variables CSS
   ========================================================================== */
:root {
    --zoho-primary: #1976D2;
    --zoho-primary-dark: #1565C0;
    --zoho-primary-light: #E3F2FD;
    --zoho-success: #43A047;
    --zoho-danger: #E53935;
    --zoho-warning: #FB8C00;
    --zoho-gray-50: #FAFAFA;
    --zoho-gray-100: #F5F5F5;
    --zoho-gray-200: #EEEEEE;
    --zoho-gray-300: #E0E0E0;
    --zoho-gray-400: #BDBDBD;
    --zoho-gray-500: #9E9E9E;
    --zoho-gray-600: #757575;
    --zoho-gray-700: #616161;
    --zoho-gray-800: #424242;
    --zoho-gray-900: #212121;
    --zoho-border-radius: 8px;
    --zoho-border-radius-sm: 4px;
    --zoho-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --zoho-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --zoho-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --zoho-shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --zoho-transition: all 0.2s ease;
}

/* ==========================================================================
   Card Container
   ========================================================================== */
.zoho-card {
    background: #ffffff;
    border-radius: var(--zoho-border-radius);
    box-shadow: var(--zoho-shadow);
    overflow: hidden;
    margin-bottom: 24px;
}

.zoho-card-header {
    background: linear-gradient(135deg, var(--zoho-primary) 0%, var(--zoho-primary-dark) 100%);
    color: #ffffff;
    padding: 20px 24px;
}

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

.zoho-page-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #ffffff;
}

.zoho-page-title .dashicons {
    font-size: 28px;
    width: 28px;
    height: 28px;
}

.zoho-card-body {
    padding: 24px;
}

.zoho-card-footer {
    background: var(--zoho-gray-50);
    border-top: 1px solid var(--zoho-gray-200);
    padding: 16px 24px;
}

/* ==========================================================================
   Form Sections
   ========================================================================== */
.zoho-form-section {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--zoho-gray-200);
}

.zoho-form-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.zoho-section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--zoho-gray-800);
    margin: 0 0 20px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--zoho-primary);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.zoho-section-title .dashicons {
    color: var(--zoho-primary);
    font-size: 20px;
    width: 20px;
    height: 20px;
}

/* ==========================================================================
   Form Grid System
   ========================================================================== */
.zoho-form-grid {
    display: grid;
    gap: 20px;
}

.zoho-grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.zoho-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.zoho-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.zoho-col-span-2 {
    grid-column: span 2;
}

.zoho-col-span-3 {
    grid-column: span 3;
}

.zoho-col-span-4 {
    grid-column: span 4;
}

/* Responsive */
@media (max-width: 992px) {
    .zoho-grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .zoho-grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .zoho-grid-2,
    .zoho-grid-3,
    .zoho-grid-4 {
        grid-template-columns: 1fr;
    }
    
    .zoho-col-span-2,
    .zoho-col-span-3,
    .zoho-col-span-4 {
        grid-column: span 1;
    }
    
    .zoho-header-content {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ==========================================================================
   Form Groups & Inputs
   ========================================================================== */
.zoho-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.zoho-form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--zoho-gray-700);
    display: flex;
    align-items: center;
    gap: 4px;
}

.zoho-required {
    color: var(--zoho-danger);
    font-weight: 600;
}

.zoho-form-control {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--zoho-gray-900);
    background-color: #ffffff;
    border: 1px solid var(--zoho-gray-300);
    border-radius: var(--zoho-border-radius-sm);
    transition: var(--zoho-transition);
    box-sizing: border-box;
}

.zoho-form-control:hover {
    border-color: var(--zoho-gray-400);
}

.zoho-form-control:focus {
    outline: none;
    border-color: var(--zoho-primary);
    box-shadow: 0 0 0 3px var(--zoho-primary-light);
}

.zoho-form-control:disabled,
.zoho-form-control[readonly] {
    background-color: var(--zoho-gray-100);
    cursor: not-allowed;
}

/* Select */
.zoho-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 10px center;
    background-repeat: no-repeat;
    background-size: 20px;
    padding-right: 40px;
    cursor: pointer;
}

/* Textarea */
.zoho-textarea {
    min-height: 80px;
    resize: vertical;
}

/* Input with suffix (€) */
.zoho-input-with-suffix {
    position: relative;
    display: flex;
    align-items: stretch;
}

.zoho-input-with-suffix .zoho-form-control {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    flex: 1;
}

.zoho-input-suffix {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    background: var(--zoho-gray-100);
    border: 1px solid var(--zoho-gray-300);
    border-left: none;
    border-radius: 0 var(--zoho-border-radius-sm) var(--zoho-border-radius-sm) 0;
    color: var(--zoho-gray-600);
    font-weight: 500;
}

/* Field help text */
.zoho-field-help {
    font-size: 0.8rem;
    color: var(--zoho-gray-500);
    margin: 4px 0 0 0;
}

/* ==========================================================================
   Lookup Field
   ========================================================================== */
.zoho-lookup-wrapper {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.zoho-lookup-wrapper .zoho-form-control {
    flex: 1;
}

.zoho-lookup-wrapper .zoho-btn-icon {
    flex-shrink: 0;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.zoho-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.5;
    text-decoration: none;
    border: none;
    border-radius: var(--zoho-border-radius-sm);
    cursor: pointer;
    transition: var(--zoho-transition);
    white-space: nowrap;
}

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

/* Primary Button */
.zoho-btn-primary {
    background: var(--zoho-primary);
    color: #ffffff;
}

.zoho-btn-primary:hover {
    background: var(--zoho-primary-dark);
    color: #ffffff;
    box-shadow: var(--zoho-shadow-md);
}

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

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

/* Outline Button */
.zoho-btn-outline {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.zoho-btn-outline:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

/* Icon Button */
.zoho-btn-icon {
    padding: 10px;
    background: var(--zoho-gray-100);
    color: var(--zoho-gray-600);
    border: 1px solid var(--zoho-gray-300);
}

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

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

/* Danger Button */
.zoho-btn-danger {
    background: var(--zoho-danger);
    color: #ffffff;
    border-color: var(--zoho-danger);
}

.zoho-btn-danger:hover {
    background: #C62828;
    color: #ffffff;
}

/* Button Sizes */
.zoho-btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

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

/* ==========================================================================
   Form Actions
   ========================================================================== */
.zoho-form-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* ==========================================================================
   Messages & Alerts
   ========================================================================== */
.zoho-alert {
    padding: 12px 16px;
    border-radius: var(--zoho-border-radius-sm);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.zoho-alert-success {
    background: #E8F5E9;
    color: #2E7D32;
    border: 1px solid #A5D6A7;
}

.zoho-alert-error {
    background: #FFEBEE;
    color: #C62828;
    border: 1px solid #EF9A9A;
}

.zoho-alert-warning {
    background: #FFF3E0;
    color: #EF6C00;
    border: 1px solid #FFCC80;
}

.zoho-alert-info {
    background: var(--zoho-primary-light);
    color: var(--zoho-primary-dark);
    border: 1px solid #90CAF9;
}

/* ==========================================================================
   Loading State
   ========================================================================== */
.zoho-loading {
    position: relative;
    pointer-events: none;
}

.zoho-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

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

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

/* ==========================================================================
   Legacy Compatibility - Old Classes
   ========================================================================== */
/* Mapping old classes to new styles */
.zoho-frontend-edit {
    max-width: 900px;
    margin: 0 auto;
}

.zoho-edit-header {
    display: none; /* Replaced by card header */
}

.zoho-form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.zoho-form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.zoho-form-field.zoho-field-full {
    grid-column: span 2;
}

.zoho-form-field.zoho-field-small {
    max-width: 120px;
}

.zoho-form-field label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--zoho-gray-700);
}

.zoho-front-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.95rem;
    border: 1px solid var(--zoho-gray-300);
    border-radius: var(--zoho-border-radius-sm);
    transition: var(--zoho-transition);
    box-sizing: border-box;
}

.zoho-front-input:focus {
    outline: none;
    border-color: var(--zoho-primary);
    box-shadow: 0 0 0 3px var(--zoho-primary-light);
}

/* Old button styles mapping */
.zoho-btn-primary .dashicons,
.zoho-btn-secondary .dashicons {
    margin-right: 4px;
}

/* Mobile responsive for old layout */
@media (max-width: 768px) {
    .zoho-form-row {
        grid-template-columns: 1fr;
    }
    
    .zoho-form-field.zoho-field-full,
    .zoho-form-field.zoho-field-small {
        grid-column: span 1;
        max-width: none;
    }
}

/* ==========================================================================
   Lookup Search Modal (if used)
   ========================================================================== */
.zoho-lookup-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: 9999;
    padding: 20px;
}

.zoho-lookup-modal-content {
    background: #ffffff;
    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-lookup-modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--zoho-gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.zoho-lookup-modal-header h4 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--zoho-gray-800);
}

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

.zoho-lookup-results {
    list-style: none;
    padding: 0;
    margin: 0;
}

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

.zoho-lookup-results li:hover {
    background: var(--zoho-primary-light);
}

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

/* ==========================================================================
   Print Styles
   ========================================================================== */
@media print {
    .zoho-card-header {
        background: var(--zoho-gray-800) !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    .zoho-btn {
        display: none !important;
    }
    
    .zoho-card-footer {
        display: none !important;
    }
}
