/* Display Wordlist Plugin Styles - Adapted from Grammar Exercise Steps */

/* Define colors as CSS variables */
:root {
    --dwl-purple-dark: #800080; /* Purple */
    --dwl-purple-light: #f2e6f2; /* Light Purple */
    --dwl-purple-hover: #6a006a; /* Darker Purple for hover */
    --dwl-text-color: #333;
    --dwl-text-color-light: #ffffff;
    --dwl-separator-color: #e0e0e0;
}

/* Styles for the wordlist steps component */
.dwl-steps-wrapper {
    margin: 25px auto;
    border: none;
    padding: 0;
    background-color: transparent;
}

/* Styles for the step buttons container */
.dwl-steps-wrapper .steps {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--dwl-separator-color);
    list-style: none;
    padding-left: 0;
    flex-wrap: wrap;
    gap: 10px;
}

/* Styles for individual step buttons */
.dwl-steps-wrapper .step {
    padding: 10px 20px;
    cursor: pointer;
    background-color: var(--dwl-purple-light);
    color: var(--dwl-text-color);
    border-radius: 5px;
    transition: background-color 0.3s ease, color 0.3s ease;
    text-align: center;
    border: 1px solid #d1b3d1; /* Slightly darker than light purple for definition */
    font-size: 1rem;
    font-weight: 500;
    flex-grow: 0;
    flex-shrink: 0;
}

/* Hover state for step buttons */
.dwl-steps-wrapper .step:hover {
    background-color: var(--dwl-purple-hover);
    color: var(--dwl-text-color-light);
    border-color: var(--dwl-purple-hover);
}

/* Active state for the selected step button */
.dwl-steps-wrapper .step.active {
     background-color: var(--dwl-purple-dark);
     color: var(--dwl-text-color-light);
     font-weight: bold;
     border-color: var(--dwl-purple-dark);
}

/* Styles for the content areas */
.dwl-steps-wrapper .content {
    display: none; /* Handled by JS for tabbing */
    margin-top: 20px;
    padding: 20px; /* Add padding for content within the box */
    border: 1px solid var(--dwl-separator-color); /* Border for the content box */
    background-color: #fff; /* White background for content box */
    border-radius: 5px; /* Rounded corners for content box */
}

.dwl-steps-wrapper .content.active {
    display: block;
}


/* Main Title for the Wordlist (below tabs) */
.dwl-main-title {
    text-align: center;
    margin-top: 0; /* Adjusted as it's inside the wrapper now */
    margin-bottom: 20px;
    font-size: 1.8em;
    color: var(--dwl-text-color);
}

/* Wordlist Details Styling (specific to the first tab's content) */
.dwl-wordlist-details-wrapper {
    margin-top: 0; /* No extra margin needed if content area has padding */
    max-width: 1000px;
    margin-left: auto;
    margin-right: auto;
}

.dwl-wordlist { /* This class is no longer used for the main list, but can be kept for other potential lists */
    list-style: none;
    padding: 0;
}

/* Table Styles */
.dwl-wordlist-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0; /* Adjusted as it's inside .dwl-wordlist-details-wrapper */
}

.dwl-wordlist-table th,
.dwl-wordlist-table td {
    border: 1px solid var(--dwl-separator-color);
    padding: 10px;
    text-align: left;
    vertical-align: top;
}

.dwl-wordlist-table th {
    background-color: var(--dwl-purple-light);
    color: var(--dwl-text-color);
    font-weight: bold;
}

.dwl-wordlist-table .dwl-td-term strong {
    color: var(--dwl-purple-dark);
}

.dwl-term-inner-wrapper {
    display: flex;
    align-items: center;
}

.dwl-wordlist-table .dwl-td-definition {
    color: #555;
}

.dwl-wordlist-table .dwl-td-example {
    color: #777;
    font-style: italic;
}

.dwl-highlighted-term {
    background-color: transparent;
    color: var(--dwl-purple-dark); /* Purple color for the term */
    font-weight: bold;
}

/* Error and Info Messages */
.dwl-error {
    color: red;
    font-weight: bold;
    padding: 10px;
    border: 1px solid red;
    background-color: #ffe0e0;
    margin-bottom: 15px;
}

.dwl-info {
    color: #31708f;
    padding: 10px;
    border: 1px solid #bce8f1;
    background-color: #d9edf7;
    margin-bottom: 15px;
}

