/* ========================================
   Shared Property Forms Styles
   PatriMapp Design System
   Uses --pm-* CSS variables from base.css
   ======================================== */

/* Form Elements */
.form-label {
    color: #495057;
    font-weight: 500;
    margin-bottom: var(--pm-space-2);
    font-size: 0.95rem;
}

.form-label .text-danger {
    color: var(--pm-danger);
    margin-left: var(--pm-space-1);
}

.form-label .text-info {
    color: var(--pm-primary);
    margin-left: var(--pm-space-1);
}

.form-control,
.form-select {
    border-radius: var(--pm-radius-md);
    border: 1px solid var(--pm-border-light);
    padding: var(--pm-space-3) var(--pm-space-4);
    font-size: 1rem;
    transition: all var(--pm-transition-base);
    background-color: var(--pm-surface-1);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--pm-primary);
    box-shadow: 0 0 0 0.25rem var(--pm-primary-light);
    background-color: var(--pm-surface-1);
    transform: scale(1.01);
}

.form-control:disabled,
.form-select:disabled {
    background-color: var(--pm-surface-2);
    border-color: var(--pm-surface-3);
    color: var(--pm-muted);
    cursor: not-allowed;
}

.form-text {
    font-size: 0.875rem;
    color: var(--pm-muted);
    margin-top: var(--pm-space-1);
}

/* Contact Sections */
.contact-section,
.tenant-section,
.management-section,
.extranet-section {
    padding: var(--pm-space-5);
    background: linear-gradient(135deg, var(--pm-surface-1), var(--pm-surface-2));
    border-radius: var(--pm-radius-xl);
    border-left: 4px solid var(--pm-primary);
    margin-bottom: var(--pm-space-5);
    transition: all var(--pm-transition-base);
}

.contact-section:hover,
.tenant-section:hover,
.management-section:hover {
    transform: translateY(-2px);
    box-shadow: var(--pm-shadow-md);
}

.contact-section h6,
.tenant-section h6,
.management-section h6,
.extranet-section h6 {
    color: var(--pm-primary);
    font-weight: 600;
    margin-bottom: var(--pm-space-4);
    display: flex;
    align-items: center;
    gap: var(--pm-space-2);
}

/* Summary Sections */
.financial-summary,
.rental-summary,
.expenses-summary,
.contacts-summary,
.tenant-summary {
    margin-top: var(--pm-space-6);
}

.financial-summary .alert,
.rental-summary .alert,
.expenses-summary .alert,
.contacts-summary .alert,
.tenant-summary .alert {
    border-radius: var(--pm-radius-xl);
    border: none;
    background: linear-gradient(135deg, var(--pm-primary-light), var(--pm-secondary-light));
    border-left: 4px solid var(--pm-primary);
    font-weight: 500;
}

/* DPE Alert */
.dpe-alert {
    margin-top: var(--pm-space-5);
}

.dpe-alert .alert {
    border-radius: var(--pm-radius-xl);
    border: none;
    font-weight: 500;
}

.dpe-alert .alert-warning {
    background: linear-gradient(135deg, var(--pm-secondary-light), rgba(255, 154, 118, 0.08));
    color: var(--pm-secondary-dark);
    border-left: 4px solid var(--pm-secondary);
}

