.crmEntityFormView {
    color: var(--hw-form-text, rgba(226, 232, 240, 0.96));
    max-width: 100%;
    margin: 0 auto;
    background-color: transparent;
    border: none;
}

/* Validation summary */
.crmEntityFormView .validation-summary.alert {
    border-radius: var(--hw-radius-lg, 12px);
    border: 1px solid var(--hw-border-medium, rgba(255, 255, 255, 0.18));
    background: rgba(2, 8, 24, 0.70);
    color: var(--hw-form-text, rgba(226, 232, 240, 0.96));
}

/* =============================================================================
   FORM LAYOUT
   ============================================================================= */

/* Two-column layout: main form + attachments/sidebar card */
.crmEntityFormView .entity-form {
    background: transparent;
    border: none;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 500px;
    gap: 18px;
    align-items: start;
}

.crmEntityFormView .cell {
    padding: 0;
}

/* Card surfaces for tabs and sections */
.crmEntityFormView .tab,
.crmEntityFormView .tr {
    background: var(--hw-card-bg, rgb(44, 53, 68));
    border-radius: var(--hw-radius-sm, .5rem);
    margin: 0;
}

.crmEntityFormView .tab {
    padding: 18px;
    grid-column: 1;
    order: 0;
}

.crmEntityFormView .tr {
    padding: 18px;
    grid-column: 2;
}

.crmEntityFormView .actions {
    grid-column: 1;
    padding: 15px 0 0 0;
    margin: 0;
    border-top: none;
}

/* Remove unused zero-cell columns */
.crmEntityFormView td.zero-cell {
    display: none;
}

/* Table section layout */
.crmEntityFormView table.section {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.crmEntityFormView table.section > tbody > tr > td {
    padding: 5px;
    vertical-align: top;
}

/* =============================================================================
   FORM LABELS
   ============================================================================= */

.crmEntityFormView .info .field-label {
    display: block;
    margin: 0 0 8px;
    font-family: var(--hw-font-family, 'Segoe UI', sans-serif);
    font-size: var(--hw-font-size-xs, 12px);
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--hw-form-muted, rgba(226, 232, 240, 0.68));
}

