/* SECURITY ENHANCED VERSION - assets/frontend.css */

/* POPRAWKA 2: Numerowanie instrukcji - uniwersalne liczniki */
.urd-instructions-list {
    counter-reset: urd-step-counter;
}

.urd-instruction-item {
    counter-increment: urd-step-counter;
}

/* SECURITY FIX: Prevent CSS injection attacks with safer selectors */
/* Base Recipe Container Styles */
.urd-recipe-container {
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    /* SECURITY FIX: Prevent content injection */
    overflow: hidden;
    word-wrap: break-word;
    max-width: 100%;
}

/* SECURITY FIX: Prevent malicious content in pseudo-elements */
.urd-recipe-container::before,
.urd-recipe-container::after {
    content: '';
}

/* Progress bars */
.urd-progress {
    background: #f8f9fa;
    border-radius: 10px;
    overflow: hidden;
    margin: 10px 0;
    height: 8px;
    position: relative;
    /* SECURITY FIX: Prevent layout attacks */
    max-width: 100%;
    min-height: 8px;
}

.urd-progress-fill {
    background: linear-gradient(90deg, #28a745, #20c997);
    height: 100%;
    border-radius: 10px;
    transition: width 0.5s ease;
    width: 0%;
    /* SECURITY FIX: Prevent overflow attacks */
    max-width: 100%;
    min-width: 0%;
}

.urd-progress-text {
    position: absolute;
    right: 10px;
    top: -25px;
    font-size: 12px;
    color: #6c757d;
    font-weight: 600;
    /* SECURITY FIX: Prevent text overflow attacks */
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Animation for checking items - SECURITY FIX: Limited animation */
.urd-checking {
    transform: scale(1.05);
    transition: transform 0.3s ease;
    /* SECURITY FIX: Prevent excessive animation */
    animation-duration: 0.3s;
    animation-fill-mode: both;
}

/* SECURITY FIX: Prevent animation abuse */
@keyframes urd-checking-safe {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Notification styles */
.urd-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #28a745;
    color: white;
    padding: 12px 20px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
    font-weight: 500;
    z-index: 9999;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
    /* SECURITY FIX: Prevent notification abuse */
    max-width: 400px;
    max-height: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    word-wrap: break-word;
    /* SECURITY FIX: Prevent clickjacking */
    pointer-events: auto;
}

.urd-notification-show {
    opacity: 1;
    transform: translateX(0);
}

/* SECURITY FIX: Limit notification count */
.urd-notification:nth-child(n+4) {
    display: none !important;
}

/* Focus styles for accessibility */
.urd-ingredient-item:focus,
.urd-instruction-item:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
    /* SECURITY FIX: Prevent focus outline abuse */
    box-shadow: 0 0 0 2px rgba(0, 123, 186, 0.25);
}

/* Common hover effects - SECURITY FIX: Safe hover states */
.urd-ingredient-item,
.urd-instruction-item {
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    /* SECURITY FIX: Prevent content manipulation */
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    /* SECURITY FIX: Prevent layout manipulation */
    position: relative;
    overflow: hidden;
}

/* SECURITY FIX: Prevent malicious content in interactive elements */
.urd-ingredient-item *,
.urd-instruction-item * {
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Responsive design */
@media (max-width: 768px) {
    .urd-recipe-container {
        margin: 15px 0;
        /* SECURITY FIX: Prevent mobile layout issues */
        min-width: 0;
        max-width: 100%;
    }

    .urd-notification {
        right: 10px;
        left: 10px;
        transform: translateY(-100%);
        /* SECURITY FIX: Prevent mobile notification overflow */
        max-width: calc(100vw - 20px);
    }

    .urd-notification-show {
        transform: translateY(0);
    }
}

/* Print styles - SECURITY FIX: Safe print styles */
@media print {
    .urd-ingredient-item,
    .urd-instruction-item {
        cursor: default;
        break-inside: avoid;
        /* SECURITY FIX: Prevent print layout issues */
        page-break-inside: avoid;
    }

    .urd-recipe-container {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
        /* SECURITY FIX: Safe print layout */
        max-width: 100% !important;
        overflow: visible !important;
    }

    /* SECURITY FIX: Hide interactive elements in print */
    .urd-notification {
        display: none !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .urd-ingredient-item,
    .urd-instruction-item {
        border: 2px solid #000 !important;
        /* SECURITY FIX: Ensure visibility in high contrast */
        background: transparent !important;
    }
    
    .urd-progress {
        border: 1px solid #000 !important;
    }
    
    .urd-progress-fill {
        background: #000 !important;
    }
}

/* Reduced motion support - SECURITY FIX: Respect user preferences */
@media (prefers-reduced-motion: reduce) {
    .urd-ingredient-item,
    .urd-instruction-item,
    .urd-progress-fill,
    .urd-notification,
    .urd-checking {
        transition: none !important;
        animation: none !important;
        transform: none !important;
    }
    
    /* SECURITY FIX: Remove potentially seizure-inducing effects */
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .urd-recipe-container {
        color: #e0e0e0;
        /* SECURITY FIX: Ensure readability in dark mode */
        background: inherit;
    }

    .urd-progress {
        background: #444;
        /* SECURITY FIX: Maintain contrast in dark mode */
        border: 1px solid #666;
    }

    .urd-progress-text {
        color: #ccc;
    }
    
    .urd-notification {
        /* SECURITY FIX: Ensure notification visibility in dark mode */
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    }
}

/* Loading state - SECURITY FIX: Safe loading animation */
.urd-loading {
    opacity: 0.6;
    pointer-events: none;
    /* SECURITY FIX: Prevent interaction during loading */
    position: relative;
    overflow: hidden;
}

.urd-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #333;
    border-radius: 50%;
    animation: urd-spin 1s linear infinite;
    /* SECURITY FIX: Prevent loading animation abuse */
    z-index: 1;
}

/* SECURITY FIX: Safe spinner animation */
@keyframes urd-spin {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(90deg); }
    50% { transform: rotate(180deg); }
    75% { transform: rotate(270deg); }
    100% { transform: rotate(360deg); }
}

/* Custom scrollbar for recipe containers with overflow - SECURITY FIX: Safe scrollbars */
.urd-recipe-container::-webkit-scrollbar {
    width: 6px;
    /* SECURITY FIX: Prevent scrollbar abuse */
    max-width: 12px;
}

.urd-recipe-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.urd-recipe-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
    /* SECURITY FIX: Prevent scrollbar manipulation */
    min-height: 20px;
}

