.mailsystem-field-wrapper {margin-top:25px;}
.mailsystem-field-section{
	position: relative;
    display: -webkit-flex;
    display: flex;
    -webkit-flex-wrap: wrap;
    flex-wrap: wrap;
    -webkit-align-items: stretch;
    align-items: stretch;
    width: 100%;
    background-color: #f8f6fc;
    padding: 15px;
    margin-bottom: 20px;
}
form h5{
	margin-bottom:20px;
}
.mailsystem-field-section label{
	width: 100%;
	font-size: 16px;
    font-weight: bold;
}
.mailsystem-field-section .mailsystem-template-fields{
	position: relative;
    -webkit-flex: 1 1 auto;
    flex: 1 1 auto;
    width: 1%;
    margin-bottom: 0;
	border-radius: 0;
    border: 2px solid #cbc9cd;
    padding: 9px 13px;
    height: 49px;
    font-size: 1.125rem;
    line-height: 1.5;
    background: #fff;
    box-shadow: none;
}
.mp-founded {
    padding: 5px 15px;
}

.mp-founded h2 {margin-bottom:20px; font-size:33px !important;}
.half-fields{width: 49%;}
.half-fields:first-child{
	margin-right: 2%;
}
.full-width-fields{width: 100%;}
.sendmail-template-fields{
	width: 100%;
	padding: 0.15em 0.75em;
    min-height: 40px;
    border: 1px solid;
    border-color: #e1e1e1;
}
.sendmail-template-fields:focus{
	outline: none;
}
.mailsystem-field-section .mailsystem-template-fields:focus,
.mailsystem-field-section .mailsystem-field-preview:focus{
	outline: none;
}
.mailsystem-field-section .input-group-append {
    margin-left: -1px;
}
.mailsystem-field-section .mailsystem-field-preview{
	font-size: 1.125rem;
    line-height: 1.5;
    background-color: #012169 !important;
    color: #fff;
    text-decoration: none;
    padding: 7px 17px 4px;
    border: none;
    border-bottom: 3px solid #214282;
    cursor: pointer;
    height: 49px;
}
.mailsystem-field-section .mailsystem-field-preview:hover{
	background-color: #009fe3 !important;
    border-bottom: 3px solid #214282;
}

.mailsystem-field-section .mailsystem-field-preview.disabled,
.mailsystem-field-section .mailsystem-field-preview:disabled {
    background-color: #cccccc !important;
    color: #666666 !important;
    cursor: not-allowed !important;
    opacity: 0.6;
}

.mailsystem-field-section .mailsystem-field-preview.disabled:hover,
.mailsystem-field-section .mailsystem-field-preview:disabled:hover {
    background-color: #cccccc !important;
    border-bottom: 3px solid #214282;
}
.card-inner .image-outer{
	border: 1px solid #bbb;
    display: inline-block;
    border-radius: 50%;
    margin-right: 15px;
}
.card-inner .image-outer .image{
	height: 90px;
    width: 90px;
    border-width: 3px;
    background-position: 50%;
    background-size: contain;
    border-radius: 50%;
    background-repeat: no-repeat;
    border: 2px solid #4d4d4d;
}
.card-inner .mp-details {
    display: inline-block;
    vertical-align: top;
   
}
.card-inner .mp-details .primary-info{
	font-weight: 500;
    color: #373151;
    font-size: 1.25rem;
    line-height: 1.35;
}
.card-inner .mp-details .secondary-info{
	font-size: 1.1rem; font-weight:bold;
}
.card-inner .mp-details .indicator-label{
	font-size: 0.9rem;
    line-height: 1.4;
    padding-top: 7px;
    text-align: left;
    overflow: hidden
}
.message-content-data{
	margin: 15px 0;
	width: 100%;
}
.message-data-clone{
	display: none;
}
.mailsystem-field-section .message-data{
	padding: 15px;
    border: 1px solid #e1e1e1;
    word-break: keep-all;
    white-space: pre-line;
    font-size: 1rem;
    /* pointer-events: none; */
    background: #fffef3;
    line-height:1.7;
}
.success-notice-mp {
    text-align: center;
    padding: 15px;
    width: 410px;
    margin: 0 auto;
    background:#00a225;
    font-size: 1.1rem;
    color: #fff;
}
.error-notice-mp{
	background:#fb5858;
	color: #fff;
}

