/**
 * Mad Origin SVG Dividers - CSS Styles
 * Comprehensive styling for SVG dividers across all contexts
 */

/* ==========================================================================
   Base SVG Divider Styles
   ========================================================================== */

.mad-svg-divider {
    display: block;
    width: 100%;
    line-height: 0;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.mad-svg-divider svg {
    width: 100%;
    height: auto;
    display: block;
    vertical-align: bottom;
    fill: currentColor;
}

/* Alignment Classes */
.mad-svg-divider.align-left {
    text-align: left;
    margin-left: 0;
    margin-right: auto;
}

.mad-svg-divider.align-center {
    text-align: center;
    margin-left: auto;
    margin-right: auto;
}

.mad-svg-divider.align-right {
    text-align: right;
    margin-left: auto;
    margin-right: 0;
}

/* ==========================================================================
   Context-Specific Styles
   ========================================================================== */

/* Standalone Widget Dividers */
.mad-svg-widget {
    margin: 20px 0;
}

/* Enhancement Dividers (added to other widgets) */
.mad-svg-enhancement.mad-svg-divider-top {
    margin-bottom: 25px;
}

.mad-svg-enhancement.mad-svg-divider-bottom {
    margin-top: 25px;
}

/* Internal Dividers */
.mad-svg-internal {
    margin: 15px 0;
}

.mad-svg-after-title {
    margin-top: 10px;
    margin-bottom: 20px;
}

.mad-svg-between-elements {
    margin: 30px 0;
}

/* Shortcode Dividers */
.mad-svg-shortcode {
    margin: 20px 0;
    clear: both;
}

/* Smart Inject Dividers */
.mad-svg-smart-inject {
    margin: 20px 0;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

/* Mobile Styles */
@media (max-width: 767px) {
    .mad-svg-divider.mad-svg-mobile {
        margin: 15px 0;
    }
    
    .mad-svg-divider.mad-svg-mobile svg {
        max-height: 40px;
    }
    
    .mad-svg-after-title {
        margin-top: 8px;
        margin-bottom: 15px;
    }
    
    .mad-svg-between-elements {
        margin: 20px 0;
    }
}

/* Tablet Styles */
@media (min-width: 768px) and (max-width: 1023px) {
    .mad-svg-divider.mad-svg-tablet {
        margin: 18px 0;
    }
    
    .mad-svg-divider.mad-svg-tablet svg {
        max-height: 60px;
    }
}

/* Desktop Styles */
@media (min-width: 1024px) {
    .mad-svg-divider.mad-svg-desktop {
        margin: 25px 0;
    }
}

/* ==========================================================================
   Animation Support
   ========================================================================== */

.mad-svg-divider {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.mad-svg-divider.mad-svg-animate-in {
    opacity: 1;
    transform: translateY(0);
}

/* Disable animations on reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .mad-svg-divider {
        opacity: 1;
        transform: none;
        transition: none;
    }
}

/* ==========================================================================
   Widget Integration Styles
   ========================================================================== */

/* SiteOrigin Page Builder Integration */
.so-panel .mad-svg-divider {
    margin-left: auto;
    margin-right: auto;
}

/* Button Widget Integration */
.siteorigin-widget-button .mad-svg-divider {
    margin: 20px auto;
}

/* Hero Widget Integration */
.siteorigin-widget-hero .mad-svg-after-title {
    margin: 15px 0 25px 0;
}

.siteorigin-widget-hero .mad-svg-after-content {
    margin: 25px 0 15px 0;
}

/* Features Widget Integration */
.siteorigin-widget-features .mad-svg-between-features {
    margin: 40px 0;
    text-align: center;
}

/* Editor Widget Integration */
.siteorigin-widget-editor .mad-svg-after-title {
    margin: 10px 0 20px 0;
}

/* Image Widget Integration */
.siteorigin-widget-image .mad-svg-after-image {
    margin: 15px 0 0 0;
}

/* ==========================================================================
   Admin Interface Styles
   ========================================================================== */

/* Widget Form Preview */
.mad-svg-preview-container {
    margin: 15px 0;
    padding: 15px;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.mad-svg-preview-container label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #333;
}

.mad-svg-preview {
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 2px dashed #ccc;
    border-radius: 4px;
    padding: 20px;
}

.mad-svg-preview-placeholder,
.mad-svg-preview-loading,
.mad-svg-preview-error {
    color: #666;
    font-style: italic;
    text-align: center;
}

.mad-svg-preview-loading {
    color: #0073aa;
}

.mad-svg-preview-error {
    color: #d63384;
}

/* Shortcode Generator Modal */
.mad-modal {
    display: none;
    position: fixed;
    z-index: 100000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.mad-modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    border: 1px solid #888;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.mad-modal-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mad-modal-header h3 {
    margin: 0;
    color: #333;
}

.mad-modal-close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
}

.mad-modal-close:hover {
    color: #333;
}

.mad-modal-body {
    padding: 20px;
}

.mad-modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    text-align: right;
}

.mad-modal-footer .button {
    margin-left: 10px;
}

/* Shortcode Form Styles */
#mad-svg-shortcode-form .form-table {
    width: 100%;
}