.urd-recipe-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* SECURITY FIX: Fallback for non-webkit browsers */
.urd-recipe-container {
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f1f1f1;
}

/* Universal text correction for proper display */
.urd-instruction-text,
.urd-instruction-title,
.urd-instruction-content {
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    word-break: normal !important;
    white-space: normal !important;
    display: block !important;
    width: 100% !important;
    box-sizing: border-box !important;
    /* SECURITY FIX: Prevent text overflow attacks */
    max-width: 100% !important;
    overflow: hidden !important;
    /* SECURITY FIX: Prevent malicious text manipulation */
    unicode-bidi: normal !important;
    direction: ltr !important;
}

/* SECURITY FIX: Prevent CSS injection through content */
.urd-instruction-text::before,
.urd-instruction-text::after,
.urd-instruction-title::before,
.urd-instruction-title::after {
    content: '' !important;
}

/* Style-specific corrections with security fixes */

/* Style 1 - SECURITY FIX: Safe style 1 */
.urd-style1 .urd-instruction-text {
    flex: 1;
    font-size: 16px;
    line-height: 1.6;
    color: #2c3e50;
    transition: all 0.3s ease;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    word-break: normal;
    /* SECURITY FIX: Prevent flex abuse */
    min-width: 0;
    max-width: 100%;
}

.urd-style1 .urd-instruction-content {
    flex: 1;
    padding-top: 8px;
    width: 100%;
    /* SECURITY FIX: Prevent content overflow */
    min-width: 0;
    overflow: hidden;
}

/* Style 2 - SECURITY FIX: Safe style 2 */
.urd-style2 .urd-instruction-text {
    font-size: 16px;
    line-height: 1.6;
    color: #333;
    transition: all 0.3s ease;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    word-break: normal;
}

.urd-style2 .urd-instruction-content {
    flex: 1;
    width: 100%;
    /* SECURITY FIX: Prevent layout issues */
    min-width: 0;
    box-sizing: border-box;
}

/* Style 3 - SECURITY FIX: Safe style 3 */
.urd-style3 .urd-instruction-text {
    font-size: 16px;
    line-height: 1.5;
    color: #495057;
    transition: all 0.2s ease;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    word-break: normal;
}

