/* =========================
   FORMULARIO MEAG
========================= */

.meag-form {
    max-width: 1200px;
    margin: 40px auto;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

/* =========================
   STEPS
========================= */

.meag-steps {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 30px;
}

.meag-step-circle {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 2px solid #0051a8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #0051a8;
    background: #fff;
    font-size: 15px;
}

.meag-step--active .meag-step-circle {
    background: #0051a8;
    color: #fff;
}

.meag-step-line {
    width: 80px;
    height: 2px;
    background: #cbd5e1;
}

/* =========================
   TITULO
========================= */

.meag-form-title {
    text-align: center;
    font-size: 28px;
    font-weight: 600;
    margin: 10px 0 40px;
    color: #0f172a;
}

/* =========================
   SECCIONES
========================= */

.meag-section {
    background: #eef5ff;
    padding: 30px;
    border-radius: 14px;
    margin-bottom: 30px;
}

.meag-section h3 {
    margin: 0 0 8px;
    font-size: 20px;
    font-weight: 600;
    color: #0f172a;
}

.meag-section h4 {
    margin: 28px 0 10px;
    font-size: 16px;
    font-weight: 600;
    color: #334155;
}

.meag-help {
    font-size: 14px;
    color: #475569;
    margin-bottom: 24px;
}

/* =========================
   GRID / COLUMNAS
========================= */

.meag-columns {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 30px;
}

.meag-field-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
}

/* =========================
   CAMPOS
========================= */

.meag-field {
    margin-bottom: 18px;
}

.meag-field label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
}

.meag-field input[type="text"],
.meag-field input[type="date"],
.meag-field input[type="number"],
.meag-field select {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    font-size: 14px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    box-sizing: border-box !important;
    transition: all 0.2s ease;
}

/* Selector de Archivos Personalizado */
.meag-field input[type="file"] {
    width: 100%;
    height: 42px;
    padding: 0;
    font-size: 14px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    box-sizing: border-box !important;
    transition: all 0.2s ease;
    cursor: pointer;
    line-height: 40px;
}

.meag-field input[type="file"]::-webkit-file-upload-button,
.meag-field input[type="file"]::file-selector-button {
    background: #0051a8;
    color: #ffffff;
    border: none;
    height: 100%;
    padding: 0 16px;
    margin-right: 15px;
    border-radius: 5px 0 0 5px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: background 0.2s;
}

.meag-field input[type="file"]::-webkit-file-upload-button:hover,
.meag-field input[type="file"]::file-selector-button:hover {
    background: #003d7e;
}

.meag-field input:focus,
.meag-field select:focus {
    outline: none;
    border-color: #0051a8;
    box-shadow: 0 0 0 3px rgba(0, 81, 168, 0.15);
}

/* =========================
   CHECKBOX
========================= */

.meag-checkbox-group label {
    font-weight: 500;
    font-size: 14px;
    margin-right: 16px;
    color: #334155;
}

.meag-checkbox-group input {
    margin-right: 6px;
}

/* =========================
   MULTI-SELECT DROPDOWN (REGIONES / COMUNAS)
========================= */

.meag-multiselect {
    position: relative;
}

.meag-multiselect-trigger {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    font-size: 14px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.meag-multiselect-trigger:hover {
    border-color: #94a3b8;
}

.meag-multiselect.open .meag-multiselect-trigger {
    border-color: #0051a8;
    box-shadow: 0 0 0 3px rgba(0, 81, 168, 0.15);
    border-radius: 6px 6px 0 0;
}

.meag-multiselect-placeholder {
    color: #64748b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.meag-multiselect-placeholder.has-selection {
    color: #1f2937;
}

.meag-multiselect-arrow {
    color: #64748b;
    font-size: 12px;
    transition: transform 0.2s;
    flex-shrink: 0;
    margin-left: 8px;
}

.meag-multiselect.open .meag-multiselect-arrow {
    transform: rotate(180deg);
}

.meag-multiselect-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #0051a8;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 220px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.meag-multiselect.open .meag-multiselect-dropdown {
    display: block;
}

.meag-multiselect-item {
    display: flex !important;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500 !important;
    color: #334155;
    cursor: pointer;
    transition: background 0.15s;
    margin: 0 !important;
}

.meag-multiselect-item:hover {
    background: #f0f6ff;
}

.meag-multiselect-item--all {
    font-weight: 600 !important;
    color: #0f172a;
    background: #f8fafc;
}

.meag-multiselect-item--all:hover {
    background: #e8f1ff;
}

.meag-multiselect-item input[type="checkbox"] {
    margin: 0;
    width: 15px;
    height: 15px;
    accent-color: #0051a8;
    cursor: pointer;
    flex-shrink: 0;
}