/* Media Query for Smaller Screens */
@media (max-width: 768px) {
    .dwl-steps-wrapper .steps {
        flex-direction: column;
        align-items: center;
        border-bottom: none;
        padding-bottom: 0;
    }

    .dwl-steps-wrapper .step {
        width: 90%;
        max-width: 400px; /* Max width for buttons on small screens */
    }

    .dwl-steps-wrapper .content {
        margin-top: 25px;
        padding: 15px; /* Adjust padding for smaller screens */
    }

    /* Responsive Table Styles */
    .dwl-wordlist-table thead {
        display: none; /* Hide table headers on mobile */
    }
    .dwl-wordlist-table, 
    .dwl-wordlist-table tbody, 
    .dwl-wordlist-table tr, 
    .dwl-wordlist-table td {
        display: block; /* Make table elements stack */
        width: 100% !important; /* Force full width */
        box-sizing: border-box;
    }
    .dwl-wordlist-table tr {
        margin-bottom: 15px; /* Space between stacked items */
        border: 1px solid var(--dwl-separator-color); /* Add border around each item */
        border-radius: 4px;
    }
    .dwl-wordlist-table td {
        text-align: left !important; /* Align text to the left */
        padding-left: 10px;
        padding-right: 10px;
        border: none; /* Remove individual cell borders */
        border-bottom: 1px dashed var(--dwl-separator-color); /* Separator inside item */
        position: relative;
        padding-top: 8px;
        padding-bottom: 8px;
    }
    .dwl-wordlist-table td:last-child {
        border-bottom: none; /* No border for the last cell in an item */
    }
    .dwl-wordlist-table td[data-label]::before {
        content: attr(data-label); /* Use data-label for pseudo-headers */
        font-weight: bold;
        display: inline-block;
        width: auto; /* Adjust as needed or remove if labels are short */
        margin-right: 5px;
        color: var(--dwl-text-color);
    }

    .dwl-wordlist-table .dwl-td-term .dwl-term-inner-wrapper {
        display: inline-flex;
        vertical-align: middle;
    }
    .dwl-wordlist-table .dwl-td-term strong { /* Ensure term remains bold */
        font-weight: bold !important; 
    }

    /* Modal specific adjustments for smaller screens */
    .dwl-modal-content {
        width: 90% !important; /* Make modal wider on small screens */
        margin: 5% auto; /* Adjust margin for better centering */
        padding: 15px;
    }
}

/* Export Button and Modal Styles */
.dwl-export-button-container {
    display: flex;
    justify-content: flex-end; /* Align buttons to the right */
    gap: 10px; /* Space between buttons */
    margin-bottom: 15px;
    flex-wrap: wrap; /* Allow buttons to wrap on smaller screens if necessary */
}

.button.dwl-button-primary { /* General purple button style */
    background-color: var(--dwl-purple-dark) !important;
    border-color: var(--dwl-purple-dark) !important;
    color: var(--dwl-text-color-light) !important;
    padding: 8px 15px;
    text-decoration: none;
    font-size: 0.9em;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.button.dwl-button-primary:hover {
    background-color: var(--dwl-purple-hover) !important;
    border-color: var(--dwl-purple-hover) !important;
}

/* Danger Button Style (for delete buttons) */
.button.dwl-button-danger {
    background-color: #dc3545 !important; /* Red */
    border-color: #dc3545 !important;
    color: white !important;
    padding: 8px 15px; /* Consistent with primary button */
    text-decoration: none !important;
    font-size: 0.9em; /* Consistent with primary button */
    border-radius: 4px; /* Consistent with primary button */
    transition: background-color 0.2s ease;
}

.button.dwl-button-danger:hover {
    background-color: #c82333 !important; /* Darker Red */
    border-color: #bd2130 !important;
    color: white !important;
}


/* Modal Styles (similar to create-wordlist) */
.dwl-modal {
    display: none; 
    position: fixed; 
    z-index: 1000; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgba(0,0,0,0.5); 
}

.dwl-modal-content {
    background-color: #fefefe;
    margin: 10% auto; 
    padding: 25px;
    border: 1px solid #888;
    width: 60%; 
    max-width: 600px;
    border-radius: 5px;
    position: relative;
    box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19);
}

.dwl-modal-close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    line-height: 1;
}

.dwl-modal-close:hover,
.dwl-modal-close:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

.dwl-modal .dwl-form-group {
    margin-bottom: 20px; /* Increased margin for better spacing with toggles */
    display: flex; /* For aligning label and toggle */
    align-items: center; /* Vertically align items */
    justify-content: space-between; /* Space out label and toggle */
    min-height: 34px; /* Ensure consistent height for alignment */
}

.dwl-modal .dwl-form-group > label:first-child,
.dwl-modal .dwl-form-group > .dwl-dynamic-label { /* Style for the main label of the group, including dynamic ones */
    margin-right: 15px; /* Space between main label and toggle area */
    font-weight: bold;
    flex-shrink: 0; /* Prevent this label from shrinking unduly */
    flex-basis: 280px; /* Give labels a consistent starting width, adjust as needed */
    min-width: 200px; /* Ensure it doesn't get too small */
}