.urd-style3 .urd-instruction-content {
    width: 100%;
    /* SECURITY FIX: Prevent content manipulation */
    overflow: hidden;
    box-sizing: border-box;
}

/* Style 4 - SECURITY FIX: Safe style 4 */
.urd-style4 .urd-instruction-text {
    font-size: 16px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.9);
    transition: all 0.3s ease;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    word-break: normal;
}

.urd-style4 .urd-step-content {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px 20px;
    border-radius: 15px;
    flex: 1;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
    width: 100%;
    box-sizing: border-box;
    /* SECURITY FIX: Prevent backdrop abuse */
    overflow: hidden;
    min-width: 0;
}

/* Style 5 - SECURITY FIX: Safe style 5 */
.urd-style5 .urd-instruction-text {
    font-size: 16px;
    line-height: 1.7;
    color: #444;
    transition: all 0.3s ease;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    word-break: normal;
}

.urd-style5 .urd-instruction-content {
    padding: 25px;
    transition: all 0.3s ease;
    width: 100%;
    box-sizing: border-box;
    /* SECURITY FIX: Prevent padding abuse */
    overflow: hidden;
    max-width: 100%;
}

/* Style 6 - SECURITY FIX: Safe style 6 */
.urd-style6 .urd-instruction-text {
    font-size: 16px;
    line-height: 1.6;
    color: #2c3e50;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    word-break: normal;
}

.urd-style6 .urd-instruction-content {
    flex: 1;
    padding-top: 6px;
    width: 100%;
    /* SECURITY FIX: Prevent flex issues */
    min-width: 0;
    overflow: hidden;
}

/* SECURITY FIX: Prevent layout manipulation through flex containers */
.urd-instruction-item {
    align-items: flex-start !important;
    /* SECURITY FIX: Prevent flex abuse */
    max-width: 100% !important;
    min-height: 0 !important;
}

.urd-instruction-content * {
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    white-space: normal !important;
    word-break: normal !important;
    /* SECURITY FIX: Prevent text manipulation */
    max-width: 100% !important;
}

/* SECURITY FIX: Reset potentially problematic theme styles */
.urd-recipe-container .urd-instruction-text,
.urd-recipe-container .urd-instruction-title {
    display: block !important;
    width: auto !important;
    max-width: 100% !important;
    word-spacing: normal !important;
    letter-spacing: normal !important;
    text-align: left !important;
    line-height: inherit !important;
    /* SECURITY FIX: Prevent text injection */
    text-transform: none !important;
    text-decoration: inherit !important;
}

/* SECURITY FIX: Prevent text manipulation */
.urd-instruction-text * {
    display: inline !important;
    word-break: keep-all !important;
    hyphens: none !important;
    /* SECURITY FIX: Prevent malicious inline content */
    max-width: 100% !important;
    overflow: hidden !important;
}

/* SECURITY FIX: Container-level protection */
.urd-recipe-container {
    word-break: normal !important;
    overflow-wrap: break-word !important;
    white-space: normal !important;
    /* SECURITY FIX: Prevent container manipulation */
    isolation: isolate;
    contain: layout style;
}

.urd-recipe-container * {
    word-break: inherit !important;
    overflow-wrap: inherit !important;
    /* SECURITY FIX: Prevent global style manipulation */
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* SECURITY FIX: Prevent malicious pseudo-element content */
.urd-recipe-container *::before,
.urd-recipe-container *::after {
    content: '' !important;
    max-width: 100% !important;
    max-height: 100% !important;
}

/* SECURITY FIX: Performance protection */
.urd-recipe-container {
    will-change: auto;
    transform: translateZ(0);
    /* SECURITY FIX: Prevent excessive repaints */
    backface-visibility: hidden;
}

/* SECURITY FIX: Prevent CSS-based attacks */
.urd-recipe-container,
.urd-recipe-container * {
    /* Prevent data exfiltration via background images */
    background-image: none !important;
    /* Prevent malicious fonts */
    font-family: inherit !important;
    /* Prevent cursor abuse */
    cursor: inherit !important;
}

/* SECURITY FIX: Override any potentially malicious inherited styles */
.urd-recipe-container {
    all: unset;
    display: block;
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    overflow: hidden;
    word-wrap: break-word;
    max-width: 100%;
}