/* --- article-add.css --- */

/* Import Font (Optional - Example using Inter) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap');

/* Rosso Corsa Color Variable */
:root {
    --rosso-corsa: #D40000;
    --rosso-corsa-dark: #a70000;
    --rosso-corsa-light: #ff1a1a;
    --text-color: #333;
    --label-color: #555;
    --border-color: #ccc;
    --input-bg: #fff;
    --input-focus-border: var(--rosso-corsa);
    --error-color: #d9534f; /* Bootstrap danger color */
    --success-color: #5cb85c; /* Bootstrap success color */
    --modal-bg: rgba(0, 0, 0, 0.6);
    --modal-content-bg: #fff;
    --required-color: var(--rosso-corsa);
}

.article-add-container {
    font-family: 'Inter', sans-serif; /* Apply font */
    max-width: 700px;
    margin: 2rem auto;
    padding: 2rem;
    background-color: #f9f9f9;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
    color: var(--text-color);
}

#article-add-form .form-field {
    margin-bottom: 1.5rem;
}

#article-add-form label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--label-color);
    font-size: 0.95em;
}

#article-add-form label .required {
    color: var(--required-color);
    margin-left: 2px;
    font-weight: bold;
}

#article-add-form input[type="text"],
#article-add-form textarea,
#article-add-form select {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1em;
    background-color: var(--input-bg);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    box-sizing: border-box; /* Include padding in width */
}

#article-add-form input[type="text"]:focus,
#article-add-form textarea:focus,
#article-add-form select:focus {
    border-color: var(--input-focus-border);
    box-shadow: 0 0 0 3px rgba(212, 0, 0, 0.15); /* Rosso Corsa focus ring */
    outline: none;
}

/* Style invalid inputs */
#article-add-form input.input-error,
#article-add-form textarea.input-error,
#article-add-form select.input-error {
    border-color: var(--error-color);
    box-shadow: 0 0 0 3px rgba(217, 83, 79, 0.15);
}


#article-add-form textarea {
    min-height: 120px;
    resize: vertical;
}

#article-add-form small {
    display: block;
    margin-top: 0.4rem;
    font-size: 0.85em;
    color: #777;
}

/* Category Field Specifics */
.category-field .category-controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.category-field select {
    flex-grow: 1; /* Select takes available space */
}

/* Button Styles (General - Apply to all buttons) */
.article-add-container .button,
.modal .button {
    display: inline-block;
    padding: 0.7rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: background-color 0.3s ease, box-shadow 0.3s ease, transform 0.1s ease;
    line-height: 1.4; /* Ensure text is centered vertically */
}

.article-add-container .button:active,
.modal .button:active {
     transform: translateY(1px); /* Slight press effect */
}


/* Primary Button (Submit, Upload) */
.article-add-container .button.button-primary,
.modal .button.button-primary {
    background-color: var(--rosso-corsa);
    color: #fff;
    box-shadow: 0 2px 5px rgba(212, 0, 0, 0.2);
}

.article-add-container .button.button-primary:hover,
.modal .button.button-primary:hover {
    background-color: var(--rosso-corsa-dark);
    box-shadow: 0 4px 8px rgba(167, 0, 0, 0.3);
}
.article-add-container .button.button-primary:disabled,
.modal .button.button-primary:disabled {
    background-color: #f3a0a0; /* Lighter red when disabled */
    cursor: not-allowed;
    box-shadow: none;
}


