:root {
    /* Colors based on WordPress defaults and your design */
    --ktp-color-primary: #0073aa; /* Main Blue */
    --ktp-color-primary-dark: #005177; /* Darker Blue (Border/Active) */
    --ktp-color-primary-light: #008ec2; /* Lighter Blue (Hover) */
    --ktp-color-white: #ffffff;
    --ktp-color-light-grey: #eee; /* Gutter, Border light */
    --ktp-color-border-medium: #e0e0e0; /* Medium border (read container) */
    --ktp-color-border-light: #f0f0f0; /* Light border (content boxes) */
    --ktp-color-border-dark: #ccc; /* Darker border/Dashicons */
    --ktp-color-text-dark: #333; /* Dark text */
    --ktp-color-success: #4caf50; /* Green */
    --ktp-color-error: #dc3232; /* Red */
    --ktp-color-disabled: #a0a5aa;

    /* Spacing and Sizing */
    --ktp-space-xs: 4px;
    --ktp-space-sm: 8px;
    --ktp-space-md: 10px;
    --ktp-space-lg: 16px;
    --ktp-space-xl: 20px;
    --ktp-space-xxl: 30px; /* New: For large grid gap/margins */
    --ktp-border-radius: 4px;

    /* Transitions */
    --ktp-transition-duration: 0.2s;
    --ktp-transition-timing: ease;

    /* Layout Sizing */
    --ktp-initial-height: 1000px;
    --ktp-min-editor-height: 450px;

    /* Shadows */
    --ktp-shadow-sm: 0 4px 6px rgba(0, 0, 0, 0.1); /* Image shadow */
}

/* -------------------------------------------------------------------------- */
/* 1. READ VIEW CONTAINER STYLES */
/* -------------------------------------------------------------------------- */

.transcription-read-container {
    max-width: 1200px;
    margin: var(--ktp-space-xl) auto;
    padding: var(--ktp-space-xl);
    background-color: var(--ktp-color-white);
    border: 1px solid var(--ktp-color-border-medium);
    border-radius: var(--ktp-border-radius);
}

.transcription-read-title {
    border-bottom: 2px solid var(--ktp-color-primary);
    padding-bottom: var(--ktp-space-md);
    margin-bottom: var(--ktp-space-xl);
}

.transcription-content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--ktp-space-xxl); /* 30px */
}

.transcription-original-image,
.transcription-transcribed-text {
    padding: 15px; /* Keeping 15px as it's an odd value not defined in base spacing */
    border: 1px solid var(--ktp-color-border-light);
    border-radius: var(--ktp-border-radius);
    height: 100%;
}

.transcription-original-image h2,
.transcription-transcribed-text h2 {
    color: var(--ktp-color-text-dark);
    margin-top: 0;
    font-size: 1.2em;
    padding-bottom: var(--ktp-space-sm); /* 8px */
}

.image-wrapper {
    text-align: center;
    max-height: 80vh;
    overflow-y: auto;
}

.transcription-read-image {
    max-width: 100%;
    height: auto;
    display: block;
    box-shadow: var(--ktp-shadow-sm);
}

.transcription-read-footer {
    margin-top: var(--ktp-space-xxl); /* 30px */
    padding-top: 15px; /* Keeping 15px */
    border-top: 1px solid var(--ktp-color-border-light);
    text-align: right;
}

/* Responsive adjustment for smaller screens */
@media (max-width: 800px) {
    .transcription-content-grid {
        grid-template-columns: 1fr;
    }
}

/* -------------------------------------------------------------------------- */
/* 2. TRANSCRIBED TEXT HEADER & COPY BUTTON LAYOUT */
/* -------------------------------------------------------------------------- */

.transcribed-text-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* Using light grey for the separator within the box */
    border-bottom: 1px solid var(--ktp-color-border-light);
    padding-bottom: var(--ktp-space-sm); /* 8px */
    margin-bottom: var(--ktp-space-md); /* 10px */
}

.transcribed-text-header h2 {
    margin: 0;
    padding: 0;
}

/* -------------------------------------------------------------------------- */
/* 3. ICON BUTTON STYLES (ktp-icon-button) */
/* -------------------------------------------------------------------------- */

.ktp-icon-button {
    /* Layout */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--ktp-space-sm);

    /* Appearance */
    background-color: var(--ktp-color-primary);
    color: var(--ktp-color-white);
    border: 1px solid var(--ktp-color-primary-dark);
    border-radius: var(--ktp-border-radius);
    padding: var(--ktp-space-sm) var(--ktp-space-lg);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    line-height: 1.2;
    transition: background-color var(--ktp-transition-duration) var(--ktp-transition-timing),
        border-color var(--ktp-transition-duration) var(--ktp-transition-timing),
        box-shadow var(--ktp-transition-duration) var(--ktp-transition-timing);
}

