/*
 * Plugin Name: Textise Viewer Enhanced
 * Description: Styling for the Textise Viewer Enhanced plugin.
 */

/* Google Font for titles (Roboto Slab) - already enqueued in PHP */

/* Verdana font for general text (fallback to system sans-serif) */
/* @import url('https://fonts.googleapis.com/css2?family=Verdana&display=swap'); */ /* Verdana is typically a system font, no need to import */

/* Base styles for the entire textise wrapper */
.textise-wrapper {
    max-width: 960px; /* Even wider for the input box */
    margin: 30px auto;
    padding: 20px;
    background-color: var(--textise-bg-color, #ffffff); /* Use CSS variables for themes */
    /* No border or shadow */
    font-family: 'Verdana', Geneva, sans-serif; /* General font for UI elements */
    color: var(--textise-text-color, #333);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Theme specific variables */
.textise-wrapper.theme-light {
    --textise-bg-color: #ffffff;
    --textise-text-color: #333;
    --textise-input-bg: #ffffff;
    --textise-input-border: #ccc;
    --textise-output-bg: transparent;
    --textise-notice-bg: #e9f7ff;
    --textise-notice-border: #cce5ff;
    --textise-notice-text: #004085;
    --textise-code-bg: #f5f5f5;
    --textise-code-border: #eee;
    --textise-link-color: #007bff;
    --textise-link-hover-color: #0056b3;
}

.textise-wrapper.theme-dark {
    --textise-bg-color: #2b2b2b;
    --textise-text-color: #e0e0e0;
    --textise-input-bg: #2b2b2b;
    --textise-input-border: #555;
    --textise-output-bg: transparent;
    --textise-notice-bg: #3a3a4a;
    --textise-notice-border: #55556a;
    --textise-notice-text: #c0c0d0;
    --textise-code-bg: #444444;
    --textise-code-border: #555555;
    --textise-link-color: #8ab4f8;
    --textise-link-hover-color: #6a9de8;
}

/* Title Styling (Main Textise Logo/Text) */
.textise-title {
    text-align: center;
    font-size: 4.5rem; /* Even larger title */
    font-family: 'Roboto Slab', serif;
    margin-bottom: 5px;
    color: #4169E1; /* Royal Blue from image */
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    letter-spacing: 2px;
    line-height: 1; /* Prevent extra space above */
}

.textise-subtitle {
    text-align: center;
    font-size: 1.2rem;
    font-family: 'Verdana', Geneva, sans-serif;
    color: #4169E1; /* Royal Blue from image */
    margin-top: 0;
    margin-bottom: 20px;
    letter-spacing: 3px;
    font-weight: normal;
}

/* Instructions Link */
.textise-instructions-link {
    display: block;
    text-align: center;
    margin-bottom: 30px;
    color: #007bff;
    text-decoration: underline;
    font-size: 0.95rem;
}
.textise-instructions-link:hover {
    color: #0056b3;
}

/* Input Section Layout */
.textise-input-section {
    margin-bottom: 25px;
    display: flex;
    flex-direction: column;
    align-items: center; /* Center content */
}

.textise-label {
    display: block;
    text-align: center;
    margin-bottom: 10px;
    font-size: 1.1rem;
    color: var(--textise-text-color);
}

/* Form Container - Now a column for input and buttons */
.textise-form {
    display: flex;
    flex-direction: column; /* Stack input and buttons vertically */
    align-items: center; /* Center items horizontally */
    gap: 15px; /* Space between input and buttons */
    width: 100%;
    max-width: 800px; /* Max width for the entire form group */
}

/* URL Input Wrapper for clear button */
.textise-input-wrapper {
    position: relative;
    width: 100%; /* Take full width of parent form */
}

/* URL Input Field - Wider and simpler */
.textise-url-input {
    width: 100%; /* Take full width of its wrapper */
    padding: 10px 40px 10px 15px;
    font-size: 1.1rem;
    border: 1px solid var(--textise-input-border);
    border-radius: 0;
    background-color: var(--textise-input-bg);
    color: var(--textise-text-color);
    box-shadow: none;
    transition: border-color 0.3s ease, background-color 0.3s ease, color 0.3s ease;
}

.textise-url-input:focus {
    border-color: #007bff;
    outline: none;
    box-shadow: none;
}

/* Clear Input Button */
.textise-clear-input {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--textise-text-color);
    opacity: 0.5;
    transition: opacity 0.2s ease, background-color 0.2s ease;
}

.textise-clear-input:hover {
    opacity: 1;
    background-color: rgba(0,0,0,0.05);
}
.textise-clear-input svg {
    fill: currentColor;
}

/* Button Group (Textise, Search - only Textise is active) */
.textise-buttons-group {
    display: flex;
    gap: 10px;
    width: 100%; /* Take full width of parent form */
    justify-content: center; /* Center buttons within their group */
}

/* Submit Button - Simpler style */
.textise-submit-button {
    padding: 10px 25px;
    font-size: 1.1rem;
    font-weight: normal;
    color: #333;
    background-color: #e0e0e0;
    border: 1px solid #ccc;
    border-radius: 0;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    box-shadow: none;
}

.textise-submit-button:hover {
    background-color: #d0d0d0;
    color: #000;
}

.textise-submit-button:active {
    background-color: #c0c0c0;
}

.textise-submit-button:disabled {
    background-color: #f0f0f0;
    color: #999;
    cursor: not-allowed;
}

/* New Search Button Container (moved to be next to input) */
.textise-new-search {
    text-align: center;
    margin-top: 20px; /* More space from controls */
    margin-bottom: 20px; /* Space before output */
    width: 100%; /* Ensure it spans full width */
}

/* Reset Button - Simpler style, similar to submit */
.textise-reset-button {
    padding: 10px 25px;
    font-size: 1.1rem;
    font-weight: normal;
    color: #333;
    background-color: #e0e0e0;
    border: 1px solid #ccc;
    border-radius: 0;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    box-shadow: none;
}

.textise-reset-button:hover {
    background-color: #d0d0d0;
    color: #000;
}

.textise-reset-button:active {
    background-color: #c0c0c0;
}


/* Notice Div Styling (Enhanced Box Look) */
.textise-notice {
    font-size: 0.95rem;
    padding: 20px;
    background-color: var(--textise-notice-bg);
    border: 1px solid var(--textise-notice-border);
    border-radius: 8px;
    margin-bottom: 30px; /* More space below notice */
    color: var(--textise-notice-text);
    line-height: 1.6;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08); /* Stronger shadow for "box" effect */
    font-weight: 500; /* Slightly bolder for emphasis */
}

.textise-notice strong {
    color: var(--textise-notice-text); /* Ensure strong text matches notice color */
}

/* Notice types */
.textise-notice.textise-notice-success {
    background-color: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}
.textise-notice.textise-notice-error {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}
.textise-notice.textise-notice-info {
    background-color: #e2e3e5;
    border-color: #d6d8db;
    color: #383d41;
}
/* Dark theme adjustments for notices */
.theme-dark .textise-notice.textise-notice-success {
    background-color: #28a745; /* Darker green */
    border-color: #218838;
    color: #e2e3e5;
}
.theme-dark .textise-notice.textise-notice-error {
    background-color: #dc3545; /* Darker red */
    border-color: #c82333;
    color: #e2e3e5;
}
.theme-dark .textise-notice.textise-notice-info {
    background-color: #6c757d; /* Darker grey */
    border-color: #5a6268;
    color: #e2e3e5;
}


/* Loading Spinner */
.textise-loading-spinner {
    text-align: center;
    padding: 50px 0;
    font-size: 1.2rem;
    color: var(--textise-text-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.textise-loading-spinner::before {
    content: '';
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

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

.textise-error-message {
    text-align: center;
    padding: 30px 0;
    font-size: 1.1rem;
    color: #dc3545; /* Red for errors */
    font-weight: bold;
}

/* Controls Section */
.textise-controls-section {
    display: flex;
    flex-wrap: wrap;
    justify-content: center; /* Center controls */
    gap: 20px; /* Space between control groups */
    margin-top: 30px; /* Space above controls */
    margin-bottom: 30px;
    padding: 15px;
    background-color: var(--textise-input-bg); /* Match wrapper background */
    border-radius: 8px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05); /* Keep subtle inner shadow */
}

.textise-readability-controls,
.textise-action-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
}

.textise-readability-controls label {
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--textise-text-color);
}

.textise-font-size-btn,
.textise-line-height-btn {
    padding: 8px 12px;
    font-size: 0.9rem;
    font-weight: bold;
    background-color: #e0e0e0;
    border: 1px solid #ccc;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    color: #333;
}
.textise-font-size-btn:hover,
.textise-line-height-btn:hover {
    background-color: #d0d0d0;
    transform: translateY(-1px);
}
.textise-font-size-btn:active,
.textise-line-height-btn:active {
    background-color: #c0c0c0;
    transform: translateY(0);
}
/* Dark theme for readability control buttons */
.theme-dark .textise-font-size-btn,
.theme-dark .textise-line-height-btn {
    background-color: #4a4a4a;
    border-color: #666;
    color: #e0e0e0;
}
.theme-dark .textise-font-size-btn:hover,
.theme-dark .textise-line-height-btn:hover {
    background-color: #5a5a5a;
}

/* Theme Toggle Button */
.textise-theme-toggle {
    padding: 8px 15px;
    font-size: 0.95rem;
    font-weight: 500;
    background-color: #e0e0e0;
    border: 1px solid #ccc;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s ease, transform 0.1s ease;
    color: #333;
}
.textise-theme-toggle:hover {
    background-color: #d0d0d0;
    transform: translateY(-1px);
}
.textise-theme-toggle:active {
    background-color: #c0c0c0;
    transform: translateY(0);
}
.textise-theme-toggle .textise-theme-icon {
    font-size: 1.2em; /* Adjust icon size relative to text */
}
/* Dark theme for theme toggle */
.theme-dark .textise-theme-toggle {
    background-color: #4a4a4a;
    border-color: #666;
    color: #e0e0e0;
}
.theme-dark .textise-theme-toggle:hover {
    background-color: #5a5a5a;
}

/* Action Buttons (Copy, Print) */
.textise-action-button {
    padding: 8px 15px;
    font-size: 0.95rem;
    font-weight: 500;
    background-color: #007bff;
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s ease, transform 0.1s ease;
}
.textise-action-button:hover {
    background-color: #0056b3;
    transform: translateY(-1px);
}
.textise-action-button:active {
    background-color: #004085;
    transform: translateY(0);
}
.textise-action-button svg {
    fill: currentColor;
}


/* Output Div Styling (Main Content) */
.textise-output {
    font-family: 'Verdana', Geneva, sans-serif; /* Changed to Verdana */
    font-size: 1.1rem; /* Default font size */
    line-height: 1.7; /* Default line height */
    color: var(--textise-text-color);
    padding: 20px 0; /* No horizontal padding, match wrapper */
    min-height: 150px; /* Ensure it has some height even when empty */
    background-color: var(--textise-output-bg); /* Match wrapper background */
    border-radius: 0; /* No border-radius */
    box-shadow: none; /* No shadow */
    word-wrap: break-word; /* Ensure long words break */
    transition: font-size 0.2s ease, line-height 0.2s ease, background-color 0.3s ease, color 0.3s ease;
}

.textise-output p {
    margin-bottom: 1em; /* Spacing between paragraphs */
}

.textise-output a {
    color: var(--textise-link-color);
    text-decoration: underline;
    word-break: break-all; /* Break long URLs */
}

.textise-output a:hover {
    color: var(--textise-link-hover-color);
}

.textise-output h1,
.textise-output h2,
.textise-output h3,
.textise-output h4,
.textise-output h5,
.textise-output h6 {
    font-family: 'Roboto Slab', serif; /* Keep Roboto Slab for headings */
    margin-top: 1.8em; /* More space above headings */
    margin-bottom: 0.8em;
    color: var(--textise-text-color);
    line-height: 1.3;
}

.textise-output h1 { font-size: 2.2em; }
.textise-output h2 { font-size: 1.9em; }
.textise-output h3 { font-size: 1.6em; }
.textise-output h4 { font-size: 1.3em; }
.textise-output h5 { font-size: 1.15em; }
.textise-output h6 { font-size: 1em; }

.textise-output ul,
.textise-output ol {
    margin-left: 30px; /* More indent for lists */
    margin-bottom: 1.2em;
}

.textise-output li {
    margin-bottom: 0.6em;
}

.textise-output blockquote {
    border-left: 5px solid #ccc; /* Thicker border */
    padding-left: 20px;
    margin: 1.5em 0;
    font-style: italic;
    color: var(--textise-text-color);
    opacity: 0.8;
}

.textise-output code,
.textise-output pre {
    font-family: 'Fira Code', 'Consolas', monospace; /* Monospace font for code */
    background-color: var(--textise-code-bg);
    border: 1px solid var(--textise-code-border);
    border-radius: 5px;
    padding: 2px 5px;
    color: var(--textise-text-color);
}

.textise-output pre {
    display: block;
    padding: 15px;
    overflow-x: auto;
    white-space: pre-wrap; /* Allow long lines to wrap */
    word-wrap: break-word;
    line-height: 1.5;
}

.textise-output img {
    max-width: 100%; /* Ensure images are responsive */
    height: auto;
    display: block; /* Remove extra space below images */
    margin: 1.5em auto; /* Center images with more vertical space */
    border-radius: 6px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

/* Table Styling - No borders/shadows on table/cells, but clear separation */
.textise-output table {
    width: 100%;
    border-collapse: collapse; /* Collapse borders for a cleaner look */
    margin: 1.5em 0;
    font-size: 0.95em;
    background-color: transparent; /* Match output background */
    border: none; /* No border around table */
}

.textise-output th,
.textise-output td {
    border: none; /* No cell borders */
    padding: 10px 15px;
    text-align: left;
    vertical-align: top;
    color: var(--textise-text-color);
    /* Add a subtle bottom border for row separation */
    border-bottom: 1px solid var(--textise-input-border);
}

.textise-output th {
    background-color: rgba(0,0,0,0.05); /* Slightly darker header background */
    font-weight: bold;
    color: var(--textise-text-color);
}
.theme-dark .textise-output th {
    background-color: rgba(255,255,255,0.08);
}

.textise-output tr:nth-child(even) {
    background-color: rgba(0,0,0,0.02); /* Subtle zebra striping */
}
.theme-dark .textise-output tr:nth-child(even) {
    background-color: rgba(255,255,255,0.05);
}

/* Back to Top Button */
.textise-back-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #007bff;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 123, 255, 0.4);
    opacity: 0; /* Hidden by default */
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.2s ease;
    z-index: 1000; /* Ensure it's on top */
}

.textise-back-to-top:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
}

