/**
 * Global Modal & Shared Component Styles
 *
 * Shared styles for modals, buttons, forms, and animations
 * Used by both Feedback and Roadmap components
 *
 * @package Changeloger_Pro
 */

/* ========================================
   Animations
   ======================================== */

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

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

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(20px);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========================================
   Modal Overlay
   ======================================== */

.cha-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.cha-modal-overlay.active {
    display: flex;
    opacity: 1;
    animation: fadeIn 0.2s ease forwards;
}

.cha-modal-overlay.closing {
    animation: fadeOut 0.2s ease forwards;
}

/* ========================================
   Modal Container
   ======================================== */

.cha-modal {
    background: #fff;
    border-radius: 16px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: translateY(0);
    transition: transform 0.2s ease;
}

.cha-modal-sm {
    width: 400px;
    max-width: 95%;
}

.cha-modal-md {
    width: 500px;
    max-width: 95%;
}

.cha-modal-lg {
    width: 700px;
    max-width: 95%;
}

/* Detail Modal Animation */
.cha-feedback-detail-modal,
.cha-roadmap-detail-modal {
    animation: slideUp 0.2s ease forwards;
}

.cha-feedback-detail-modal.closing,
.cha-roadmap-detail-modal.closing {
    animation: slideDown 0.2s ease forwards;
}

/* ========================================
   Modal Header
   ======================================== */

.cha-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
}

.cha-modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
}

.cha-modal-close {
    padding: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    border-radius: 6px;
    transition: all 0.15s;
}

.cha-modal-close:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.cha-modal-close svg {
    width: 20px;
    height: 20px;
}

/* ========================================
   Modal Body & Footer
   ======================================== */

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

.cha-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}

/* ========================================
   Buttons
   ======================================== */

.cha-btn:is(button,a) {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.cha-btn:is(button,a):disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.cha-btn-primary:is(button,a) {
    background: var(--changeloger_brand_color);
    color: #fff;
}

.cha-btn-primary:is(button,a):hover:not(:disabled) {
    background: color-mix(in srgb, var(--changeloger_brand_color) 90%, #fff);
    color: #fff;
}

.cha-btn-primary:is(button,a):disabled {
    background: var(--changeloger_brand_color);
    color: #fff;
}

.cha-btn-secondary:is(button,a) {
    background: #fff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
}

.cha-btn-secondary:is(button,a):hover:not(:disabled) {
    background: #f8fafc;
}

.cha-btn-ghost:is(button,a) {
    background: transparent;
    color: #64748b;
    border: none;
}

.cha-btn-ghost:is(button,a):hover:not(:disabled) {
    background: #f1f5f9;
    color: #1e293b;
}

.cha-btn-sm:is(button,a) {
    padding: 6px 12px;
    font-size: 13px;
}

.cha-btn-lg:is(button,a) {
    padding: 12px 24px;
    font-size: 15px;
}

/* ========================================
   Form Elements
   ======================================== */

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

.cha-form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #1e293b;
}

.cha-form-group input,
.cha-form-group select,
.cha-form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.cha-form-group input:focus,
.cha-form-group select:focus,
.cha-form-group textarea:focus {
    outline: none;
    border-color: var(--changeloger_brand_color);
}

.cha-form-group textarea {
    resize: vertical;
    min-height: 100px;
}

/* ========================================
   Spinner / Loading
   ======================================== */

.cha-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--changeloger_brand_color);
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 1s linear infinite;
}

.cha-spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.cha-spinner-lg {
    width: 60px;
    height: 60px;
    border-width: 4px;
}

/* ========================================
   Auth Modal (Login/Register)
   ======================================== */

.cha-auth-modal {
    animation: slideUp 0.2s ease forwards;
}

.cha-auth-modal.closing {
    animation: slideDown 0.2s ease forwards;
}

/* ========================================
   Status Badges
   ======================================== */

.cha-status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.cha-status-badge.in-review {
    background: #fef3c7;
    color: #d97706;
}

.cha-status-badge.in-progress {
    background: #dbeafe;
    color: #2563eb;
}

.cha-status-badge.completed {
    background: #d1fae5;
    color: #059669;
}

.cha-status-badge.rejected {
    background: #fee2e2;
    color: #dc2626;
}

/* ========================================
   Avatar
   ======================================== */

.cha-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
}

.cha-avatar-sm {
    width: 20px;
    height: 20px;
}