.meag-multiselect-divider {
    height: 1px;
    background: #e2e8f0;
    margin: 0;
}

.meag-multiselect-empty {
    padding: 10px 14px;
    font-size: 13px;
    color: #94a3b8;
    margin: 0;
    font-style: italic;
}

/* Scrollbar personalizada */
.meag-multiselect-dropdown::-webkit-scrollbar {
    width: 6px;
}

.meag-multiselect-dropdown::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.meag-multiselect-dropdown::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.meag-multiselect-dropdown::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* =========================
   TAGS
========================= */

.meag-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Chips */

.meag-tag {
    background: #e8f1ff;
    border: 1px solid #2f6fdf;
    color: #2f6fdf;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.meag-tag span {
    cursor: pointer;
    font-weight: bold;
}

.meag-region-group {
    margin-top: 15px;
    width: 100%;
}

.meag-region-group-title {
    font-size: 12px !important;
    font-weight: 700 !important;
    color: #0051a8 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid #e2e8f0;
    font-family: inherit !important;
}

.meag-region-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* =========================
   TABLAS
========================= */

.meag-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    font-size: 14px;
}

.meag-table thead {
    background: #0051a8;
    color: #ffffff;
}

.meag-table th {
    padding: 12px;
    font-weight: 600;
    text-align: left;
}

.meag-table th:last-child,
.meag-table td:last-child {
    text-align: center;
}

.meag-table td {
    padding: 12px;
    border-bottom: 1px solid #e2e8f0;
    color: #334155;
}

.meag-table tbody tr:hover {
    background: rgba(0, 81, 168, 0.05);
}

/* =========================
   BOTONES
========================= */

.meag-btn-primary {
    background: #0051a8;
    color: #ffffff !important;
    border: 1px solid #0051a8;
    padding: 10px 22px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.meag-btn-primary:hover {
    background: #003d7e;
    border-color: #003d7e;
}

.meag-btn-secondary {
    background: #ffffff;
    color: #0051a8;
    border: 1px solid #0051a8;
    padding: 10px 22px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.meag-btn-secondary:hover {
    background: rgba(0, 81, 168, 0.05);
}

.meag-form-footer {
    display: flex;
    gap: 14px;
    margin-top: 30px;
    justify-content: flex-end;
}

/* =========================
   HEADER SECCIONES
========================= */

.meag-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

/* =========================
   RESOLUCIONES
========================= */

.meag-field-row--resolucion {
    display: flex;
    gap: 20px;
    align-items: flex-end;
}

.meag-field-file {
    flex: 2;
}

.meag-field-numero {
    flex: 1;
}

.meag-field-monto {
    flex: 1.4;
}

.meag-file-wrapper {
    display: flex;
}

.meag-file-wrapper input[type=file] {
    flex: 1;
}

.meag-file-btn {
    background: #1f5fae;
    color: white;
    border: none;
    padding: 8px 16px;
    cursor: pointer;
}

.meag-field--action {
    display: flex;
    align-items: flex-end;
}

.meag-field--action button {
    width: auto;
    padding: 10px 18px;
    white-space: nowrap;
}

.meag-field--select-small {
    max-width: 280px;
}

/* =========================
   CAMPOS PEQUEÑOS
========================= */

.meag-field--resolucion-small input {
    max-width: 140px;
}

.meag-field--fecha input {
    max-width: 100%;
}

.meag-field--monto input {
    max-width: 180px;
}

/* =========================
   RESPONSIVE
========================= */

@media (max-width: 900px) {

    .meag-columns {
        grid-template-columns: 1fr;
    }

    .meag-field-row {
        grid-template-columns: 1fr;
    }

    .meag-field-row--resolucion {
        flex-direction: column;
        align-items: stretch;
    }

    .meag-form-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .meag-form-footer button {
        width: 100%;
    }

}

/* =========================
   ACTION ICONS (DASHICONS)
========================= */
.meag-table td .dashicons {
    cursor: pointer;
    font-size: 20px;
    color: #0051a8;
    transition: color 0.2s;
    text-decoration: none;
    width: 20px;
    height: 20px;
}

.meag-table td a {
    text-decoration: none;
    display: inline-block;
}

.meag-table td .dashicons:hover {
    color: #003d7e;
}

.meag-table td .dashicons-trash:hover {
    color: #cc0000;
}

/* =========================
   CAMPO CATEGORÍA (NUEVO)
   ========================= */
.meag-field--categoria select {
    max-width: 100%;
}

.meag-field-row--tipo {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 30px !important;
    margin: 30px 0 !important;
    align-items: start;
}

.meag-field-row--tipo .meag-field label {
    white-space: nowrap;
}

@media (max-width: 900px) {
    .meag-field-row--tipo {
        grid-template-columns: 1fr !important;
    }
}
