/**
 * reNotes - Frontend Styles
 * @package     ReDim.Renotes
 * @copyright   (C) 2025 reDim GmbH
 *
 * Layout & Styling für Vanilla JS Modal (Fallback)
 */

/* ============================================
   CSS Custom Properties (Design Tokens)
   ============================================ */

:root {
    /* Loading Overlay */
    --rc-loading-bg: rgba(0, 0, 0, 0.85);
    --rc-loading-spinner: #fff;
    --rc-loading-spinner-track: rgba(255, 255, 255, 0.3);
    --rc-loading-text: #fff;

    /* Modal Colors */
    --rc-modal-bg: #fff;
    --rc-modal-overlay: rgba(0, 0, 0, 0.5);
    --rc-modal-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    --rc-modal-border: #e5e5e5;
    --rc-modal-title: #333;
    --rc-modal-text: #555;
    --rc-modal-close: #999;
    --rc-modal-close-hover: #333;

    /* Status Colors */
    --rc-success: #28a745;
    --rc-error: #dc3545;
    --rc-warning: #ffc107;
    --rc-info: #17a2b8;

    /* Button Colors */
    --rc-btn-primary: #007bff;
    --rc-btn-primary-hover: #0056b3;

    /* Avatar */
    --rc-avatar-text: #fff;
}

/* ============================================
   Checkbox-Gruppe: Checkbox links, Label rechts
   ============================================ */
.renotes-form,
.renotes-reply-container {
    max-width: 600px;
    margin: 1em 0;
}

.renotes-checkbox-group {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.renotes-wrapper .renotes-checkbox-group .control-label label {
    cursor: pointer !important;
}

.altcha-main input[type="checkbox"] {
    cursor: pointer !important;
}

.renotes-checkbox-group .controls {
    order: -1;
    flex: 0 0 auto;
}

.renotes-checkbox-group .control-label {
    flex: 1 1 auto;
}

.renotes-checkbox-group .form-check-inline {
    margin-right: 0 !important;
}

/* ============================================
   Loading Overlay & Spinner Animation
   ============================================ */

.renotes-loading {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 99998;
    animation: renotesLoadingFadeIn 0.25s ease;
    background: var(--rc-loading-bg);
}

.renotes-spinner {
    width: 48px;
    height: 48px;
}

.renotes-spinner-ring {
    width: 100%;
    height: 100%;
    border-width: 4px;
    border-style: solid;
    border-color: var(--rc-loading-spinner-track);
    border-top-color: var(--rc-loading-spinner);
    border-radius: 50%;
    animation: renotesSpinnerRotate 0.9s cubic-bezier(0.5, 0.1, 0.5, 0.9) infinite;
}

.renotes-loading-text {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--rc-loading-text);
}

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

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

.renotes-loading.fade-out {
    animation: renotesLoadingFadeOut 0.3s ease forwards;
}

@keyframes renotesLoadingFadeOut {
    to { opacity: 0; }
}

/* ============================================
   Comment List Styling
   ============================================ */

/* Liste ohne Bullets */
.renotes-list,
.renotes-replies,
.renotes-wrapper .renotes-list,
.renotes-wrapper .renotes-replies {
    list-style: none !important;
    list-style-type: none !important;
    /*padding-left: 0 !important;
    margin: 0 !important;*/
}

.renotes-item,
.renotes-wrapper .renotes-item {
    list-style: none !important;
    list-style-type: none !important;
}

/* Abstände zwischen Kommentaren */
.renotes-item {
    padding: 1.25rem 0;
    margin-bottom: 0;
}

.renotes-item:last-child {
    border-bottom: none;
}

/* Nested Replies */
.renotes-replies {
    margin-left: 2.5rem;
    margin-top: 0.5rem;
    padding-left: 1rem;
}

/* ============================================
   Meta-Bereich: Name + Zeit
   ============================================ */

.renotes-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.renotes-author {
    font-weight: 600;
    font-size: 0.95rem;
}

.renotes-date {
    font-size: 0.8rem;
}

.renotes-date::before {
    content: "•";
    margin-right: 0.5rem;
}

.renotes-edited {
    font-size: 0.75rem;
    font-style: italic;
}

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

.renotes-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.renotes-avatar-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    z-index: 2;
}

.renotes-avatar-initials {
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--rc-avatar-text);
    text-transform: uppercase;
    border-radius: 50%;
    z-index: 1;
}

/* ============================================
   Comment Layout
   ============================================ */

.renotes-item-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.renotes-content {
    line-height: 1.6;
    margin-bottom: 0.75rem;
}

.renotes-actions {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
}

.renotes-action {
    background: none;
    border: none;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.renotes-action:hover {
    opacity: 0.7;
}

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

@media (max-width: 640px) {
    .renotes-replies {
        margin-left: 1rem;
        padding-left: 0.75rem;
    }
}

/* ============================================
   Vanilla Modal (Fallback wenn kein Framework)
   ============================================ */

.renotes-modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--rc-modal-overlay);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.renotes-modal-overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

.renotes-modal-dialog {
    background: var(--rc-modal-bg);
    border-radius: 12px;
    max-width: 400px;
    width: 100%;
    box-shadow: var(--rc-modal-shadow);
    transform: scale(0.9) translateY(-20px);
    transition: transform 0.2s ease;
    overflow: hidden;
}

.renotes-modal-overlay.is-visible .renotes-modal-dialog {
    transform: scale(1) translateY(0);
}

.renotes-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--rc-modal-border);
}

.renotes-modal-title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--rc-modal-title);
}

.renotes-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--rc-modal-close);
    cursor: pointer;
    padding: 0.25rem;
    transition: color 0.15s ease;
}

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

.renotes-modal-body {
    padding: 2rem 1.25rem;
    text-align: center;
}

.renotes-modal-icon {
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
}

.renotes-modal-icon svg {
    width: 56px;
    height: 56px;
}

/* Icon-Farben nach Typ */
.renotes-modal--success .renotes-modal-icon { color: var(--rc-success); }
.renotes-modal--error .renotes-modal-icon { color: var(--rc-error); }
.renotes-modal--warning .renotes-modal-icon { color: var(--rc-warning); }
.renotes-modal--info .renotes-modal-icon { color: var(--rc-info); }

.renotes-modal-message {
    margin: 0;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--rc-modal-text);
}

.renotes-modal-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--rc-modal-border);
    display: flex;
    justify-content: center;
}

.renotes-modal-btn {
    background: var(--rc-btn-primary);
    color: var(--rc-avatar-text);
    border: none;
    padding: 0.625rem 2rem;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease;
}

.renotes-modal-btn:hover {
    background: var(--rc-btn-primary-hover);
}

.renotes-modal-btn:focus {
    outline: 2px solid var(--rc-btn-primary);
    outline-offset: 2px;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --rc-modal-bg: #2d2d2d;
        --rc-modal-title: #f0f0f0;
        --rc-modal-border: #444;
        --rc-modal-text: #ccc;
        --rc-modal-close: #888;
        --rc-modal-close-hover: #f0f0f0;
    }
}
