/* Salama Core Styles */

/* Ad Slots */
.salama-ad-slot {
    margin: 20px 0;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.salama-ad-slide {
    display: none;
    width: 100%;
}
.salama-ad-slide.active {
    display: block;
    animation: fadeIn 0.5s;
}
.salama-ad-disclaimer {
    display: inline-block;
    width: 24px;
    height: 24px;
    background: rgba(0,0,0,0.5);
    color: white;
    border-radius: 50%;
    text-align: center;
    line-height: 24px;
    font-size: 12px;
    cursor: help;
    margin-top: 5px;
    position: relative;
}
.salama-ad-disclaimer:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 100;
}


/* TTS Player (Floating Round) */
.salama-tts-floating-container {
    position: fixed;
    bottom: 80px;
    left: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 99998;
    gap: 8px;
}
.salama-tts-round-btn {
    width: 60px;
    height: 60px;
    background: #25a0d8;
    color: white;
    border: none;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transition: transform 0.2s, background 0.2s;
}
.salama-tts-round-btn:hover {
    transform: scale(1.05);
    background: #1e87b8;
}
.salama-tts-label {
    font-size: 13px;
    font-family: inherit;
    color: #444;
    text-align: center;
    line-height: 1.2;
    font-weight: 500;
}
/* Ensure TTS button hides on invert/monochrome but keeps structure if needed, or adjust z-index */

/* TOC */
.salama-toc {
    background: #f1f1f1;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
}
.salama-toc-title {
    font-weight: bold;
    font-size: 1.2em;
    margin-bottom: 10px;
}
.salama-toc ul {
    list-style: none;
    padding-left: 0;
}
.salama-toc li {
    margin-bottom: 5px;
}
.salama-toc-level-2 { padding-left: 10px; }
.salama-toc-level-3 { padding-left: 20px; }
.salama-toc-mobile-btn, .salama-toc-mobile-overlay {
    display: none;
}

/* Mobile Tables (Karty) */
@media (max-width: 1024px) {
    table.salama-karty {
        display: block;
    }
    table.salama-karty thead {
        display: none;
    }
    table.salama-karty tbody {
        display: block;
    }
    table.salama-karty tr {
        display: block;
        margin-bottom: 15px;
        border: 1px solid #ddd;
        border-radius: 4px;
        padding: 10px;
        background: #fff;
    }
    table.salama-karty td {
        display: block;
        text-align: right;
        padding: 5px 0;
        border-bottom: 1px solid #eee;
    }
    table.salama-karty td:last-child {
        border-bottom: none;
    }
    table.salama-karty td::before {
        content: attr(data-label);
        float: left;
        font-weight: bold;
        color: #555;
    }
    
    /* TOC Mobile */
    .salama-toc { display: none; }
    .salama-toc-mobile-btn {
        display: block;
        position: fixed;
        bottom: 20px;
        right: 20px;
        background: #0073aa;
        color: white;
        border: none;
        padding: 10px 20px;
        border-radius: 30px;
        z-index: 999;
        box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    }
    .salama-toc-mobile-overlay {
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(255,255,255,0.95);
        z-index: 9999;
        padding: 40px 20px;
        overflow-y: auto;
    }
    .salama-toc-mobile-overlay .salama-toc {
        display: block;
        background: transparent;
    }
    .salama-toc-close {
        position: absolute;
        top: 10px;
        right: 20px;
        font-size: 30px;
        background: none;
        border: none;
        cursor: pointer;
    }
}

/* CSV Features */
.salama-section {
    content-visibility: auto;
    contain-intrinsic-size: 1px 1000px;
}
table.salama-tabela-referencyjna {
    display: block;
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
}

/* PDF Viewer */
.salama-pdf-viewer {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    overflow: hidden;
    margin: 20px 0;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}
.salama-pdf-toolbar {
    background: #1e293b;
    color: white;
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.salama-pdf-toolbar button {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    transition: background 0.2s;
}
.salama-pdf-toolbar button:hover {
    background: #2563eb;
}
.salama-pdf-toolbar button:disabled {
    background: #64748b;
    cursor: not-allowed;
}
.salama-pdf-canvas {
    width: 100%;
    height: auto;
    display: block;
    background: white;
}

/* ============================================
   SALAMA CORE v2.0 — New Module Styles
   ============================================ */

/* --- Glossary Tooltips --- */
.salama-glossary-term {
    border-bottom: 1px dotted #4a7c59;
    text-decoration: none;
    color: inherit;
    position: relative;
    cursor: help;
}
.salama-glossary-term:hover {
    color: #4a7c59;
}
.salama-glossary-term[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.4;
    max-width: 320px;
    min-width: 180px;
    white-space: normal;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0,0,0,.25);
    pointer-events: none;
}
.salama-glossary-term[data-tooltip]:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    border: 6px solid transparent;
    border-top-color: #333;
    z-index: 10001;
}

