/**
 * UX Enhancement Styles
 * Loading states, animations, modals, messages
 */

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

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

button.loading,
.btn.loading {
    opacity: 0.7;
    cursor: wait;
    pointer-events: none;
}

/* Error and Success Messages */
.error-message,
.success-message {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    animation: slideDown 0.3s ease-out;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.error-message {
    background: #fee;
    color: #c33;
    border: 1px solid #fcc;
}

.success-message {
    background: #efe;
    color: #3c3;
    border: 1px solid #cfc;
}

.error-message.fade-out,
.success-message.fade-out {
    animation: slideUp 0.3s ease-out forwards;
}

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

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

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.show {
    opacity: 1;
}

.confirmation-modal {
    background: white;
    border-radius: 12px;
    padding: 0;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal-overlay.show .confirmation-modal {
    transform: scale(1);
}

.modal-content {
    padding: 24px;
}

.modal-content p {
    margin: 0 0 20px 0;
    font-size: 16px;
    color: #333;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.modal-actions .btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-actions .btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.modal-actions .btn-secondary:hover {
    background: #e0e0e0;
}

.modal-actions .btn-primary {
    background: #667eea;
    color: white;
}

.modal-actions .btn-primary:hover {
    background: #5568d3;
    transform: translateY(-1px);
}

/* Form Validation States */
input.invalid,
textarea.invalid {
    border-color: #e74c3c;
    background-color: #fee;
}

input.valid,
textarea.valid {
    border-color: #2ecc71;
    background-color: #efe;
}

input:focus.invalid,
textarea:focus.invalid {
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
}

input:focus.valid,
textarea:focus.valid {
    box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.1);
}

/* Resource Update Animation */
.updating {
    position: relative;
    animation: pulse 0.5s ease-in-out;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.updated {
    animation: highlight 0.3s ease-out;
}

@keyframes highlight {
    0% {
        background-color: transparent;
    }
    50% {
        background-color: rgba(46, 204, 113, 0.2);
    }
    100% {
        background-color: transparent;
    }
}

/* Responsive Design Improvements */
@media (max-width: 768px) {
    .confirmation-modal {
        width: 95%;
        margin: 20px;
    }
    
    .modal-content {
        padding: 20px;
    }
    
    .modal-actions {
        flex-direction: column;
    }
    
    .modal-actions .btn {
        width: 100%;
    }
    
    .error-message,
    .success-message {
        font-size: 13px;
        padding: 10px 14px;
    }
}

@media (max-width: 480px) {
    .confirmation-modal {
        border-radius: 8px;
    }
    
    .modal-content {
        padding: 16px;
    }
    
    .modal-content p {
        font-size: 14px;
    }
}

/* Fade animations */
.fade-in {
    animation: fadeIn 0.3s ease-out;
}

.fade-out {
    animation: fadeOut 0.3s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* Smooth transitions for interactive elements */
button,
.btn,
input,
textarea,
select {
    transition: all 0.2s ease;
}

/* Disabled state styling */
button:disabled,
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

/* Loading state for inputs */
input[disabled],
textarea[disabled] {
    background-color: #f5f5f5;
    cursor: not-allowed;
}
