/**
 * Common CSS for Custom Flatsome Elements
 * 
 * Shared styling for all custom elements to ensure consistency
 * with the Flatsome theme design system.
 */

/* Element Base Styles */
.custom-element {
    margin-bottom: 30px;
}

.custom-element-loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.custom-element-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

/* Form Elements */
.custom-form-group {
    margin-bottom: 20px;
}

.custom-form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
    font-size: 14px;
}

.custom-form-label .required {
    color: #e74c3c;
    margin-left: 2px;
}

.custom-form-control {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e1e8ed;
    border-radius: 6px;
    font-size: 16px;
    line-height: 1.4;
    background: #fff;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.custom-form-control:focus {
    outline: none;
    border-color: var(--primary-color, #3498db);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.custom-form-control:disabled {
    background-color: #f8f9fa;
    opacity: 0.7;
    cursor: not-allowed;
}

.custom-form-help {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
    line-height: 1.3;
}

/* Buttons */
.custom-btn {
    display: inline-block;
    padding: 12px 30px;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    line-height: 1.4;
    white-space: nowrap;
    user-select: none;
    vertical-align: middle;
    position: relative;
    overflow: hidden;
}

.custom-btn:hover {
    transform: translateY(-2px);
    text-decoration: none;
}

.custom-btn:active {
    transform: translateY(0);
}

.custom-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Button Variants */
.custom-btn-primary {
    background: var(--primary-color, #3498db);
    color: #fff;
}

.custom-btn-primary:hover {
    background: var(--primary-color-dark, #2980b9);
    color: #fff;
}

.custom-btn-secondary {
    background: #6c757d;
    color: #fff;
}

.custom-btn-secondary:hover {
    background: #5a6268;
    color: #fff;
}

.custom-btn-success {
    background: #28a745;
    color: #fff;
}

.custom-btn-success:hover {
    background: #218838;
    color: #fff;
}

.custom-btn-alert {
    background: #dc3545;
    color: #fff;
}

.custom-btn-alert:hover {
    background: #c82333;
    color: #fff;
}

.custom-btn-white {
    background: #fff;
    color: #333;
    border: 2px solid #e1e8ed;
}

.custom-btn-white:hover {
    background: #f8f9fa;
    color: #333;
    border-color: #d1d9e0;
}

/* Loading Spinner */
.custom-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Messages */
.custom-message {
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    border-left: 4px solid;
    background-color: #f8f9fa;
}

.custom-message-success {
    background-color: #d4edda;
    color: #155724;
    border-left-color: #28a745;
}

.custom-message-error {
    background-color: #f8d7da;
    color: #721c24;
    border-left-color: #dc3545;
}

.custom-message-warning {
    background-color: #fff3cd;
    color: #856404;
    border-left-color: #ffc107;
}

.custom-message-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border-left-color: #17a2b8;
}

/* Grid System */
.custom-row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -15px;
}

.custom-col {
    flex: 1;
    padding: 0 15px;
    box-sizing: border-box;
}

.custom-col-auto {
    flex: 0 0 auto;
    padding: 0 15px;
}

.custom-col-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
.custom-col-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
.custom-col-3 { flex: 0 0 25%; max-width: 25%; }
.custom-col-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
.custom-col-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
.custom-col-6 { flex: 0 0 50%; max-width: 50%; }
.custom-col-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
.custom-col-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
.custom-col-9 { flex: 0 0 75%; max-width: 75%; }
.custom-col-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
.custom-col-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
.custom-col-12 { flex: 0 0 100%; max-width: 100%; }

/* Utilities */
.custom-text-center { text-align: center; }
.custom-text-left { text-align: left; }
.custom-text-right { text-align: right; }

.custom-mb-0 { margin-bottom: 0; }
.custom-mb-1 { margin-bottom: 10px; }
.custom-mb-2 { margin-bottom: 20px; }
.custom-mb-3 { margin-bottom: 30px; }
.custom-mb-4 { margin-bottom: 40px; }
.custom-mb-5 { margin-bottom: 50px; }

.custom-mt-0 { margin-top: 0; }
.custom-mt-1 { margin-top: 10px; }
.custom-mt-2 { margin-top: 20px; }
.custom-mt-3 { margin-top: 30px; }
.custom-mt-4 { margin-top: 40px; }
.custom-mt-5 { margin-top: 50px; }

.custom-p-0 { padding: 0; }
.custom-p-1 { padding: 10px; }
.custom-p-2 { padding: 20px; }
.custom-p-3 { padding: 30px; }
.custom-p-4 { padding: 40px; }
.custom-p-5 { padding: 50px; }

.custom-d-none { display: none; }
.custom-d-block { display: block; }
.custom-d-flex { display: flex; }
.custom-d-inline { display: inline; }
.custom-d-inline-block { display: inline-block; }

/* Responsive Utilities */
@media (max-width: 849px) {
    .custom-hide-for-medium { display: none !important; }
    .custom-show-for-medium { display: block !important; }
    
    .custom-row {
        margin: 0 -10px;
    }
    
    .custom-col,
    .custom-col-auto,
    [class*="custom-col-"] {
        padding: 0 10px;
        margin-bottom: 20px;
    }
    
    /* Stack columns on medium screens */
    [class*="custom-col-"]:not(.custom-col-12) {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

@media (max-width: 549px) {
    .custom-hide-for-small { display: none !important; }
    .custom-show-for-small { display: block !important; }
    
    .custom-btn {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .custom-form-control {
        padding: 10px 12px;
        font-size: 14px;
    }
    
    .custom-form-label {
        font-size: 13px;
    }
}

/* Show/Hide Utilities */
.custom-show-for-medium,
.custom-show-for-small {
    display: none !important;
}

/* Flatsome Integration */
.ux-builder-element .custom-element {
    margin-bottom: 0;
}

/* Animation Classes */
.custom-fade-in {
    animation: customFadeIn 0.3s ease-in-out;
}

.custom-slide-up {
    animation: customSlideUp 0.3s ease-in-out;
}

.custom-slide-down {
    animation: customSlideDown 0.3s ease-in-out;
}

@keyframes customFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes customSlideUp {
    from { 
        opacity: 0;
        transform: translateY(20px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes customSlideDown {
    from { 
        opacity: 0;
        transform: translateY(-20px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}