/* AI Generation Styles */
.ai-generation-controls {
    padding: 20px 0;
}

.ai-generation-controls h4 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.2em;
    font-weight: 600;
}

.ai-generation-controls .button {
    margin-right: 10px;
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.ai-generation-controls .button-primary,
#regenerate-ai-email {
    background-color: #de2134 !important;
    border-color: #de2134;
    color: white;
    padding: 10px 30px !important;
}

.ai-generation-controls .button-primary:hover,
#regenerate-ai-email:hover {
    background-color: #b81d2e;
    border-color: #b81d2e;
}

/* Loading state for regenerate button */
#regenerate-ai-email:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    background-color: #de2134 !important;
    border-color: #de2134 !important;
    color: white !important;
}

#regenerate-ai-email .spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s ease-in-out infinite;
}

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

.ai-generation-controls .button-secondary {
    background-color: #f1f1f1;
    border-color: #ccc;
    color: #333;
}

.ai-generation-controls .button-secondary:hover {
    background-color: #e1e1e1;
    border-color: #999;
}

#ai-loading {
    display: flex;
    align-items: center;
    color: #de2134;
    font-weight: 500;
}

#ai-loading .spinner {
    margin-right: 8px;
}

#ai-error {
    padding: 8px 12px;
    border-radius: 4px;
    font-weight: 500;
    margin-top: 10px;
}

/* Email Subject Section */
.email-subject-section {
    margin-bottom: 20px;
}

.email-subject-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

#mailsystem_subject,
.ukmp-locked-subject {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    background: #f3f4f6;
    color: #1f2937;
    cursor: default;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: none;
}

#mailsystem_subject:focus {
    outline: none !important;
    border-color: #0073aa;
}

#mailsystem_subject.error {
    border-color: #d63638;
}

#mailsystem_subject.warning {
    border-color: #f0b849;
}

.ukmp-locked-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.ukmp-locked-hint {
    margin: 8px 0 0;
    font-size: 13px;
    color: #6b7280;
}

/* Tone dropdown (sits beside the Send button, where the AI button used to be) */
.input-group-appends {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.ukmp-tone-wrap {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    vertical-align: middle;
}

.ukmp-tone-label {
    font-weight: 600;
    font-size: 0.95rem;
    color: #012169;
    margin: 0;
    width: auto !important;
    white-space: nowrap;
}

.ukmp-tone-select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    height: 49px;
    padding: 0 44px 0 16px;
    border: 2px solid #cbc9cd;
    border-radius: 0;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23012169' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    font-size: 1rem;
    line-height: 1.5;
    font-weight: 600;
    color: #012169;
    min-width: 210px;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ukmp-tone-select:hover {
    border-color: #012169;
}

.ukmp-tone-select:focus {
    outline: none;
    border-color: #012169;
    box-shadow: 0 0 0 3px rgba(1, 33, 105, 0.12);
}

.ukmp-tone-select:disabled {
    opacity: 0.6;
    cursor: wait;
    border-color: #cbc9cd;
}

@media (max-width: 768px) {
    .ukmp-tone-wrap {
        display: flex;
        width: 100%;
    }

    .ukmp-tone-select {
        flex: 1;
        min-width: 0;
    }
}

/* Locked campaign message — display only */
#editable-message,
.ukmp-locked-message {
    min-height: 200px;
    border: 2px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    background: #f3f4f6;
    font-size: 16px;
    line-height: 1.6;
    cursor: default;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: none;
}

#editable-message:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.1);
}