/* --- Accessibility Toolbar (Dark Theme) --- */
#salama-a11y-toggle {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 56px;
    height: 56px;
    background: #4285f4;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 99998;
    box-shadow: 0 4px 12px rgba(0,0,0,.3);
    transition: transform .2s;
}
#salama-a11y-toggle:hover { transform: scale(1.05); }

#salama-a11y-panel.salama-a11y-dark-theme {
    position: fixed;
    bottom: 140px;
    right: 20px;
    width: 380px;
    background: #222;
    color: #eee;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,.5);
    z-index: 99999;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.salama-a11y-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #333;
}
.salama-a11y-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
}
.salama-a11y-header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}
.salama-a11y-header-actions button {
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: color 0.2s, background 0.2s;
}
.salama-a11y-header-actions button:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
}
.salama-a11y-close-btn {
    background: #4285f4 !important;
    color: #fff !important;
    width: 32px;
    height: 32px;
    font-size: 20px;
}
.salama-a11y-close-btn:hover {
    background: #3367d6 !important;
}

.salama-a11y-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 20px;
    border-bottom: 1px solid #333;
}
.salama-a11y-btn {
    background: #333;
    border: 1px solid #444;
    color: #eee;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    text-align: left;
}
.salama-a11y-btn:hover {
    background: #444;
}
.salama-a11y-btn.active {
    border-color: #4285f4;
    box-shadow: 0 0 0 1px #4285f4;
    color: #fff;
}

