/* ==========================
   FORMULARIOS BASE
========================== */
form {
    width: 100%;
}

.form-container {
    background: var(--bg-card, #ffffff);
    padding: 32px;
    border-radius: var(--radius-lg, 16px);
    box-shadow: var(--shadow-md, 0 4px 6px rgba(0, 0, 0, 0.1));
    max-width: 700px;
    margin: 0 auto;
}

.form-header {
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f1f5f9;
}

.form-header h2 {
    margin-bottom: 8px;
    color: var(--text-primary, #0f172a);
    font-size: 1.75rem;
}

.form-header p {
    color: var(--text-secondary, #64748b);
    font-size: 0.95rem;
    line-height: 1.5;
}

/* ==========================
   GRUPOS DE FORMULARIO
========================== */
.form-group {
    margin-bottom: 24px;
    position: relative;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

/* ==========================
   LABELS
========================== */
label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary, #0f172a);
    font-size: 0.9rem;
    transition: color var(--transition-fast, 150ms);
    cursor: pointer;
}

label.required::after {
    content: ' *';
    color: #ef4444;
    font-weight: 700;
    margin-left: 2px;
}

label .label-hint {
    font-weight: 400;
    color: var(--text-secondary, #64748b);
    font-size: 0.85rem;
    margin-left: 6px;
    font-style: italic;
}

/* ==========================
   INPUTS BASE
========================== */
input,
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text-primary, #0f172a);
    background-color: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: var(--radius-md, 10px);
    transition: all var(--transition-base, 250ms);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

input:hover,
select:hover,
textarea:hover {
    border-color: #cbd5e1;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1), 0 1px 2px rgba(0, 0, 0, 0.05);
    background-color: #fafbff;
}

/* Placeholder mejorado */
input::placeholder,
textarea::placeholder {
    color: #94a3b8;
    opacity: 1;
}

input:focus::placeholder,
textarea:focus::placeholder {
    opacity: 0.6;
}

/* ==========================
   SELECT MEJORADO
========================== */
select {
    cursor: pointer;
    padding-right: 40px;
    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='%2364748b' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 12px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;  /* ✅ Propiedad estándar agregada */
}

select:focus {
    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='%236366f1' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
}

/* ==========================
   TEXTAREA
========================== */
textarea {
    min-height: 120px;
    resize: vertical;
    line-height: 1.6;
}

/* ==========================
   INPUT CON ICONOS
========================== */
.input-with-icon {
    position: relative;
}

.input-with-icon input,
.input-with-icon select {
    padding-left: 44px;
}

.input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: #94a3b8;
    pointer-events: none;
    transition: color var(--transition-fast, 150ms);
}

.input-with-icon input:focus ~ .input-icon,
.input-with-icon select:focus ~ .input-icon {
    color: #6366f1;
}

/* Icono a la derecha */
.input-icon-right {
    left: auto;
    right: 14px;
}

/* ==========================
   CHECKBOX Y RADIO
========================== */
.checkbox-group,
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.checkbox-item,
.radio-item {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 10px 12px;
    border-radius: var(--radius-sm, 6px);
    transition: background-color var(--transition-fast, 150ms);
}

.checkbox-item:hover,
.radio-item:hover {
    background-color: #f8fafc;
}

input[type="checkbox"],
input[type="radio"] {
    width: 20px;
    height: 20px;
    min-width: 20px;
    cursor: pointer;
    margin: 0;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;  /* ✅ Propiedad estándar agregada */
    border: 2px solid #cbd5e1;
    background-color: #ffffff;
    transition: all var(--transition-fast, 150ms);
    box-shadow: none;
}

input[type="checkbox"] {
    border-radius: 5px;
}

input[type="radio"] {
    border-radius: 50%;
}

input[type="checkbox"]:checked,
input[type="radio"]:checked {
    background-color: #6366f1;
    border-color: #6366f1;
}

input[type="checkbox"]:checked {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath fill='none' stroke='%23ffffff' stroke-width='2' d='M3 7l3 3 5-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
}

input[type="radio"]:checked {
    box-shadow: inset 0 0 0 3px #ffffff;
}

input[type="checkbox"]:focus,
input[type="radio"]:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

input[type="checkbox"]:hover:not(:disabled),
input[type="radio"]:hover:not(:disabled) {
    border-color: #6366f1;
}

.checkbox-item label,
.radio-item label {
    cursor: pointer;
    margin-bottom: 0;
    font-weight: 500;
    user-select: none;
    flex: 1;
}

/* ==========================
   SWITCH (TOGGLE)
========================== */
.switch-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-radius: var(--radius-md, 10px);
    background-color: #f8fafc;
    transition: background-color var(--transition-fast, 150ms);
    border: 1px solid #e2e8f0;
}

.switch-group:hover {
    background-color: #f1f5f9;
}

.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: 0.3s;
    border-radius: 34px;
}

.switch-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.switch input:checked + .switch-slider {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}

.switch input:focus + .switch-slider {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.switch input:checked + .switch-slider:before {
    transform: translateX(22px);
}

/* ==========================
   FILE UPLOAD
========================== */
.file-upload {
    position: relative;
}

.file-upload input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.file-upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px 20px;
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius-md, 10px);
    background-color: #f8fafc;
    cursor: pointer;
    transition: all var(--transition-base, 250ms);
    text-align: center;
}