.textise-back-to-top.show {
    opacity: 1;
    visibility: visible;
}


/* Responsive Adjustments */
@media (max-width: 768px) {
    .textise-wrapper {
        margin: 20px 15px;
        padding: 15px;
    }

    .textise-title {
        font-size: 3.5rem;
    }
    .textise-subtitle {
        font-size: 1rem;
        letter-spacing: 2px;
    }

    .textise-form {
        max-width: 100%; /* Full width on small screens */
    }

    .textise-input-wrapper,
    .textise-buttons-group {
        width: 100%;
    }

    .textise-url-input {
        padding: 10px 40px 10px 15px;
        font-size: 1rem;
    }

    .textise-submit-button,
    .textise-reset-button {
        padding: 10px 20px;
        font-size: 1rem;
    }

    .textise-notice {
        padding: 15px;
        font-size: 0.9rem;
    }

    .textise-output {
        padding: 15px 0;
        font-size: 1rem;
    }

    .textise-controls-section {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
        padding: 10px;
    }

    .textise-readability-controls,
    .textise-action-buttons {
        justify-content: center; /* Center buttons in stacked layout */
        gap: 8px;
    }

    .textise-back-to-top {
        width: 45px;
        height: 45px;
        bottom: 15px;
        right: 15px;
    }
}

@media (max-width: 480px) {
    .textise-wrapper {
        margin: 15px 10px;
        padding: 10px;
    }

    .textise-title {
        font-size: 2.8rem;
    }
    .textise-subtitle {
        font-size: 0.9rem;
        letter-spacing: 1.5px;
    }

    .textise-output h1 { font-size: 1.8em; }
    .textise-output h2 { font-size: 1.6em; }
    .textise-output h3 { font-size: 1.4em; }
    .textise-output h4 { font-size: 1.2em; }
    /* Smaller adjustments for other elements as needed */
}