.cha-avatar-md {
    width: 32px;
    height: 32px;
}

.cha-avatar-lg {
    width: 48px;
    height: 48px;
}

/* ========================================
   Responsive Modal
   ======================================== */

@media (max-width: 640px) {
    .cha-modal {
        margin: 16px;
        max-height: calc(100vh - 32px);
    }

    .cha-modal-md,
    .cha-modal-lg {
        width: 100%;
    }

    .cha-modal-footer {
        flex-direction: column-reverse;
    }

    .cha-modal-footer .cha-btn {
        width: 100%;
    }
}

/* ========================================
   Detail Sidebar (Shared for Feedback & Roadmap)
   ======================================== */

.cha-detail-sidebar {
    padding: 24px;
    background: #f8fafc;
    border-left: 1px solid #e2e8f0;
    overflow-y: auto;
}

.cha-sidebar-section {
    margin-bottom: 20px;
}

.cha-sidebar-section>label {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cha-upvoters-display {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cha-upvote-btn:is(button,a),
.cha-downvote-btn:is(button,a) {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    color: #64748b;
    padding: 0;
    transition: all 0.2s;
}

.cha-upvote-btn:is(button,a):hover:not(:disabled),
.cha-downvote-btn:is(button,a):hover:not(:disabled) {
    border-color: var(--changeloger_brand_color);
    color: var(--changeloger_brand_color);
    background-color: transparent;
}

.cha-upvote-btn.voted:is(button,a),
.cha-downvote-btn.voted:is(button,a),
.cha-downvote-btn.voted:hover:is(button,a) {
    background: var(--changeloger_brand_color);
    border-color: var(--changeloger_brand_color);
    color: #fff;
}

.cha-upvote-btn:is(button,a):disabled,
.cha-downvote-btn:is(button,a):disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.cha-upvote-btn svg,
.cha-downvote-btn svg {
    width: 18px;
    height: 18px;
}

.cha-upvote-count {
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
}

.cha-status-badge-detail {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.cha-board-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    color: #1e293b;
}

.cha-date-text {
    font-size: 14px;
    color: #475569;
}

.cha-author-display {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cha-author-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.cha-author-name {
    font-size: 14px;
    color: #1e293b;
    font-weight: 500;
}

.cha-comments-count {
    font-size: 14px;
    color: #475569;
}

/* Type Badge */
.cha-detail-type-badge {
    margin-bottom: 24px;
}

.cha-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #f0f9ff;
    border-radius: 6px;
    font-size: 12px;
    color: #0369a1;
}

.cha-type-badge.manual {
    background: #fef3c7;
    color: #b45309;
}

.cha-product-badge {
    display: inline-block;
    padding: 6px 12px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    color: #1e293b;
}

/* Responsive Detail Sidebar */
@media (max-width: 768px) {
    .cha-detail-layout {
        grid-template-columns: 1fr;
    }

    .cha-detail-sidebar {
        order: -1;
        border-left: none;
        border-bottom: 1px solid #e2e8f0;
    }

    .cha-detail-main {
        padding: 20px;
    }
}

/* ========================================
   Detail Modal (Shared for Feedback & Roadmap)
   ======================================== */

.cha-feedback-detail-modal,
.cha-roadmap-detail-modal {
    position: relative;
    width: 900px;
    max-width: 95%;
    max-height: 90vh;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.cha-detail-close:is(button,a) {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    color: #64748b;
    padding: 0;
    z-index: 10;
    transition: all 0.15s;
}

.cha-detail-close:is(button,a):hover {
    background: #e2e8f0;
    color: #1e293b;
}

.cha-detail-close svg {
    width: 18px;
    height: 18px;
}

.cha-detail-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    flex: 1;
    overflow: hidden;
}

.cha-detail-main {
    padding: 32px;
    overflow-y: auto;
}

.cha-detail-header {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}

.cha-detail-accent-bar {
    width: 4px;
    min-height: 100%;
    background: var(--changeloger_brand_color);
    border-radius: 2px;
    flex-shrink: 0;
}

.cha-detail-title {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.3;
    padding-top: 0 !important;
    margin-bottom: 0 !important;
}

.cha-detail-description {
    font-size: 15px;
    line-height: 1.7;
    color: #475569;
    margin-bottom: 24px;
}

.cha-detail-description p {
    margin: 0 0 12px;
}

.cha-no-description {
    color: #94a3b8;
    font-style: italic;
}
