/**
 * Advanced Form Builder - Frontend CSS v2.1
 * Icons, Counter, Password Toggle, 12-Grid (FIXED)
 */

/* ========== FORM ========== */
.afb-form-wrapper { max-width: 100%; }
.afb-form { width: 100%; }
.afb-form-content { width: 100%; }

/* ========== LAYOUT ========== */
.afb-section { width: 100%; box-sizing: border-box; }
.afb-container { width: 100%; box-sizing: border-box; }
.afb-row { display: flex; flex-wrap: wrap; width: 100%; box-sizing: border-box; }
.afb-column { box-sizing: border-box; }

/* 12-Column Grid - FIXED: cols=3 is 25%, cols=4 is 33.33% */
.afb-col-1 { flex: 0 0 calc(8.333% - 15px); max-width: calc(8.333% - 15px); }
.afb-col-2 { flex: 0 0 calc(16.666% - 15px); max-width: calc(16.666% - 15px); }
.afb-col-3 { flex: 0 0 calc(25% - 15px); max-width: calc(25% - 15px); }
.afb-col-4 { flex: 0 0 calc(33.333% - 15px); max-width: calc(33.333% - 15px); }
.afb-col-5 { flex: 0 0 calc(41.666% - 15px); max-width: calc(41.666% - 15px); }
.afb-col-6 { flex: 0 0 calc(50% - 15px); max-width: calc(50% - 15px); }
.afb-col-7 { flex: 0 0 calc(58.333% - 15px); max-width: calc(58.333% - 15px); }
.afb-col-8 { flex: 0 0 calc(66.666% - 15px); max-width: calc(66.666% - 15px); }
.afb-col-9 { flex: 0 0 calc(75% - 15px); max-width: calc(75% - 15px); }
.afb-col-10 { flex: 0 0 calc(83.333% - 15px); max-width: calc(83.333% - 15px); }
.afb-col-11 { flex: 0 0 calc(91.666% - 15px); max-width: calc(91.666% - 15px); }
.afb-col-12 { flex: 0 0 100%; max-width: 100%; }

/* ========== FIELDS ========== */
.afb-field { margin-bottom: 18px; }

.afb-label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 14px; color: #333; }
.afb-required { color: #dc3545; margin-left: 3px; }

/* Input wrapper with icons */
.afb-input-wrapper { position: relative; display: flex; align-items: center; }

.afb-icon { position: absolute; z-index: 2; color: #666; font-size: 16px; width: 16px; height: 16px; pointer-events: none; }
.afb-icon-left { left: 12px; }
.afb-icon-right { right: 12px; pointer-events: auto; cursor: pointer; }
.afb-icon-right:hover { color: #333; }

.afb-password-toggle { cursor: pointer; transition: color 0.2s; }
.afb-password-toggle:hover { color: #667eea; }

/* Inputs */
.afb-input, .afb-textarea, .afb-select, .afb-file {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.afb-input:focus, .afb-textarea:focus, .afb-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.afb-input.has-icon-left, .afb-select.has-icon-left { padding-left: 40px; }
.afb-input.has-icon-right { padding-right: 40px; }

/* Counter */
.afb-counter { display: block; text-align: right; font-size: 11px; color: #888; margin-top: 4px; }

/* Description */
.afb-description { margin: 5px 0 0; font-size: 12px; color: #666; }

/* Textarea */
.afb-textarea { resize: vertical; min-height: 100px; }

/* Select */
.afb-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 35px;
}

/* Radio & Checkbox */
.afb-options { display: flex; flex-direction: column; gap: 8px; }
.afb-options-inline { flex-direction: row; flex-wrap: wrap; gap: 15px; }

.afb-option { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.afb-option input { margin: 0; width: 16px; height: 16px; cursor: pointer; }
.afb-option-text { color: #333; }

/* File */
.afb-file { padding: 8px; }
.afb-file::file-selector-button {
    padding: 8px 16px;
    margin-right: 12px;
    border: none;
    border-radius: 4px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 13px;
    cursor: pointer;
}

/* ========== BUTTON ========== */
.afb-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 28px;
    font-size: 15px;
    font-weight: 500;
    color: #fff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.35);
}

.afb-button:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(102, 126, 234, 0.45); }
.afb-button:disabled, .afb-button.afb-loading { opacity: 0.7; cursor: not-allowed; transform: none; }
.afb-button .dashicons { font-size: 16px; width: 16px; height: 16px; }

/* ========== MESSAGES ========== */
.afb-form-messages { margin-top: 15px; }
.afb-message { padding: 12px 16px; border-radius: 6px; font-size: 14px; }
.afb-message.afb-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.afb-message.afb-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* ========== CONTENT ========== */
.afb-heading { margin: 0 0 15px; }
.afb-paragraph { margin: 0 0 15px; line-height: 1.6; }
.afb-image { max-width: 100%; height: auto; display: block; }
.afb-divider { border: 0; }
.afb-spacer { display: block; }

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .afb-row { flex-direction: column; }
    .afb-column, [class*="afb-col-"] { flex: 0 0 100% !important; max-width: 100% !important; margin-bottom: 15px; }
    .afb-options-inline { flex-direction: column; }
    .afb-button { width: 100%; }
}