.dpe-alert .alert-danger {
    background: linear-gradient(135deg, #f8d7da, #fab1a0);
    color: #721c24;
    border-left: 4px solid var(--pm-danger);
}

/* Charges and Insurance Sections */
.charges-section,
.insurance-section {
    padding: var(--pm-space-5);
    background: linear-gradient(135deg, var(--pm-surface-1), var(--pm-surface-2));
    border-radius: var(--pm-radius-xl);
    border-left: 4px solid var(--pm-secondary);
    margin-bottom: var(--pm-space-5);
}

.charges-section h6,
.insurance-section h6 {
    color: var(--pm-secondary);
    font-weight: 600;
    margin-bottom: var(--pm-space-4);
}

/* Form Validation */
.form-control.is-invalid,
.form-select.is-invalid {
    border-color: var(--pm-danger);
    box-shadow: 0 0 0 0.25rem var(--pm-danger-light);
}

.invalid-feedback {
    color: var(--pm-danger);
    font-size: 0.875rem;
    font-weight: 500;
    margin-top: var(--pm-space-1);
}

.form-control.is-valid,
.form-select.is-valid {
    border-color: var(--pm-secondary);
    box-shadow: 0 0 0 0.25rem var(--pm-secondary-light);
}

.valid-feedback {
    color: var(--pm-secondary);
    font-size: 0.875rem;
    margin-top: var(--pm-space-1);
}

/* Department Select */
.department-select {
    font-family: 'Courier New', monospace;
}

.department-select option {
    font-family: 'Courier New', monospace;
}

/* Address Autocomplete */
.pm-address-suggestions {
    position: absolute;
    top: calc(100% + 0.25rem);
    left: 0;
    right: 0;
    max-height: 260px;
    overflow-y: auto;
    background: var(--pm-surface-1);
    border: 1px solid var(--pm-border-light);
    border-radius: var(--pm-radius-md);
    box-shadow: var(--pm-shadow-md);
    z-index: 1080;
}

.pm-address-suggestions.is-loading::before {
    content: "Recherche d'adresses...";
    display: block;
    padding: var(--pm-space-2) var(--pm-space-3);
    font-size: 0.85rem;
    color: var(--pm-muted);
    border-bottom: 1px solid var(--pm-border-light);
}

.pm-address-suggestion-item {
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    padding: var(--pm-space-3);
    cursor: pointer;
    border-bottom: 1px solid var(--pm-border-light);
    transition: background-color var(--pm-transition-base);
}

.pm-address-suggestion-item:last-child {
    border-bottom: 0;
}

.pm-address-suggestion-item:hover,
.pm-address-suggestion-item:focus {
    background: var(--pm-primary-light);
    outline: none;
}

.pm-address-suggestion-title {
    color: var(--pm-primary-dark);
    font-weight: 600;
    font-size: 0.92rem;
}

.pm-address-suggestion-subtitle {
    color: var(--pm-muted);
    font-size: 0.8rem;
    margin-top: 2px;
}

/* Features Grid */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--pm-space-3);
    margin-top: var(--pm-space-4);
    padding: var(--pm-space-5);
    background: linear-gradient(135deg, var(--pm-surface-2), var(--pm-surface-3));
    border-radius: var(--pm-radius-xl);
    border-left: 4px solid var(--pm-primary);
}

.form-check {
    padding: var(--pm-space-2);
    border-radius: var(--pm-radius-md);
    transition: background-color var(--pm-transition-base);
    cursor: pointer;
}

.form-check:hover {
    background-color: var(--pm-primary-light);
}

.form-check-input:checked {
    background-color: var(--pm-primary);
    border-color: var(--pm-primary);
}

.form-check-label {
    font-size: 0.9rem;
    cursor: pointer;
    user-select: none;
}

/* Button Styles */
.btn {
    border-radius: var(--pm-radius-md);
    font-weight: 500;
    transition: all var(--pm-transition-base);
    border: none;
    padding: var(--pm-space-3) var(--pm-space-5);
}

.btn-primary {
    background: linear-gradient(135deg, var(--pm-primary), var(--pm-primary-dark));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 122, 184, 0.3);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--pm-secondary), var(--pm-secondary-dark));
    color: white;
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 154, 118, 0.3);
}

.btn-outline-secondary {
    color: var(--pm-muted);
    border: 2px solid var(--pm-muted);
    background: transparent;
}

.btn-outline-secondary:hover {
    background-color: var(--pm-muted);
    border-color: var(--pm-muted);
    color: white;
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, var(--pm-secondary), var(--pm-secondary-dark));
    color: white;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 154, 118, 0.3);
}

.btn-warning {
    background: linear-gradient(135deg, var(--pm-secondary), var(--pm-secondary-dark));
    color: white;
}

.btn-warning:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 154, 118, 0.3);
}

/* Loading State */
.btn.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn.loading::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 2px solid currentColor;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Alert Styles */
.alert {
    border-radius: var(--pm-radius-xl);
    border: none;
    padding: var(--pm-space-4) var(--pm-space-5);
    font-weight: 500;
}

