/* ═══════════════════════════════════════════
   CoverGen Dialog & Toast Component System
   Based on pc-dialogs.html UI prototype
   Adapted for dark theme
   ═══════════════════════════════════════════ */

/* ─── Modal Overlay ─── */
.cg-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity .25s ease, visibility .25s ease;
}

.cg-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ─── Modal Container ─── */
.cg-modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .4);
    width: 100%;
    max-width: 420px;
    transform: scale(.96) translateY(4px);
    transition: transform .25s ease;
    position: relative;
    overflow: hidden;
}

.cg-modal-overlay.active .cg-modal {
    transform: scale(1) translateY(0);
}

.cg-modal.modal-lg {
    max-width: 560px;
}

.cg-modal.modal-sm {
    max-width: 360px;
}

/* ─── Modal Parts ─── */
.cg-modal-body {
    padding: 40px 40px 32px;
    text-align: center;
}

.cg-modal-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

.cg-modal-icon svg {
    width: 32px;
    height: 32px;
}

.cg-modal-icon.success {
    background: rgba(34, 197, 94, .15);
    color: var(--success);
}

.cg-modal-icon.error {
    background: rgba(239, 68, 68, .15);
    color: var(--error);
}

.cg-modal-icon.warning {
    background: rgba(245, 158, 11, .15);
    color: var(--warning);
}

.cg-modal-icon.info {
    background: rgba(59, 130, 246, .15);
    color: var(--info);
}

.cg-modal-icon.primary {
    background: var(--primary-alpha);
    color: var(--primary);
}

.cg-modal-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.3;
}

.cg-modal-desc {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 28px;
}

.cg-modal-actions {
    display: flex;
    gap: 10px;
}

.cg-modal-actions .cg-btn {
    flex: 1;
}

.cg-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: background .15s, color .15s;
}

.cg-modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.cg-modal-close svg {
    width: 16px;
    height: 16px;
}

/* ─── Dialog Buttons ─── */
.cg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    padding: 13px 20px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: background .15s, opacity .15s, transform .15s;
}

.cg-btn:hover {
    transform: translateY(-1px);
}

.cg-btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(255, 107, 53, .25);
}

.cg-btn-primary:hover {
    background: var(--primary-dark);
}

.cg-btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.cg-btn-secondary:hover {
    background: var(--bg-hover);
}

.cg-btn-danger {
    background: var(--error);
    color: #fff;
}

.cg-btn-danger:hover {
    opacity: .9;
}

/* ─── Loading Spinner ─── */
.cg-spinner {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 4px solid var(--bg-hover);
    border-top-color: var(--primary);
    animation: cg-spin .8s linear infinite;
    margin: 0 auto 20px;
}

@keyframes cg-spin {
    to {
        transform: rotate(360deg);
    }
}

.cg-progress-wrap {
    background: var(--bg-hover);
    border-radius: 9999px;
    height: 6px;
    margin: 20px 0 28px;
    overflow: hidden;
}

.cg-progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 9999px;
    width: 0%;
    animation: cg-progress 1.8s ease-in-out infinite;
}

@keyframes cg-progress {
    0% {
        width: 15%;
    }

    50% {
        width: 75%;
    }

    100% {
        width: 15%;
    }
}

/* ─── Form Modal Overrides ─── */
.cg-modal-form-body {
    padding: 32px 40px 32px;
    text-align: left;
}

.cg-modal-form-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.cg-modal-form-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.cg-form-field {
    margin-bottom: 16px;
}

.cg-form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    display: block;
}

.cg-form-input {
    width: 100%;
    padding: 11px 14px;
    font-size: 14px;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text-primary);
    transition: border-color .15s;
    outline: none;
}

.cg-form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-alpha);
}

.cg-form-input::placeholder {
    color: var(--text-muted);
}

.cg-form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.cg-form-row {
    display: flex;
    gap: 12px;
}

.cg-form-row .cg-form-field {
    flex: 1;
}

.cg-modal-form-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
}

.cg-modal-form-actions .cg-btn {
    flex: 1;
}

/* ─── Rate Limit ─── */
.cg-rate-countdown {
    font-size: 36px;
    font-weight: 800;
    color: var(--text-primary);
    margin: 8px 0 4px;
}

.cg-rate-plan-tip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--primary-alpha);
    border: 1px solid rgba(255, 107, 53, .2);
    border-radius: 8px;
    padding: 10px 14px;
    margin: 20px 0;
    text-align: left;
}

.cg-rate-plan-tip svg {
    width: 16px;
    height: 16px;
    color: var(--primary);
    flex-shrink: 0;
}

.cg-rate-plan-tip-text {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ─── Geo-block ─── */
.cg-geo-flag {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(239, 68, 68, .15);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 32px;
}

.cg-geo-alt-note {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 12px;
    text-align: center;
}

.cg-geo-alt-note a {
    color: var(--primary);
    cursor: pointer;
}

/* ─── Maintenance ─── */
.cg-maintenance-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--bg-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

.cg-maintenance-icon svg {
    width: 40px;
    height: 40px;
    color: var(--text-muted);
}

.cg-maintenance-bar {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0 0 28px;
    text-align: left;
}

.cg-maintenance-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.cg-maintenance-row .service {
    color: var(--text-secondary);
}

.cg-maintenance-row .status {
    font-weight: 600;
    color: var(--warning);
}

.cg-maintenance-row .status.ok {
    color: var(--success);
}

/* ─── Upgrade Prompt ─── */
.cg-upgrade-box {
    background: var(--bg-hover);
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 24px;
    text-align: left;
}

.cg-upgrade-box-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.cg-upgrade-box-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.cg-upgrade-box-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ─── Toast ─── */
.cg-toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    z-index: 99999;
    pointer-events: none;
}

.cg-toast {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #0A0A0A;
    color: #fff;
    padding: 11px 18px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .3);
    animation: cg-toastIn .25s ease forwards;
    pointer-events: all;
}

.cg-toast.success {
    background: #166534;
}

.cg-toast.error {
    background: #991B1B;
}

.cg-toast.warning {
    background: #92400E;
}

.cg-toast svg {
    width: 16px;
    height: 16px;
}

@keyframes cg-toastIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cg-toast.fade-out {
    animation: cg-toastOut .2s ease forwards;
}

@keyframes cg-toastOut {
    to {
        opacity: 0;
        transform: translateY(4px);
    }
}

/* ─── Responsive ─── */
@media (max-width: 600px) {

    .cg-modal-body,
    .cg-modal-form-body {
        padding: 28px 24px 24px;
    }

    .cg-modal-form-actions .cg-btn,
    .cg-modal-actions .cg-btn {
        padding: 12px 14px;
        font-size: 14px;
    }
}