/* ==========================================================================
   CRUD UI: MODALS, FORMS, BUTTONS & ACTIONS
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.92rem;
    cursor: pointer;
    border: 1px solid var(--line);
    transition: all 150ms ease;
    background: var(--panel-strong);
    color: var(--ink);
    text-decoration: none;
}

.btn:hover {
    background: #fff8dc;
    border-color: var(--accent);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--accent);
    color: #fff9dc;
    border-color: #5c3010;
}

.btn-primary:hover {
    background: #61330e;
    color: #ffffff;
}

.btn-danger {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fca5a5;
}

.btn-danger:hover {
    background: #fecaca;
    color: #7f1d1d;
    border-color: #f87171;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.82rem;
    border-radius: 6px;
}

/* Header bar with Actions */
.header-with-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.header-actions-group {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* Add Rule Quick Form */
.quick-add-bar {
    display: flex;
    gap: 10px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.45);
}

.quick-add-input {
    flex: 1;
    padding: 9px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fffef8;
    font-size: 0.95rem;
    color: var(--ink);
}

.quick-add-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(122, 66, 22, 0.15);
}

/* Item Action Controls */
.item-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 8px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--ink-soft);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 120ms ease;
}

.icon-btn:hover {
    background: rgba(122, 66, 22, 0.1);
    color: var(--ink);
    border-color: var(--line);
}

.icon-btn-delete:hover {
    background: #fee2e2;
    color: #b91c1c;
    border-color: #fca5a5;
}

/* Modal Popup */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(36, 20, 7, 0.65);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-dialog {
    background: #fffdf5;
    border: 2px solid var(--accent);
    border-radius: 14px;
    width: min(100%, 38rem);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 48px -12px rgba(36, 20, 7, 0.45);
    transform: scale(0.94);
    transition: transform 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal-dialog {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 246, 210, 0.5);
    border-radius: 12px 12px 0 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--ink);
}

.modal-close {
    background: transparent;
    border: 0;
    font-size: 1.6rem;
    cursor: pointer;
    color: var(--ink-soft);
    line-height: 1;
    padding: 0 4px;
}

.modal-close:hover {
    color: var(--ink);
}

.modal-body {
    padding: 20px 24px;
    overflow-y: auto;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-weight: 700;
    font-size: 0.88rem;
    margin-bottom: 6px;
    color: var(--ink);
}

.form-group .form-hint {
    display: block;
    font-size: 0.8rem;
    color: var(--ink-soft);
    margin-top: 4px;
}

.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #ffffff;
    font-size: 0.95rem;
    color: var(--ink);
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(122, 66, 22, 0.18);
}

textarea.form-control {
    min-height: 80px;
    resize: vertical;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--line);
    background: rgba(255, 246, 210, 0.3);
    border-radius: 0 0 12px 12px;
}

/* YouTube Thumbnail Player Card */
.yt-preview-card {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 8px 24px -6px rgba(0, 0, 0, 0.3);
}

.yt-preview-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.88;
    transition: opacity 150ms ease, transform 150ms ease;
}

.yt-preview-card:hover .yt-preview-thumb {
    opacity: 1;
    transform: scale(1.02);
}

.yt-play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 68px;
    height: 48px;
    background: #ff0000;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    transition: transform 150ms ease, background 150ms ease;
}

.yt-play-btn svg {
    fill: #ffffff;
    width: 20px;
    height: 20px;
    margin-left: 2px;
}

.yt-preview-card:hover .yt-play-btn {
    transform: translate(-50%, -50%) scale(1.1);
    background: #cc0000;
}

/* ==========================================================================
   INLINE CLICK-TO-EDIT (NOTION STYLE)
   ========================================================================== */

/* Banner thông báo chế độ chỉnh sửa */
.edit-mode-banner {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    margin-bottom: 16px;
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 10px;
    color: #92400e;
    font-size: 0.92rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.15);
    animation: fadeInDown 200ms ease;
}

.is-editing .edit-mode-banner {
    display: flex;
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Các trường khi bật chế độ sửa */
.is-editing [contenteditable="true"] {
    outline: 1.5px dashed rgba(180, 83, 9, 0.45);
    border-radius: 4px;
    padding: 2px 6px;
    background: rgba(254, 243, 199, 0.4);
    cursor: text;
    transition: all 120ms ease;
}

.is-editing [contenteditable="true"]:hover {
    background: rgba(254, 243, 199, 0.85);
    outline-color: #d97706;
}

.is-editing [contenteditable="true"]:focus {
    outline: 2px solid var(--accent);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(122, 66, 22, 0.15);
}

/* Overlay đổi ảnh bìa khi đang sửa */
.cover-wrapper-editable {
    position: relative;
    cursor: pointer;
}

.cover-change-btn {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(36, 20, 7, 0.75);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 8px;
    border-radius: 6px;
    backdrop-filter: blur(2px);
    transition: opacity 150ms ease;
}

.is-editing .cover-wrapper-editable:hover .cover-change-btn {
    display: flex;
}

/* Video input bar khi đang sửa */
.edit-video-bar {
    display: none;
    margin-bottom: 12px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px dashed var(--accent);
    border-radius: 8px;
}

.is-editing .edit-video-bar {
    display: block;
}

/* Nút lưu nổi bật */
.btn-save-glow {
    background: #15803d !important;
    color: #ffffff !important;
    border-color: #166534 !important;
    box-shadow: 0 0 10px rgba(22, 163, 74, 0.4);
}

.btn-save-glow:hover {
    background: #166534 !important;
}