.alert-info {
    background: linear-gradient(135deg, var(--pm-primary-light), rgba(139, 122, 184, 0.05));
    color: #495057;
    border-left: 4px solid var(--pm-primary);
}

.alert-success {
    background: linear-gradient(135deg, var(--pm-secondary-light), rgba(255, 154, 118, 0.05));
    color: var(--pm-secondary-dark);
    border-left: 4px solid var(--pm-secondary);
}

.alert-warning {
    background: linear-gradient(135deg, var(--pm-secondary-light), rgba(255, 154, 118, 0.08));
    color: var(--pm-secondary-dark);
    border-left: 4px solid var(--pm-secondary);
}

.alert-danger {
    background: linear-gradient(135deg, #f8d7da, #fab1a0);
    color: #721c24;
    border-left: 4px solid var(--pm-danger);
}

/* Calculation Displays */
.d-flex.justify-content-between {
    align-items: center;
    padding: var(--pm-space-1) 0;
}

.d-flex.justify-content-between:not(:last-child) {
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

/* Input Groups */
.input-group {
    position: relative;
}

.input-group .form-control {
    border-radius: var(--pm-radius-md) 0 0 var(--pm-radius-md);
}

.input-group-text {
    background: linear-gradient(135deg, var(--pm-surface-2), var(--pm-surface-3));
    border: 1px solid var(--pm-border-light);
    border-left: none;
    border-radius: 0 var(--pm-radius-md) var(--pm-radius-md) 0;
    color: #495057;
    font-weight: 500;
}

/* Conditional Display */
.conditional-field {
    transition: all var(--pm-transition-base);
    overflow: hidden;
}

.conditional-field.hidden {
    max-height: 0;
    opacity: 0;
    margin: 0;
    padding: 0;
}

.conditional-field.visible {
    max-height: 1000px;
    opacity: 1;
}

/* Form Steps Indicator */
.form-steps {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--pm-space-6);
    position: relative;
}

.form-steps::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--pm-surface-3);
    z-index: 1;
}

.form-step {
    background: var(--pm-surface-1);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    border: 2px solid var(--pm-surface-3);
    color: var(--pm-muted);
    position: relative;
    z-index: 2;
    transition: all var(--pm-transition-base);
}

.form-step.active {
    background: var(--pm-primary);
    border-color: var(--pm-primary);
    color: white;
    transform: scale(1.1);
}

.form-step.completed {
    background: var(--pm-secondary);
    border-color: var(--pm-secondary);
    color: white;
}

/* Contact Summary Displays */
.contact-summary-item {
    padding: var(--pm-space-2) 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.contact-summary-item:last-child {
    border-bottom: none;
}

.contact-summary-item .small {
    margin-left: var(--pm-space-4);
    opacity: 0.8;
}

/* Field Contextual Adaptation */
.field-disabled-by-type {
    opacity: 0.5;
    pointer-events: none;
    position: relative;
    transition: all var(--pm-transition-base);
}

.field-disabled-by-type::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(108, 117, 125, 0.1), rgba(173, 181, 189, 0.1));
    border-radius: var(--pm-radius-md);
    z-index: 1;
    pointer-events: none;
}

.field-disabled-by-type .form-control,
.field-disabled-by-type .form-select {
    background-color: var(--pm-surface-2) !important;
    border-color: var(--pm-surface-3) !important;
    color: var(--pm-muted) !important;
    cursor: not-allowed !important;
}

.field-disabled-by-type .form-label {
    color: var(--pm-muted) !important;
    opacity: 0.7;
}

.field-disabled-by-type .form-label::after {
    content: ' (Non applicable pour ce type de bien)';
    font-size: 0.75rem;
    font-style: italic;
    color: var(--pm-muted);
    font-weight: normal;
}

/* Section-level disabling */
.section-disabled-by-type {
    opacity: 0.4;
    position: relative;
    transition: all var(--pm-transition-base);
}