/* New container for the toggle switch and any associated labels (like Comma/Tab) on the right */
.dwl-modal .dwl-form-group .dwl-toggle-control-area {
    display: flex;
    align-items: center;
    justify-content: flex-end; /* Aligns single toggles to the end */
    /* min-width: 60px; /* Only needs to fit the toggle itself now */
    flex-shrink: 0; /* Prevent shrinking */
}

/* This class is no longer used for delimiter text labels, but keep for now if other uses exist */
.dwl-modal .dwl-form-group .dwl-delimiter-control-area .dwl-delimiter-label {
    font-size: 0.9em;
    color: var(--dwl-text-color);
    padding: 0 6px; 
    white-space: nowrap; 
}


.dwl-modal textarea#dwl-export-textarea {
    min-height: 150px;
    resize: vertical;
}

/* Toggle Switch Styles */
.dwl-toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px; /* Width of the toggle */
    height: 34px; /* Height of the toggle */
    flex-shrink: 0; /* Prevent toggle from shrinking */
}

.dwl-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.dwl-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc; /* Default background of the slider */
    -webkit-transition: .4s;
    transition: .4s;
    border-radius: 34px; /* Rounded slider */
}

/* Specific style for delimiter toggle track to always be purple */
.dwl-slider.dwl-delimiter-slider-track {
    background-color: var(--dwl-purple-dark); /* Darker purple for the track */
}
.dwl-slider.dwl-delimiter-slider-track:before {
    /* Knob color remains white by default from .dwl-slider:before */
}

input:checked + .dwl-slider.dwl-delimiter-slider-track {
    background-color: var(--dwl-purple-dark); /* Stays dark purple */
}


.dwl-slider:before {
    position: absolute;
    content: "";
    height: 26px; /* Height of the knob */
    width: 26px; /* Width of the knob */
    left: 4px;
    bottom: 4px;
    background-color: white; /* Knob color */
    -webkit-transition: .4s;
    transition: .4s;
    border-radius: 50%; /* Circular knob */
}

input:checked + .dwl-slider:not(.dwl-delimiter-slider-track) { /* Exclude delimiter from changing track color on check */
    background-color: var(--dwl-purple-dark); /* Purple background when checked for normal toggles */
}

input:focus + .dwl-slider {
    box-shadow: 0 0 1px var(--dwl-purple-dark);
}

input:checked + .dwl-slider:before { /* This applies to all sliders including delimiter for knob movement */
    -webkit-transform: translateX(26px); /* Move knob to the right */
    -ms-transform: translateX(26px);
    transform: translateX(26px);
}

/* Specific styling for delimiter toggle text if needed */
.dwl-delimiter-label { /* This was the old generic one, specific one above is better */
    font-size: 0.9em;
    color: #555;
    margin-left: 8px; 
}


/* Adjust form group for text area to not use flex */
.dwl-modal .dwl-form-group.dwl-textarea-group {
    display: block; /* Revert to block for textarea */
}
.dwl-modal .dwl-form-group.dwl-textarea-group label {
    margin-bottom: 5px; /* Add margin back for textarea label */
}


/* Mobile specific adjustments for toggles */
@media (max-width: 768px) {
    .dwl-modal .dwl-form-group {
        flex-direction: column; /* Stack label and toggle area */
        align-items: flex-start; /* Align items to the start of the column */
    }

    .dwl-modal .dwl-form-group > label:first-child,
    .dwl-modal .dwl-form-group > .dwl-dynamic-label {
        margin-bottom: 8px; /* Space between stacked label and toggle area */
        margin-right: 0; /* No right margin when stacked */
        flex-basis: auto; /* Allow label to take natural width on mobile */
        width: 100%; /* Make label take full width */
    }

    .dwl-modal .dwl-form-group .dwl-toggle-control-area {
        width: auto; /* Allow toggle area to be its natural width */
        justify-content: flex-start; /* Align toggle to the start (left) below label */
        min-width: unset; /* Remove min-width on mobile */
        margin-left: 0; /* Ensure no extra left margin */
    }
    
    /* For single toggles on mobile, they will now be left-aligned under their label */
     .dwl-modal .dwl-form-group .dwl-toggle-control-area .dwl-toggle-switch:only-child {
         margin-left: 0; 
    }

    /* Delimiter specific on mobile if needed, but general rules should cover it */
    .dwl-modal .dwl-form-group .dwl-delimiter-control-area {
        justify-content: flex-start; /* Align to start */
    }
     .dwl-modal .dwl-form-group .dwl-delimiter-control-area .dwl-delimiter-label {
    /* This class is no longer used for the main delimiter label */
    }
}