/* Secondary Button (Add Category, Remove Image) */
.article-add-container .button.button-secondary,
.modal .button.button-secondary {
    background-color: #e0e0e0;
    color: #444;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.article-add-container .button.button-secondary:hover,
.modal .button.button-secondary:hover {
    background-color: #d0d0d0;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Submit Button Area */
.form-submit {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Spinner (Uses WordPress default spinner styles if available) */
.spinner {
    display: inline-block; /* Make it visible */
    opacity: 0; /* Hide by default */
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    /* Ensure WP spinner styles are loaded or add custom spinner */
     background: url('/wp-admin/images/spinner.gif') no-repeat; /* Default WP spinner */
     background-size: 20px 20px;
     width: 20px;
     height: 20px;
     vertical-align: middle;
     filter: invert(20%) sepia(80%) saturate(5000%) hue-rotate(350deg) brightness(90%) contrast(110%); /* Colorize spinner red */
}

.spinner.is-active {
    opacity: 1;
    visibility: visible;
}

/* Image Uploader Area */
.image-uploader-area {
    border: 2px dashed var(--border-color);
    border-radius: 6px;
    padding: 1.5rem;
    text-align: center;
    background-color: #fdfdfd;
    transition: border-color 0.3s ease, background-color 0.3s ease;
    position: relative; /* For positioning preview and remove button */
}

.image-uploader-area.dragover {
    border-color: var(--rosso-corsa);
    background-color: #fff5f5; /* Light red background on drag over */
}

.image-uploader-area .upload-image-button {
    margin-top: 1rem;
}

.image-uploader-area small {
    margin-top: 0.8rem;
    color: #888;
}

/* Image Preview */
.image-preview {
    position: relative;
    display: inline-block; /* Or block with margin auto */
    margin-bottom: 1rem;
    max-width: 200px; /* Limit preview size */
    border: 1px solid #eee;
    padding: 5px;
    background: #fff;
    border-radius: 4px;
}

.image-preview img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 3px;
}

.image-preview .remove-image-button {
    position: absolute;
    top: -10px;
    right: -10px;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 16px;
    line-height: 22px; /* Center the 'x' */
    text-align: center;
    padding: 0;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.image-preview .remove-image-button:hover {
    background-color: rgba(212, 0, 0, 0.8); /* Red on hover */
}


/* Form Messages (Success/Error) */
.form-message {
    padding: 1rem;
    margin-top: 1.5rem;
    border-radius: 6px;
    font-weight: 500;
    display: none; /* Hidden by default */
    border: 1px solid transparent;
}

.form-message.success {
    background-color: #dff0d8; /* Light green */
    border-color: #d6e9c6;
    color: #3c763d; /* Dark green */
}

.form-message.error {
    background-color: #f2dede; /* Light red */
    border-color: #ebccd1;
    color: #a94442; /* Dark red */
}

/* Modal Styles */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1000; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto; /* Enable scroll if needed */
    background-color: var(--modal-bg);
    animation: fadeIn 0.3s ease-out; /* Fade in animation */
}

.modal-content {
    font-family: 'Inter', sans-serif; /* Apply font */
    background-color: var(--modal-content-bg);
    margin: 15% auto; /* 15% from the top and centered */
    padding: 2rem 2.5rem;
    border: 1px solid #bbb;
    width: 80%; /* Could be more or less, depending on screen size */
    max-width: 500px; /* Maximum width */
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    position: relative;
    animation: slideIn 0.4s ease-out; /* Slide in animation */
    color: var(--text-color);
}

.modal-content h2 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    color: var(--rosso-corsa);
    font-weight: 700;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.8rem;
}

.close-modal {
    color: #aaa;
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    font-weight: bold;
    line-height: 1;
}

.close-modal:hover,
.close-modal:focus {
    color: var(--rosso-corsa);
    text-decoration: none;
    cursor: pointer;
}

/* Modal form fields */
#add-category-form .form-field {
    margin-bottom: 1rem;
}
#add-category-form label {
     margin-bottom: 0.4rem;
     font-weight: 500;
     color: var(--label-color);
}
#add-category-form input[type="text"] {
     width: 100%;
     padding: 0.7rem 0.9rem;
}
#add-category-form .form-submit {
     margin-top: 1.5rem;
     text-align: right; /* Align button to the right */
}
#add-category-form .form-message {
    margin-top: 1rem;
    margin-bottom: 0;
    text-align: left;
}


/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { transform: translateY(-30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .article-add-container {
        margin: 1rem;
        padding: 1.5rem;
    }
    .category-field .category-controls {
        flex-direction: column;
        align-items: stretch;
    }
    .category-field .category-controls button {
        width: 100%;
        margin-top: 0.5rem; /* Add space when stacked */
    }
    .modal-content {
        width: 90%;
        margin: 10% auto;
        padding: 1.5rem;
    }
}