.section-disabled-by-type::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(108, 117, 125, 0.05) 10px,
        rgba(108, 117, 125, 0.05) 20px
    );
    border-radius: var(--pm-radius-xl);
    z-index: 1;
    pointer-events: none;
}

.section-disabled-by-type .contact-section h6::after,
.section-disabled-by-type .tenant-section h6::after,
.section-disabled-by-type .management-section h6::after {
    content: ' - Non applicable';
    font-size: 0.8rem;
    font-style: italic;
    color: var(--pm-muted);
    font-weight: normal;
}

.section-disabled-by-type * {
    pointer-events: none !important;
    cursor: not-allowed !important;
}

/* Property type specific styles */
.property-type-house .syndic-section,
.property-type-parking .syndic-section,
.property-type-commercial .syndic-section,
.property-type-land .syndic-section,
.property-type-cave .syndic-section {
    opacity: 0.4;
}

.property-type-parking .dpe-section,
.property-type-land .dpe-section,
.property-type-cave .dpe-section {
    opacity: 0.4;
}

.property-type-parking .rooms-section,
.property-type-land .rooms-section,
.property-type-cave .rooms-section {
    opacity: 0.4;
}

/* Contextual help tooltips */
.field-disabled-tooltip {
    position: relative;
    display: inline-block;
}

.field-disabled-tooltip .tooltip-text {
    visibility: hidden;
    width: 200px;
    background-color: rgba(0, 0, 0, 0.8);
    color: #fff;
    text-align: center;
    border-radius: var(--pm-radius-md);
    padding: 5px 8px;
    position: absolute;
    z-index: 1000;
    bottom: 125%;
    left: 50%;
    margin-left: -100px;
    font-size: 0.75rem;
    opacity: 0;
    transition: opacity var(--pm-transition-base);
}

.field-disabled-tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* Responsive Design */
@media (max-width: 768px) {
    .contact-section,
    .tenant-section,
    .management-section,
    .charges-section,
    .insurance-section {
        padding: var(--pm-space-4);
        margin-bottom: var(--pm-space-4);
    }

    .features-grid {
        grid-template-columns: 1fr;
        padding: var(--pm-space-4);
    }

    .form-control,
    .form-select {
        padding: 0.6rem 0.8rem;
        font-size: 0.95rem;
    }

    .btn {
        padding: 0.6rem 1.2rem;
        font-size: 0.9rem;
    }

    .contact-summary-item .small {
        margin-left: var(--pm-space-2);
        font-size: 0.75rem;
    }
}

@media (max-width: 576px) {
    .form-label {
        font-size: 0.9rem;
    }

    .form-text {
        font-size: 0.8rem;
    }

    .alert {
        padding: var(--pm-space-3) var(--pm-space-4);
        font-size: 0.9rem;
    }

    .contact-section h6,
    .tenant-section h6,
    .management-section h6,
    .charges-section h6,
    .insurance-section h6 {
        font-size: 0.95rem;
        margin-bottom: var(--pm-space-3);
    }

    .btn {
        width: 100%;
        margin-bottom: var(--pm-space-2);
    }

    .btn:last-child {
        margin-bottom: 0;
    }
}

/* Print Styles */
@media print {
    .contact-section,
    .tenant-section,
    .management-section,
    .charges-section,
    .insurance-section {
        break-inside: avoid;
        background: white !important;
        border: 1px solid #ccc;
        box-shadow: none;
    }

    .btn {
        display: none;
    }

    .alert {
        background: white !important;
        border: 1px solid #ccc;
        color: black !important;
    }

    .form-control,
    .form-select {
        border: 1px solid #ccc;
        background: white;
    }
}

/* Animation Classes */
.fade-in {
    animation: fadeIn var(--pm-transition-base) ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.slide-in {
    animation: slideIn var(--pm-transition-base) ease-in-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Accessibility */
.form-control:focus,
.form-select:focus,
.btn:focus {
    outline: 2px solid transparent;
    outline-offset: 2px;
}

.form-check-input:focus {
    box-shadow: 0 0 0 0.25rem rgba(139, 122, 184, 0.25);
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .form-control,
    .form-select {
        border: 2px solid;
    }

    .btn {
        border: 2px solid;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