.ktp-icon-button svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    flex-shrink: 0;
}

.ktp-icon-button span {
    margin: 0;
    padding: 0;
}

.ktp-icon-button:hover {
    background-color: var(--ktp-color-primary-light);
    border-color: var(--ktp-color-primary-dark);
    color: var(--ktp-color-white);
}

.ktp-icon-button:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8), 0 0 0 4px var(--ktp-color-primary);
}

.ktp-icon-button:active {
    background-color: var(--ktp-color-primary-dark);
    transform: translateY(1px);
}

.ktp-icon-button:disabled,
.ktp-icon-button.disabled {
    background-color: var(--ktp-color-disabled);
    border-color: #8c96a0;
    color: #e4e6eb;
    cursor: not-allowed;
    box-shadow: none;
}

/* Container for the entire archive page */
.transcription-archive-container {
    max-width: 1200px;
    margin: 30px auto;
    padding: 0 20px;
}

/* Styling for the unauthorized access notification */
.transcription-archive-container .error-message {
    /* Layout */
    margin: var(--ktp-space-xxl) auto; /* Center with generous top/bottom margin */
    padding: var(--ktp-space-lg);
    max-width: 600px;

    /* Appearance */
    background-color: #ffebe8; /* Very light red/pink background */
    color: var(--ktp-color-error); /* Use the defined error red for text */
    border: 1px solid var(--ktp-color-error); /* Red border */
    border-left: 5px solid var(--ktp-color-error); /* Prominent left border bar */
    border-radius: var(--ktp-border-radius);
    font-size: 1.1em;
    font-weight: 600;
    line-height: 1.4;
}

/* Styling for the login link within the error box */
.login-prompt-link {
    display: inline-block;
    margin-top: var(--ktp-space-md); /* 10px space above the link */
    padding: var(--ktp-space-sm) var(--ktp-space-lg); /* Padding around the link */

    /* Appearance */
    background-color: var(--ktp-color-primary);
    color: var(--ktp-color-white);
    border-radius: var(--ktp-border-radius);
    text-decoration: none;
    font-weight: 700;
    transition: background-color var(--ktp-transition-duration);
}

.login-prompt-link:hover {
    background-color: var(--ktp-color-primary-light);
    color: var(--ktp-color-white);
    text-decoration: none;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--ktp-color-border-medium);
    padding-bottom: 10px;
    margin-bottom: 25px;
}

/* 1. GRID LAYOUT */
.transcription-grid {
    display: grid;
    /* 3 columns on desktop, adapts to min size of 300px */
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

/* 2. CARD STYLING */
.transcription-card {
    background-color: var(--ktp-color-white);
    border: 1px solid var(--ktp-color-border-light);
    border-radius: var(--ktp-border-radius);
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.2s ease;
}

.transcription-card:hover {
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.card-image-wrapper {
    height: 200px; /* Fixed height for image area */
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--ktp-color-light-grey);
}

.transcription-card-image,
.placeholder-image {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Ensure image fits without cropping */
}

.placeholder-image {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ktp-color-disabled);
    font-weight: 600;
}

.card-content {
    padding: 15px;
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Pushes the button to the bottom */
}

.card-title {
    font-size: 1.2em;
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--ktp-color-primary-dark);
}

.card-meta {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.view-button {
    margin-top: auto; /* Aligns button to the bottom */
    width: 100%;
    /* Override standard button padding for full width */
    padding-left: 0;
    padding-right: 0;
}

/* 3. PAGINATION STYLING */
.transcription-pagination {
    text-align: center;
    padding: 20px 0;
    border-top: 1px solid var(--ktp-color-border-light);
}

/* -------------------------------------------------------------------------- */
/* 9. TOAST NOTIFICATION COMPONENT */
/* -------------------------------------------------------------------------- */

#toast-container {
    position: fixed;
    bottom: var(--ktp-space-xl); /* 20px from bottom */
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none; /* Allows clicks through the empty space */
    z-index: 100000;
}

.ktp-toast {
    background-color: #333; /* Dark background */
    color: var(--ktp-color-white);
    padding: var(--ktp-space-md) var(--ktp-space-lg);
    border-radius: var(--ktp-border-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    margin-bottom: var(--ktp-space-sm);
    opacity: 0;
    transform: translateY(20px); /* Initial hidden position */
    transition: opacity 0.3s var(--ktp-transition-timing), transform 0.3s var(--ktp-transition-timing);
    font-size: 14px;
    font-weight: 500;
}

/* State when the toast should be visible */
.ktp-toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* Success and Error Color Variations */
.ktp-toast-success {
    background-color: var(--ktp-color-success);
}

.ktp-toast-error {
    background-color: var(--ktp-color-error);
}