#mad-svg-shortcode-form .form-table th {
    width: 150px;
    padding: 15px 10px 15px 0;
    text-align: left;
    font-weight: 600;
}

#mad-svg-shortcode-form .form-table td {
    padding: 15px 0;
}

#mad-svg-shortcode-form input[type="range"] {
    width: 200px;
    margin-right: 10px;
}

.value-display {
    font-weight: 600;
    color: #0073aa;
    min-width: 40px;
    display: inline-block;
}

.mad-shortcode-preview {
    margin: 20px 0;
    padding: 15px;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.mad-shortcode-preview h4 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #333;
}

#shortcode-preview-area {
    min-height: 80px;
    background: white;
    border: 2px dashed #ccc;
    border-radius: 4px;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
}

.mad-generated-shortcode {
    margin: 20px 0;
}

.mad-generated-shortcode h4 {
    margin-bottom: 10px;
    color: #333;
}

#generated-shortcode {
    width: 100%;
    height: 80px;
    font-family: monospace;
    font-size: 13px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #f9f9f9;
    resize: vertical;
}

#copy-shortcode {
    margin-top: 10px;
}

/* ==========================================================================
   Theme Compatibility
   ========================================================================== */

/* Ensure dividers work well with popular themes */

/* Twenty Twenty-One */
.wp-block-group .mad-svg-divider {
    margin: 2rem 0;
}

/* Astra */
.ast-container .mad-svg-divider {
    max-width: 100%;
}

/* GeneratePress */
.inside-article .mad-svg-divider {
    margin: 2em 0;
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .mad-svg-divider {
        opacity: 1;
        transform: none;
        page-break-inside: avoid;
    }
    
    .mad-svg-divider svg {
        max-height: 50px;
    }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

/* Screen reader support */
.mad-svg-divider[aria-hidden="true"] {
    speak: none;
}

/* Focus styles for interactive elements */
.mad-svg-divider:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .mad-svg-divider svg {
        filter: contrast(2);
    }
    
    .mad-svg-preview {
        border-color: #000;
    }
}

/* ==========================================================================
   Loading States
   ========================================================================== */

.mad-svg-divider.mad-svg-loading {
    position: relative;
    opacity: 0.5;
}

.mad-svg-divider.mad-svg-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #ccc;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: mad-svg-spin 1s linear infinite;
}

@keyframes mad-svg-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==========================================================================
   Error States
   ========================================================================== */

.mad-svg-divider.mad-svg-error {
    border: 2px dashed #d63384;
    padding: 20px;
    text-align: center;
    color: #d63384;
    background: #fdf2f2;
    border-radius: 4px;
}

.mad-svg-divider.mad-svg-error::before {
    content: "⚠ SVG Divider Error";
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
}

/* ==========================================================================
   Debug Styles (Development Only)
   ========================================================================== */

.mad-svg-debug .mad-svg-divider {
    border: 1px solid red;
    position: relative;
}

.mad-svg-debug .mad-svg-divider::before {
    content: attr(class);
    position: absolute;
    top: -20px;
    left: 0;
    font-size: 10px;
    color: red;
    background: white;
    padding: 2px 4px;
    border: 1px solid red;
    z-index: 10;
}