.file-upload-label:hover {
    border-color: #6366f1;
    background-color: #fafbff;
}

.file-upload input:focus + .file-upload-label {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.file-upload-icon {
    font-size: 2.5rem;
    opacity: 0.5;
}

.file-upload-text {
    color: var(--text-secondary, #64748b);
    font-size: 0.95rem;
}

.file-upload-text strong {
    color: #6366f1;
    font-weight: 600;
}

/* ==========================
   MENSAJES DE AYUDA
========================== */
.form-help {
    display: block;
    margin-top: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary, #64748b);
    line-height: 1.4;
}

/* ==========================
   MENSAJES DE ERROR
========================== */
.form-error {
    display: block;
    margin-top: 6px;
    font-size: 0.85rem;
    color: #ef4444;
    font-weight: 500;
    display: flex;
    align-items: flex-start;
    gap: 6px;
    animation: shake 0.3s ease;
}

.form-error::before {
    content: '⚠';
    font-size: 1rem;
    flex-shrink: 0;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.form-success {
    display: block;
    margin-top: 6px;
    font-size: 0.85rem;
    color: #10b981;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-success::before {
    content: '✓';
    font-size: 1rem;
}

/* Input con error */
.has-error input,
.has-error textarea,
.has-error select {
    border-color: #ef4444;
    background-color: #fef2f2;
}

.has-error input:focus,
.has-error textarea:focus,
.has-error select:focus {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.has-error label {
    color: #dc2626;
}

/* Input con éxito */
.has-success input,
.has-success textarea,
.has-success select {
    border-color: #10b981;
    background-color: #f0fdf4;
}

.has-success input:focus,
.has-success textarea:focus,
.has-success select:focus {
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* ==========================
   ESTADOS DISABLED
========================== */
input:disabled,
textarea:disabled,
select:disabled {
    background-color: #f1f5f9;
    color: #94a3b8;
    cursor: not-allowed;
    opacity: 0.6;
    border-color: #e2e8f0;
}

input:disabled:hover,
textarea:disabled:hover,
select:disabled:hover {
    border-color: #e2e8f0;
}

label.disabled {
    color: #94a3b8;
    cursor: not-allowed;
}

/* ==========================
   ACCIONES DE FORMULARIO
========================== */
.form-actions {
    margin-top: 32px;
    padding-top: 24px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    border-top: 2px solid #f1f5f9;
    justify-content: flex-end;
}

.form-actions-center {
    justify-content: center;
}

.form-actions-start {
    justify-content: flex-start;
}

.form-actions-space-between {
    justify-content: space-between;
}

/* ==========================
   BÚSQUEDA
========================== */
.search-box {
    position: relative;
    max-width: 400px;
}

.search-box input {
    padding-left: 44px;
    padding-right: 44px;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: #94a3b8;
    pointer-events: none;
}

.clear-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: #94a3b8;
    cursor: pointer;
    display: none;
    transition: color var(--transition-fast, 150ms);
}

.clear-icon:hover {
    color: #ef4444;
}

.search-box input:not(:placeholder-shown) ~ .clear-icon {
    display: block;
}

/* ==========================
   RANGE SLIDER
========================== */
input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 5px;
    background: #e2e8f0;
    outline: none;
    padding: 0;
    margin: 15px 0;
    border: none;
    box-shadow: none;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #6366f1;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.15s;
    border: none;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: #4f46e5;
    transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    background: #6366f1;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ==========================
   PASSWORD STRENGTH INDICATOR
========================== */
.password-strength {
    margin-top: 8px;
}

.password-strength-bar {
    height: 4px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 4px;
}

.password-strength-fill {
    height: 100%;
    width: 0;
    transition: width 0.3s ease, background 0.3s ease;
    border-radius: 4px;
}

.password-strength-text {
    font-size: 0.875rem;
    font-weight: 600;
}

/* Estados de fortaleza */
.password-strength-weak .password-strength-fill {
    background: #ef4444;
}

.password-strength-weak .password-strength-text {
    color: #ef4444;
}

.password-strength-medium .password-strength-fill {
    background: #f59e0b;
}

.password-strength-medium .password-strength-text {
    color: #f59e0b;
}

.password-strength-strong .password-strength-fill {
    background: #10b981;
}

.password-strength-strong .password-strength-text {
    color: #10b981;
}

/* ==========================
   INPUT WITH ICON BUTTON
========================== */
.input-with-icon button.input-icon-right,
.input-with-icon button.input-icon-left {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-size: 1.2rem;
    transition: transform var(--transition-fast, 150ms);
    color: inherit;
}

.input-with-icon button.input-icon-right:hover,
.input-with-icon button.input-icon-left:hover {
    transform: scale(1.1);
}

.input-with-icon button.input-icon-right:active,
.input-with-icon button.input-icon-left:active {
    transform: scale(0.95);
}

/* ==========================
   USER PREVIEW CARD
========================== */
.user-preview {
    margin-top: 24px;
    padding: 16px 20px;
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    border: 1px solid #a5b4fc;
    border-radius: var(--radius-md, 10px);
    animation: fadeInUp 0.3s ease;
}

.user-preview-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-preview-avatar {
    font-size: 2rem;
    flex-shrink: 0;
}

.user-preview-info {
    flex: 1;
}

.user-preview-name {
    font-weight: 600;
    color: var(--text-primary, #0f172a);
    margin-bottom: 4px;
}

.user-preview-role {
    font-size: 0.875rem;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================
   BUTTON LOADING STATE
========================== */
.btn-loading-text {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-loading-spinner::before {
    content: "⏳";
    animation: spin 1s linear infinite;
}

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

/* ==========================
   INPUT NUMBER (sin flechas)
========================== */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    appearance: none;  /* ✅ Propiedad estándar */
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;  /* ✅ Propiedad estándar */
}

/* ==========================
   CAMPOS DE FECHA Y HORA
========================== */
input[type="date"],
input[type="time"],
input[type="datetime-local"] {
    cursor: pointer;
}

/* ==========================
   RESPONSIVE
========================== */
@media screen and (max-width: 768px) {
    .form-container {
        padding: 24px 16px;
    }

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

    .form-actions {
        flex-direction: column;
        margin-top: 24px;
        padding-top: 20px;
    }

    .form-actions .btn {
        width: 100%;
    }

    input,
    select,
    textarea {
        font-size: 16px; /* Evita zoom en iOS */
    }
}

@media (max-width: 600px) {
    input,
    select,
    textarea {
        font-size: 1rem;
    }
}