#editable-message.error {
    border-color: #d63638;
    box-shadow: 0 0 0 2px rgba(214, 54, 56, 0.1);
}

#editable-message.warning {
    border-color: #f0b849;
    box-shadow: 0 0 0 2px rgba(240, 184, 73, 0.1);
}

/* Error Messages */
#subject-error,
#content-error {
    color: #d63638;
    font-size: 14px;
    margin-top: 5px;
    font-weight: 500;
}

/* Form Field Error States */
.sendmail-template-fields.error,
.mailsystem-template-fields.error {
    border-color: #d63638;
    box-shadow: 0 0 0 2px rgba(214, 54, 56, 0.1);
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #de2134;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Success/Error Messages */
.ai-success-message {
    color: #00a32a;
    background-color: #f0f9ff;
    border: 1px solid #00a32a;
    padding: 10px 15px;
    border-radius: 4px;
    margin-top: 10px;
}

.ai-error-message {
    color: #d63638;
    background-color: #fef7f7;
    border: 1px solid #d63638;
    padding: 10px 15px;
    border-radius: 4px;
    margin-top: 10px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .ai-generation-controls {
        padding: 15px;
    }
    
    .ai-generation-controls .button {
        display: block;
        width: 100%;
        margin-bottom: 10px;
        margin-right: 0;
    }
    
    .half-fields {
        width: 100%;
        margin-right: 0;
        margin-bottom: 15px;
    }
    
    .mp-founded h2 {
        font-size: 24px !important;
    }
    
    .card-inner .image-outer {
        display: block;
        margin-bottom: 15px;
        text-align: center;
    }
    
    .card-inner .mp-details {
        display: block;
        text-align: center;
    }
}

/* Accessibility Improvements */
.ai-generation-controls .button:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

#mailsystem_subject:focus,
#editable-message:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .ai-generation-controls {
        display: none;
    }
    
    #editable-message {
        border: 1px solid #000;
        background: white;
    }
}

/* Postcode Autocomplete Styles */
.postcode-autocomplete-container {
    position: relative;
    width: calc(100% - 95px);
}

.postcode-autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
}

.autocomplete-item {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.autocomplete-item:hover,
.autocomplete-item.active {
    background-color: #f0f8ff;
}

.mp-preview {
    padding: 15px;
    border-bottom: 1px solid #eee;
}

.mp-image {
    width: 90px;
    height: 90px;
    background-size: cover;
    background-position: center;
    border: 2px solid #ddd;
    flex-shrink: 0;
}

.mp-details {
    flex: 1;
    margin-left: 0;
}

.mp-name {
    font-weight: bold;
    font-size: 16px;
    color: #333;
    margin-bottom: 0;
}

.mp-party {
    color: #666;
    font-size: 14px;
    margin-bottom: 0;
}

.mp-constituency {
    color: #888;
    font-size: 13px;
    margin-bottom: 0;
}

.mp-since {
    color: #999;
    font-size: 12px;
    margin-bottom: 0;
}

#postcode-loading {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #0073aa;
    display: none;
}

#postcode-loading .spinner {
    float: none;
    margin-right: 5px;
}

/* Postcode Search Field - Full Width Inline */
.postcode-autocomplete-container .mailsystem-template-fields {
    width: 100% !important;
    flex: none !important;
    display: inline-block;
}

.mailsystem-field-section .input-group-append {
    margin-left: 0;
    margin-top: 0;
    display: inline-block;
    vertical-align: top;
}

.mailsystem-field-section .input-group-append .mailsystem-field-preview {
    margin-left: 0;
}

/* Responsive adjustments for autocomplete */
@media (max-width: 768px) {
    .mp-preview {
        padding: 10px;
    }
    
    .mp-image {
        width: 70px;
        height: 70px;
    }
    
    .mp-name {
        font-size: 14px;
    }
    
    .mp-party,
    .mp-constituency {
        font-size: 12px;
    }
}