/**
 * Modern UI Styles
 * Replaces obsolete jQuery plugin styles with clean, modern CSS
 */

/* Character Counter */
.char-counter {
    font-size: 12px;
    color: #666;
    margin-top: 4px;
    transition: color 0.2s ease;
}

.char-counter.warning {
    color: #d32323;
}

/* Native Color Picker Enhancement */
input[type="color"] {
    height: 40px;
    width: 60px;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

input[type="color"]:hover {
    border-color: #999;
}

.color-hex-input {
    width: 80px;
    margin-left: 8px;
    font-family: 'Courier New', monospace;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

/* Native Time Picker */
input[type="time"] {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

input[type="time"]:focus {
    outline: none;
    border-color: #6b7280;
    box-shadow: 0 0 0 3px rgba(107, 114, 128, 0.15);
}

/* Modern Dialog/Modal */
dialog.modern-dialog {
    border: none;
    border-radius: 8px;
    padding: 0;
    max-width: 600px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: dialogFadeIn 0.2s ease;
}

dialog.modern-dialog::backdrop {
    background: rgba(0, 0, 0, 0.5);
    animation: backdropFadeIn 0.2s ease;
}

.dialog-content {
    padding: 20px;
    position: relative;
}

.dialog-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.dialog-close:hover {
    background: #f5f5f5;
    color: #333;
}

/* Image Gallery Dialog */
dialog.image-gallery-dialog {
    border: none;
    padding: 20px;
    background: rgba(0, 0, 0, 0.95);
    max-width: none;
    max-height: none;
}

dialog.image-gallery-dialog::backdrop {
    background: rgba(0, 0, 0, 0.9);
}

dialog.image-gallery-dialog img {
    max-width: 90vw;
    max-height: 90vh;
    display: block;
}

dialog.image-gallery-dialog .dialog-close {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 30px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    width: 45px;
    height: 45px;
    backdrop-filter: blur(10px);
}

dialog.image-gallery-dialog .dialog-close:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

/* Tooltips */
[data-tooltip] {
    position: relative;
    cursor: help;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 13px;
    white-space: nowrap;
    z-index: 1000;
    margin-bottom: 8px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

[data-tooltip]::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    margin-bottom: 2px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

[data-tooltip]:hover::after,
[data-tooltip]:hover::before {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

/* Tree View (using <details>) */
[data-tree] details {
    margin-left: 20px;
}

[data-tree] summary {
    cursor: pointer;
    user-select: none;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

[data-tree] summary:hover {
    background: #f5f5f5;
}

[data-tree] summary::marker {
    color: #6b7280;
}

[data-tree] details[open] > summary {
    margin-bottom: 8px;
}

/* Image Gallery Grid */
[data-gallery] {
    display: inline-block;
    position: relative;
    overflow: hidden;
    border-radius: 4px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

[data-gallery]:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

[data-gallery] img {
    display: block;
    transition: transform 0.2s ease;
}

[data-gallery]:hover img {
    transform: scale(1.05);
}

/* Animations */
@keyframes dialogFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes backdropFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Form Field Enhancements */
input[type="text"][data-maxlength],
textarea[data-maxlength] {
    transition: border-color 0.2s ease;
}

input[type="text"][data-maxlength]:focus,
textarea[data-maxlength]:focus {
    border-color: #6b7280;
    box-shadow: 0 0 0 3px rgba(107, 114, 128, 0.15);
}

/* Password Strength Indicator (modern replacement) */
.password-strength {
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}

.password-strength-bar {
    height: 100%;
    transition: width 0.3s ease, background-color 0.3s ease;
    border-radius: 2px;
}

.password-strength-bar.weak {
    width: 33%;
    background: #d32323;
}

.password-strength-bar.medium {
    width: 66%;
    background: #ff9800;
}

.password-strength-bar.strong {
    width: 100%;
    background: #4caf50;
}

/* ── Rich Textarea ── */
.rich-textarea {
    display: block;
    width: 100%;
    min-height: 160px;
    padding: 14px 16px;
    border: 1px solid #e2e5e9;
    border-radius: 10px;
    background: #fff;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    font-size: 14.5px;
    line-height: 1.7;
    color: #1a1d23;
    caret-color: #3b82f6;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

.rich-textarea:focus {
    border-color: #a0aec0;
    box-shadow: 0 0 0 3px rgba(66, 82, 110, 0.08);
}

.rich-textarea::placeholder {
    color: #c4c9d0;
    font-style: italic;
}

/* Scrollbar */
.rich-textarea::-webkit-scrollbar { width: 5px; }
.rich-textarea::-webkit-scrollbar-track { background: transparent; }
.rich-textarea::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

/* Admin panel rich textarea */
.form-control.rich-textarea {
    border-radius: 10px;
}

@media (max-width: 640px) {
    .rich-textarea { padding: 12px 14px; min-height: 120px; font-size: 14px; }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    dialog.modern-dialog {
        max-width: 90vw;
        margin: auto;
    }

    [data-tooltip]::after {
        white-space: normal;
        max-width: 200px;
    }
}