/* Required field indicator */
.crmEntityFormView .info.required .field-label::after {
    content: " *";
    color: var(--hw-accent-secondary, #00B0EB);
}

/* =============================================================================
   FORM CONTROLS
   ============================================================================= */

.crmEntityFormView .control .form-control,
.crmEntityFormView .control input[type="text"],
.crmEntityFormView .control input[type="email"],
.crmEntityFormView .control input[type="tel"],
.crmEntityFormView .control input[type="number"],
.crmEntityFormView .control input[type="password"],
.crmEntityFormView .control textarea,
.crmEntityFormView .control select {
    background: var(--hw-bg-deep, #020818) !important;
    border: 1px solid var(--hw-border-medium, rgba(148, 163, 184, 0.20)) !important;
    border-radius: var(--hw-radius-lg, 12px);
    color: var(--hw-form-text, rgba(226, 232, 240, 0.96)) !important;
    padding: 14px;
    height: auto;
    min-height: 52px;
    font-family: var(--hw-font-family, 'Segoe UI', sans-serif);
    font-size: var(--hw-font-size-base, 14px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.crmEntityFormView .control textarea {
    max-height: 180px;
    resize: vertical;
}

/* Focus states */
.crmEntityFormView .control .form-control:focus,
.crmEntityFormView .control input:focus,
.crmEntityFormView .control textarea:focus,
.crmEntityFormView .control select:focus {
    outline: none;
    border-color: rgba(0, 176, 235, 0.75) !important;
    box-shadow: var(--hw-focus-shadow, 0 0 0 4px rgba(0, 176, 235, 0.18));
}

/* Readonly fields */
.crmEntityFormView .control .form-control.readonly,
.crmEntityFormView .control input.readonly,
.crmEntityFormView .control textarea.readonly {
    background: var(--hw-form-readonly-bg, rgba(2, 8, 24, 0.60)) !important;
    color: var(--hw-form-readonly-text, rgba(226, 232, 240, 0.72)) !important;
    cursor: not-allowed;
    opacity: 0.85;
}

/* =============================================================================
   INPUT GROUPS (Lookups)
   ============================================================================= */

.crmEntityFormView .control .input-group {
    width: 100%;
    display: flex;
    align-items: stretch;
}

.crmEntityFormView .control .input-group > .form-control {
    flex: 1 1 auto;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    background: var(--hw-bg-deep, #020818) !important;
}

.crmEntityFormView .input-group-btn {
    display: flex;
}

.crmEntityFormView .input-group-btn .btn {
    min-height: 52px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
    border-left: 0 !important;
    background: var(--hw-bg-deep, #020818) !important;
    border: 1px solid var(--hw-border-medium, rgba(148, 163, 184, 0.20)) !important;
    color: var(--hw-form-muted, rgba(226, 232, 240, 0.68)) !important;
}

.crmEntityFormView .input-group-btn .btn:last-child {
    border-top-right-radius: var(--hw-radius-lg, 12px);
    border-bottom-right-radius: var(--hw-radius-lg, 12px);
}

.crmEntityFormView .input-group-btn .btn:hover {
    border-color: var(--hw-border-strong, rgba(148, 163, 184, 0.30)) !important;
    color: var(--hw-form-text, rgba(226, 232, 240, 0.96)) !important;
}

/* =============================================================================
   FORM BUTTONS
   ============================================================================= */

.crmEntityFormView .btn,
.crmEntityFormView input.btn {
    border-radius: var(--hw-radius-lg, 12px);
    padding: 12px 16px;
    font-family: var(--hw-font-family, 'Segoe UI', sans-serif);
    font-weight: 600;
}

/* Primary button */
.crmEntityFormView .btn.btn-primary,
.crmEntityFormView input.btn.btn-primary {
    background: var(--hw-accent-secondary, #00B0EB) !important;
    border-color: var(--hw-accent-secondary, #00B0EB) !important;
    color: #fff !important;
    border-radius: var(--hw-radius-sm, .5rem);
}

.crmEntityFormView .btn.btn-primary:hover,
.crmEntityFormView input.btn.btn-primary:hover {
    filter: brightness(0.96);
}

/* Secondary/default buttons */
.crmEntityFormView .btn.btn-default,
.crmEntityFormView .btn.btn-success,
.crmEntityFormView .btn.btn-danger {
    background: rgba(2, 8, 24, 0.35) !important;
    border: 1px solid var(--hw-border-medium, rgba(148, 163, 184, 0.20)) !important;
    color: var(--hw-form-text, rgba(226, 232, 240, 0.96)) !important;
}

.crmEntityFormView .btn.btn-default:hover,
.crmEntityFormView .btn.btn-success:hover,
.crmEntityFormView .btn.btn-danger:hover {
    border-color: var(--hw-border-strong, rgba(148, 163, 184, 0.30)) !important;
    background: rgba(2, 8, 24, 0.55) !important;
}

/* Cancel button specific styling */
button.cancel.btn.btn-default {
    border: 1px solid var(--hw-border-accent, rgba(0, 176, 235, 0.16)) !important;
    border-radius: var(--hw-radius-sm, .5rem);
    background-color: var(--hw-surface-bg, rgba(30, 41, 59, 0.92)) !important;
    color: #fff;
}

button.primary.btn.btn-primary {
    border-radius: var(--hw-radius-sm, .5rem);
    background-color: var(--hw-accent-secondary, #00B0EB);
}

/* =============================================================================
   UPLOAD BUTTON
   ============================================================================= */

button#UploadButton {
    background-color: var(--hw-accent-primary, rgb(0, 163, 224)) !important;
    color: #ffffff !important;
    border-radius: var(--hw-radius-sm, .5rem);
}

button#UploadButton:hover,
button#UploadButton:focus {
    background-color: var(--hw-accent-primary-hover, rgb(0, 144, 212)) !important;
    border: 1px solid var(--hw-accent-primary-hover, rgb(0, 144, 212)) !important;
}

/* =============================================================================
   ATTACHMENT NOTICE
   ============================================================================= */

.hw-attachment-notice {
    margin-top: 14px;
    padding: 14px 16px;
    border-radius: var(--hw-radius-sm, .5rem);
    background: rgba(2, 8, 24, 0.55);
    border: 1px solid var(--hw-border-subtle, rgba(255, 255, 255, 0.08));
    color: rgba(247, 247, 247, 0.78);
    font-family: var(--hw-font-family, 'Segoe UI', sans-serif);
    font-size: var(--hw-font-size-base, 14px);
    line-height: var(--hw-line-height-normal, 1.55);
}

.hw-attachment-notice strong {
    color: rgba(0, 176, 235, 0.95);
    font-weight: 700;
}

/* Hide default upload elements */
.fa.fa-arrow-up {
    display: none;
}

.text-muted {
    display: none !important;
}

/* =============================================================================
   CUSTOM BUTTON STYLING
   ============================================================================= */

.custom-button {
    border: 1px solid var(--hw-border-accent, rgba(0, 176, 235, 0.16)) !important;
    background: var(--hw-surface-bg, rgba(30, 41, 59, 0.92)) !important;
}

.filename {
    color: #fff !important;
}

button.cancelIconDiv {
    display: none !important;
}

/* =============================================================================
   FORM ACTIONS ROW
   ============================================================================= */

.crmEntityFormView .form-custom-actions {
    margin-top: 18px;
}

.crmEntityFormView .form-action-container-left {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

/* =============================================================================
   MODAL STYLING (Lookups)
   ============================================================================= */

.modal-backdrop {
    opacity: 0.75 !important;
}

.modal-content {
    background: var(--hw-card-bg, rgb(44, 53, 68)) !important;
    border: 1px solid var(--hw-border-medium, rgba(148, 163, 184, 0.20)) !important;
    border-radius: var(--hw-radius-xl, 16px) !important;
    box-shadow: var(--hw-shadow-lg, 0 18px 48px rgba(0, 0, 0, 0.45));
    color: var(--hw-form-text, rgba(226, 232, 240, 0.96));
}

.modal-header,
.modal-footer {
    border-color: rgba(148, 163, 184, 0.16) !important;
}

.modal-header .modal-title {
    font-family: var(--hw-font-family, 'Segoe UI', sans-serif);
    font-size: var(--hw-font-size-xl, 18px);
    font-weight: 700;
    color: var(--hw-form-text, rgba(226, 232, 240, 0.96));
}

.modal-header .form-close {
    color: var(--hw-form-text, rgba(226, 232, 240, 0.96));
    opacity: 0.85;
}

.modal-header .form-close:hover {
    opacity: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.modal-footer .btn {
    min-width: 140px;
}

/* =============================================================================
   GENERAL INPUT STYLING (Non-entity forms)
   ============================================================================= */

/* Standard inputs with dark theme */
.hw-input {
    width: 100%;
    height: 48px;
    padding: 0 14px;
    border-radius: var(--hw-radius-sm, .5rem);
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--hw-border-medium, rgba(255, 255, 255, 0.18));
    color: var(--hw-text-primary, rgba(255, 255, 255, 0.92));
    font-family: var(--hw-font-family, 'Segoe UI', sans-serif);
    font-size: var(--hw-font-size-base, 14px);
    line-height: 18px;
}

.hw-input::placeholder {
    color: var(--hw-text-primary, rgba(255, 255, 255, 0.92));
}

.hw-input:focus {
    outline: none;
    border-color: rgba(0, 176, 235, 0.70);
    box-shadow: var(--hw-focus-shadow, 0 0 0 3px rgba(0, 176, 235, 0.18));
}

/* Autofill styling to maintain dark theme */
.hw-input:-webkit-autofill,
.hw-input:-webkit-autofill:hover,
.hw-input:-webkit-autofill:focus,
.hw-input:-webkit-autofill:active {
    -webkit-text-fill-color: var(--hw-text-primary, rgba(255, 255, 255, 0.92));
    transition: background-color 99999s ease-in-out 0s;
    box-shadow: 0 0 0 1000px rgba(0, 0, 0, 0.35) inset;
}

/* Form labels */
.hw-label {
    display: block;
    margin: 0 0 8px;
    color: var(--hw-text-secondary, rgba(247, 247, 247, 0.9));
    font-family: var(--hw-font-family, 'Segoe UI', sans-serif);
    font-weight: 600;
    font-size: var(--hw-font-size-base, 14px);
    line-height: 18px;
}

/* =============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================= */

@media (max-width: 992px) {
    .crmEntityFormView .entity-form {
        grid-template-columns: 1fr;
    }

    .crmEntityFormView .tr {
        grid-column: 1;
    }

    .crmEntityFormView .actions {
        grid-column: 1;
    }
}

@media (max-width: 768px) {
    .crmEntityFormView .tab {
        padding: 14px;
    }

    .crmEntityFormView {
        max-width: none;
    }
}
