/**
 * Title Styles - For All Users
 * Font: IBM Plex Sans Thai
 */

/* Import IBM Plex Sans Thai font */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Thai:wght@400;500;600;700&display=swap');

/* Title wrapper */
.editable-title-wrapper-kxp728 {
    position: relative;
    margin: 20px 0;
}

/* Base title styles - Applied to BOTH editable and non-editable */
.editable-title-kxp728,
.post-title-display-kxp728 {
    font-family: 'IBM Plex Sans Thai', sans-serif !important;
    font-size: 2.5em !important;
    line-height: 1.2 !important; /* Tighter line height */
    font-weight: 600 !important;
    color: #222;
    margin: 0;
    padding: 8px 8px;
    border-radius: 4px;
    white-space: pre-line !important; /* Better for line breaks */
    word-wrap: break-word;
    word-break: break-word;
    display: block;
}

/* Non-editable title (for regular users) */
.post-title-display-kxp728 {
    padding: 0;
    background: transparent;
    border: none;
}

/* Control line break spacing specifically */
.post-title-display-kxp728 br,
.editable-title-kxp728 br {
    display: block !important;
    content: "" !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 0.5 !important; /* Reduce space between lines */
    height: 0 !important;
}

/* Remove any extra spacing from empty lines */
.post-title-display-kxp728 br + br,
.editable-title-kxp728 br + br {
    display: none !important; /* Hide consecutive br tags */
}

/* Editable specific styles (admin only) */
.editable-title-kxp728 {
    border: 2px dashed #ccc;
    cursor: text;
    outline: none;
    position: relative;
    background-color: rgba(255, 255, 255, 0.5);
    transition: all 0.3s ease;
}

/* Hover state (admin only) */
.editable-title-kxp728:hover {
    background-color: rgba(0, 123, 255, 0.05);
    border-color: rgba(0, 123, 255, 0.5);
}

/* Focus/editing state (admin only) */
.editable-title-kxp728:focus,
.editable-title-kxp728.editing-kxp728 {
    background-color: rgba(0, 123, 255, 0.08);
    border-color: #007bff;
    border-style: solid;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
}

/* Edit hint (admin only) */
.edit-hint-kxp728 {
    display: inline-block;
    margin-top: 5px;
    font-family: 'IBM Plex Sans Thai', sans-serif;
    font-size: 12px;
    color: #666;
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.editable-title-kxp728:hover ~ .edit-hint-kxp728 {
    opacity: 0.8;
}

/* Status messages (admin only) */
.edit-status-kxp728 {
    margin-top: 8px;
    font-family: 'IBM Plex Sans Thai', sans-serif;
    font-size: 14px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 4px;
    opacity: 0;
    transition: all 0.3s ease;
    display: inline-block;
    position: relative;
}

/* Status states with animation */
.edit-status-kxp728.status-saving-kxp728 {
    background-color: #ffc107;
    color: #856404;
    opacity: 1;
    animation: pulse 1.5s infinite;
}

.edit-status-kxp728.status-success-kxp728 {
    background-color: #28a745;
    color: white;
    opacity: 1;
    animation: slideIn 0.3s ease;
}

.edit-status-kxp728.status-error-kxp728 {
    background-color: #dc3545;
    color: white;
    opacity: 1;
    animation: shake 0.5s;
}

/* Animations */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes slideIn {
    from { 
        transform: translateY(-10px);
        opacity: 0;
    }
    to { 
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Mobile responsive */
@media (max-width: 768px) {
    .editable-title-kxp728,
    .post-title-display-kxp728 {
        font-size: 1.8em !important;
        padding: 6px 10px;
    }
    
    .post-title-display-kxp728 {
        padding: 0;
    }
    
    .edit-status-kxp728 {
        font-size: 12px;
        padding: 4px 8px;
    }
    
    .edit-hint-kxp728 {
        font-size: 11px;
    }
}

/* Tablet responsive */
@media (max-width: 1024px) and (min-width: 769px) {
    .editable-title-kxp728,
    .post-title-display-kxp728 {
        font-size: 2.2em !important;
    }
}

/* Accessibility - Focus visible */
.editable-title-kxp728:focus-visible {
    outline: 3px solid #007bff;
    outline-offset: 2px;
}

/* Loading indicator for saving state */
.editable-title-kxp728.saving-kxp728 {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.editable-title-kxp728.saving-kxp728::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 10px;
    width: 10px;
    height: 10px;
    margin-top: -8px;
    border: 2px solid #007bff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Print styles */
@media print {
    .editable-title-kxp728,
    .post-title-display-kxp728 {
        border: none !important;
        background: none !important;
        box-shadow: none !important;
        font-family: 'IBM Plex Sans Thai', sans-serif !important;
    }
    
    .edit-status-kxp728,
    .edit-hint-kxp728 {
        display: none !important;
    }
}

/* Ensure font loads properly */
body .editable-title-kxp728,
body .post-title-display-kxp728 {
    font-family: 'IBM Plex Sans Thai', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
}