/* Print-specific styles */
@media print {
    /* Hide elements on the main page that are not relevant for printing */
    .dwl-steps-wrapper .steps,
    .dwl-export-button-container,
    .dwl-modal,
    #wpadminbar, /* WordPress admin bar */
    .site-header, /* Common theme header class */
    .site-footer, /* Common theme footer class */
    nav,
    aside {
        display: none !important;
    }

    body, 
    .dwl-wordlist-details-wrapper, 
    .dwl-steps-wrapper .content.active {
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
        width: 100% !important;
        max-width: 100% !important; /* Ensure content uses full width */
    }

    .dwl-wordlist-table th,
    .dwl-wordlist-table td {
        border: 1px solid #ccc; /* Ensure borders are visible for print */
    }
    .dwl-wordlist-table th {
        background-color: #f2f2f2; /* Light background for headers */
    }
    .dwl-highlighted-term {
        color: black !important; /* Ensure highlighted terms are black for print */
        font-weight: bold;
    background-color: transparent !important;
    }
}

/* Tooltip Styles */
.egh-tooltip-trigger {
    cursor: help;
    font-size: 1em; /* Match heading size better */
    color: var(--dwl-purple-dark);
    margin-left: 3px;
    display: inline-block;
    font-family: initial; /* Ensure it's not overridden by theme's icon font if that's an issue */
    user-select: none; /* Prevent text selection of the (?) */
}

/* Basic title attribute tooltip will be used by default. */
/* For a more advanced custom tooltip that appears on hover (optional):
.egh-tooltip-trigger .egh-tooltip-text {
    visibility: hidden;
    width: 220px;
    background-color: #555;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 5px 10px;
    position: absolute;
    z-index: 1;
    bottom: 125%; 
    left: 50%;
    margin-left: -110px; 
    opacity: 0;
    transition: opacity 0.3s;
}

.egh-tooltip-trigger:hover .egh-tooltip-text {
    visibility: visible;
    opacity: 1;
}
*/

/* Purple Spinner Style */
.dwl-spinner.egh-purple-spinner {
    display: inline-block;
    width: 18px; /* Adjust size as needed */
    height: 18px; /* Adjust size as needed */
    border: 3px solid var(--dwl-purple-light); /* Light purple for the track */
    border-top-color: var(--dwl-purple-dark); /* Dark purple for the moving part */
    border-radius: 50%;
    animation: dwl-spin 1s linear infinite;
    vertical-align: middle;
    margin-left: 5px;
}

@keyframes dwl-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Purple Success Tick Style */
.egh-success-tick {
    display: inline-block;
    color: var(--dwl-purple-dark);
    font-size: 1.2em; /* Adjust size as needed */
    margin-left: 8px;
    vertical-align: middle;
}

/* Textbox Highlight Animation */
.egh-input-highlight {
    animation: egh-highlight-animation 1.5s ease-out;
}

@keyframes egh-highlight-animation {
    0% { background-color: var(--dwl-purple-light); }
    70% { background-color: var(--dwl-purple-light); } /* Hold highlight */
    100% { background-color: transparent; }
}


/* If .dwl-spinner is a border-based spinner (like a rotating circle), 
   you might need something like this instead or in addition:
.dwl-spinner.egh-purple-spinner {
    border-color: var(--dwl-purple-light); 
    border-top-color: var(--dwl-purple-dark) !important; 
    width: 16px; 
    height: 16px;
    display: inline-block;
    vertical-align: middle;
    border-radius: 50%;
    border-width: 2px;
    border-style: solid;
    animation: dwl-spin 1s linear infinite;
}

@keyframes dwl-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
*/

/* Styles for inline link input and copy button */
.egh-link-copy-wrapper {
    display: flex;
    align-items: center;
    gap: 10px; /* Space between input and button */
}

.egh-shareable-link-input {
    flex-grow: 1; /* Allows input to take available space */
    padding: 8px 10px; /* Adjusted padding */
    font-size: 0.9em;
    border: 1px solid #ccc;
    border-radius: 4px;
    height: 37px; /* Match typical button height with padding + border */
    box-sizing: border-box; /* Include padding and border in the element's total width and height */
}

.egh-copy-link-button {
    flex-shrink: 0; /* Prevent button from shrinking */
    height: 37px; /* Match input height */
    padding-top: 8px; /* Ensure text is vertically centered if padding differs from input */
    padding-bottom: 8px;
    line-height: normal; /* Ensure text aligns well */
}