.salama-a11y-sliders {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.salama-a11y-slider-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.salama-a11y-slider-row label {
    flex: 1;
    font-size: 13px;
    color: #ccc;
    margin: 0;
}
.salama-a11y-slider-row input[type="range"] {
    width: 80px;
    accent-color: #4285f4;
}
.salama-a11y-val {
    width: 40px;
    font-size: 12px;
    font-weight: 600;
    text-align: right;
    color: #fff;
}
.salama-a11y-ctrl-btn {
    background: #333;
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: background 0.2s;
}
.salama-a11y-ctrl-btn:hover {
    background: #444;
}

/* Accessibility States */
html.salama-filter-invert body { background-color: #111 !important; color: #eee !important; }
html.salama-filter-dark-contrast body { background-color: #000 !important; color: #fff !important; }
html.salama-filter-monochrome body { background-color: #fff !important; }

html.salama-filter-invert body > *:not(#salama-a11y-panel):not(#salama-a11y-toggle):not(#salama-tts-floating-container):not(#salama-cookie-banner):not(.salama-toc-progress-container) { filter: invert(1) hue-rotate(180deg); }
html.salama-filter-monochrome body > *:not(#salama-a11y-panel):not(#salama-a11y-toggle):not(#salama-tts-floating-container):not(#salama-cookie-banner):not(.salama-toc-progress-container) { filter: grayscale(100%); }
html.salama-filter-dark-contrast body > *:not(#salama-a11y-panel):not(#salama-a11y-toggle):not(#salama-tts-floating-container):not(#salama-cookie-banner):not(.salama-toc-progress-container) { filter: invert(1) contrast(1.2); }
html.salama-filter-light-contrast body > *:not(#salama-a11y-panel):not(#salama-a11y-toggle):not(#salama-tts-floating-container):not(#salama-cookie-banner):not(.salama-toc-progress-container) { filter: contrast(1.2) brightness(1.1); }
html.salama-filter-low-saturation body > *:not(#salama-a11y-panel):not(#salama-a11y-toggle):not(#salama-tts-floating-container):not(#salama-cookie-banner):not(.salama-toc-progress-container) { filter: saturate(0.5); }
html.salama-filter-high-saturation body > *:not(#salama-a11y-panel):not(#salama-a11y-toggle):not(#salama-tts-floating-container):not(#salama-cookie-banner):not(.salama-toc-progress-container) { filter: saturate(2); }

html.salama-highlight-links body a { text-decoration: underline !important; text-decoration-color: #ffeb3b !important; text-decoration-thickness: 2px !important; }
html.salama-highlight-headings body h1, html.salama-highlight-headings body h2, html.salama-highlight-headings body h3, html.salama-highlight-headings body h4, html.salama-highlight-headings body h5, html.salama-highlight-headings body h6 { border: 2px dashed #4285f4 !important; padding: 4px !important; }

/* --- Cookie Consent Banner --- */
#salama-cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(30, 30, 30, 0.97);
    color: #f0f0f0;
    z-index: 100000;
    padding: 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,.2);
}
.salama-cookie-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 18px 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}
.salama-cookie-inner p {
    flex: 1;
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    min-width: 280px;
}
.salama-cookie-inner a { color: #90caf9; }
.salama-cookie-buttons {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}
.salama-cookie-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    transition: opacity .2s;
}
.salama-cookie-btn:hover { opacity: .85; }
.salama-cookie-btn.primary {
    background: #4caf50;
    color: #fff;
}
.salama-cookie-btn.secondary {
    background: transparent;
    color: #ccc;
    border: 1px solid #666;
}

/* --- Recent Comments Widget --- */
.salama-recent-comments {
    list-style: none;
    padding: 0;
    margin: 0;
}
.salama-recent-comments li {
    display: flex;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
    align-items: flex-start;
}
.salama-recent-comments li:last-child { border-bottom: none; }
.salama-comment-avatar img {
    border-radius: 50%;
    width: 40px;
    height: 40px;
}
.salama-comment-body { font-size: 13px; line-height: 1.4; }
.salama-comment-body a { color: #555; text-decoration: none; }
.salama-comment-body a:hover { color: #333; }
.salama-comment-post { display: block; color: #999; font-size: 11px; margin-top: 2px; }

/* --- Lightbox (enhanced) --- */
.salama-lightbox-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.92);
    z-index: 100001;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    animation: salama-fade-in .2s ease;
}
@keyframes salama-fade-in { from { opacity: 0; } to { opacity: 1; } }
.salama-lightbox-overlay img {
    max-width: 92vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 0 40px rgba(0,0,0,.5);
    cursor: default;
}
.salama-lightbox-close {
    position: absolute;
    top: 20px;
    right: 24px;
    color: #fff;
    font-size: 36px;
    cursor: pointer;
    background: none;
    border: none;
    line-height: 1;
    text-shadow: 0 2px 4px rgba(0,0,0,.5);
}

@media (max-width: 768px) {
    #salama-a11y-panel { width: 240px; right: 10px; bottom: 120px; }
    .salama-cookie-inner { flex-direction: column; padding: 14px 16px; }
    .salama-cookie-buttons { width: 100%; }
    .salama-cookie-btn { flex: 1; text-align: center; }
}
/* ============================================
   SALAMA CORE v2.0.1 — Position Fixes
   ============================================ */

/* Cookie banner MUST be fixed at bottom */
#salama-cookie-banner {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 999999 !important;
    display: none;
}

/* Accessibility toggle MUST be fixed at bottom-right */
#salama-a11y-toggle {
    position: fixed !important;
    bottom: 80px !important;
    right: 20px !important;
    left: auto !important;
    z-index: 999998 !important;
}

/* Accessibility panel MUST be fixed */
#salama-a11y-panel {
    position: fixed !important;
    bottom: 140px !important;
    right: 20px !important;
    left: auto !important;
    z-index: 999999 !important;
}

/* Glossary tooltip - ensure pseudo-elements work */
.salama-glossary-term {
    position: relative !important;
    display: inline !important;
}
.salama-glossary-term[data-tooltip]:hover::after {
    content: attr(data-tooltip) !important;
    position: absolute !important;
    bottom: calc(100% + 8px) !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    background: #333 !important;
    color: #fff !important;
    padding: 10px 14px !important;
    border-radius: 6px !important;
    font-size: 13px !important;
    line-height: 1.4 !important;
    max-width: 320px !important;
    min-width: 180px !important;
    white-space: normal !important;
    z-index: 100000 !important;
    box-shadow: 0 4px 12px rgba(0,0,0,.25) !important;
    pointer-events: none !important;
    word-wrap: break-word !important;
}
.salama-glossary-term[data-tooltip]:hover::before {
    content: '' !important;
    position: absolute !important;
    bottom: calc(100% + 2px) !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    border: 6px solid transparent !important;
    border-top-color: #333 !important;
    z-index: 100001 !important;
}

/* TOC Progress Bar */
.salama-toc-progress-container {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 6px !important;
    background-color: transparent !important;
    z-index: 9999999 !important;
    pointer-events: none;
    display: none !important;
}

@media (max-width: 1024px) {
    .salama-toc-progress-container {
        display: block !important;
    }
}

.salama-toc-progress-bar {
    height: 100% !important;
    background-color: #4caf50 !important;
    width: 0%;
    transition: width 0.1s ease !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2) !important;
}

/* Salama cards table - centered text */
table.salama-karty td,
table.salama-karty th {
    text-align: center;
}
