/* ML PDF System V0.02 Styles */

/* Button - Reset styles to allow theme override if needed */
.ml-pdf-btn-v02 {
    /* Base styles that don't conflict too much with theme */
    cursor: pointer;
    
    /* Ensure visibility */
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Only apply specific styles if NOT using theme class */
.ml-pdf-btn-v02:not(.pdf-add-btn) {
    appearance: none;
    border: 1px solid #000;
    background: rgba(255, 255, 255, 0.95);
    color: #000;
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 6px 12px;
    border-radius: 2px;
    transition: all 0.2s ease;
    white-space: nowrap;
    line-height: 1;
}

.ml-pdf-btn-v02:not(.pdf-add-btn):hover {
    background: #000;
    color: #fff;
}

.ml-pdf-btn-v02:not(.pdf-add-btn).is-active {
    background: #000;
    color: #fff;
    border-color: #000;
}

.ml-pdf-btn-v02:not(.pdf-add-btn).is-active:hover {
    background: #333;
    border-color: #333;
}

/* Sort Modal */
.ml-pdf-sort-list {
    max-height: 60vh;
    overflow-y: auto;
    margin: 20px 0;
    border: 1px solid #eee;
    border-radius: 4px;
}

.ml-pdf-sort-item {
    display: flex;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #eee;
    background: #fff;
    gap: 10px;
}

.ml-pdf-sort-item:last-child {
    border-bottom: none;
}

.ml-pdf-sort-item img {
    width: auto;
    height: 60px;
    max-width: 120px;
    object-fit: contain;
    background: transparent;
    border-radius: 2px;
}

/* Theme Integration: Match Widget Buttons to Toggle Button */
.tableau-pdf-btn {
    appearance: none;
    width: var(--ml-btn-width, 140px) !important; /* Match toggle width exactly */
    display: flex !important;
    justify-content: center;
    align-items: center;
    padding: 0.65rem 1.25rem !important;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    color: #131313 !important;
    background: #fff !important; /* Ensure background for readability */
    border: 1px solid #131313 !important;
    border-radius: 0 !important;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: none !important;
    line-height: 1.2;
}

/* Override container to ensure alignment */
.tableau-pdf-panel[data-pdf-controls] .tableau-pdf-actions {
    width: auto !important;
    min-width: 0 !important;
    align-items: center !important;
    box-shadow: none !important; /* Remove shadow as requested */
}

.tableau-pdf-btn:hover {
    background: #131313 !important;
    color: #fff !important;
}

.tableau-pdf-btn.is-danger {
    color: #b91c1c !important;
    border-color: #b91c1c !important;
}

.tableau-pdf-btn.is-danger:hover {
    background: #b91c1c !important;
    color: #fff !important;
}

.ml-pdf-sort-controls {
    margin-left: auto;
    display: flex;
    gap: 5px;
}

.ml-pdf-sort-btn {
    background: #f5f5f5;
    border: none;
    padding: 5px 10px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 12px;
}

.ml-pdf-sort-btn:hover {
    background: #e0e0e0;
}

.ml-pdf-sort-btn.is-remove {
    color: red;
    background: #fff0f0;
}

.ml-pdf-sort-btn.is-remove:hover {
    background: #ffe0e0;
}

/* Modal */
.ml-pdf-modal-v02 {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.ml-pdf-modal-v02.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.ml-pdf-backdrop {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(2px);
}

.ml-pdf-dialog {
    position: relative;
    background: #fff;
    width: 90%;
    max-width: 480px;
    border-radius: 8px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
    overflow: hidden;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}
.ml-pdf-modal-v02.is-visible .ml-pdf-dialog {
    transform: translateY(0);
}

.ml-pdf-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.ml-pdf-header h3 { margin: 0; font-size: 18px; }

.ml-pdf-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 0 5px;
}

.ml-pdf-body {
    padding: 24px;
}

.ml-pdf-field {
    margin-bottom: 16px;
}
.ml-pdf-field input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

.ml-pdf-submit {
    width: 100%;
    padding: 14px;
    background: #000;
    color: #fff;
    border: none;
    font-weight: 700;
    font-size: 16px;
    border-radius: 4px;
    cursor: pointer;
}
.ml-pdf-submit:disabled {
    opacity: 0.7;
    cursor: wait;
}

#ml-pdf-status-v02 {
    margin-top: 16px;
    font-size: 14px;
    text-align: center;
}
.success { color: green; }
.error { color: red; }

/* Mobile Tweaks */
@media (max-width: 768px) {
    .ml-pdf-btn-v02 {
        padding: 8px 14px;
        font-size: 11px;
    }
}
