/* Customizable Variables for Fine-Tuning */
:root {
    /* Colors */
    --primary-green: #198754;
    --accent-green: #80c684;
    --light-gray: #f8f9fa;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --simpleevent-border: #28a545;
    --referendum-border: #fb7e14;
    --multi_poll-border: #17cbea;

    /* Sizes */
    --card-width: 360px;
    --card-height: 400px;
    --image-height: 160px;
    --title-font-size: 1.1rem;
    --author-avatar-size: 34px;
    --delete-btn-size: 24px;
    --btn-custom-font-size: 0.85rem;

    /* Spacing */
    --card-padding: 0.5rem;
    --section-gap: 0.75rem;
    --image-padding: 3px;

    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Keyframe Animations */
@keyframes slideInFromTop {
    0% { transform: translateY(-20px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: var(--shadow-sm); }
    50% { box-shadow: var(--shadow-md); }
}

@keyframes fadeInScale {
    from {
        transform: scale(0.95);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Event Container */
.event-container {
    display: flex;
    justify-content: center;
    margin: 1rem 0;
}

.event-container.loaded {
    animation: slideInFromTop 0.6s ease-out;
}

/* Event Card */
.event-card {
    position: relative;
    width: var(--card-width);
    height: var(--card-height);
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden; /* За particles background */
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    font-family: 'Inter', sans-serif;
    padding: 15px;
}

/* Override за list view */
.event-list-item .event-card {
    width: 100% !important;
    height: auto !important;
    max-width: none !important;
}

.event-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(37, 175, 180, 0.2);
    animation: pulseGlow 1.5s infinite;
}

/* Particles background в event картите */
.event-card.particles-background-wrapper {
    position: relative;
    overflow: hidden;
}

.event-card .particles-background {
    z-index: 0;
    opacity: 0.6; /* По-лек ефект за картите */
}

.event-card > *:not(.particles-background):not(.type-label):not(.btn-danger):not(:has(.btn-danger)) {
    position: relative;
    z-index: 1;
}

/* Border Styles for Event Types */
.event-card.border-simpleevent { border: 2px solid var(--simpleevent-border); }
.event-card.border-referendum { border: 2px solid var(--referendum-border); }
.event-card.border-multi_poll { border: 2px solid var(--multi_poll-border); }

/* Type Label - специално правило за да не се прецаква от particles-background */
.event-card .type-label {
    position: absolute !important;
    top: 0;
    left: 0;
    padding: 1px 14px 1px 16px;
    border-radius: 3px;
    font-size: 0.55rem;
    font-weight: 100;
    color: #fff;
    z-index: 10 !important;
    transition: transform 0.3s ease;
}

.type-label:hover {
    transform: scale(1.05);
}

.type-label-simpleevent { background: linear-gradient(45deg, #28a545, #57ec78); }
.type-label-referendum { background: linear-gradient(45deg, #fb7e14, #fca967); }
.type-label-multi_poll { background: linear-gradient(45deg, #17cbea, #7ed4e3); }

/* Delete Button Container - специално правило за да не се прецаква */
.event-card > div:has(.btn-danger) {
    position: absolute !important;
    top: -2px;
    right: -2px;
    z-index: 100 !important;
    pointer-events: none;
}

.event-card > div:has(.btn-danger) .btn-danger {
    pointer-events: auto;
}

/* Delete Button - специално правило за да не се прецаква от particles-background */
.event-card .btn-danger {
    background: rgba(220, 53, 69, 0.9) !important;
    color: #ffffff !important;
    border: 2px solid rgba(255, 255, 255, 0.8) !important;
    border-radius: 50%;
    width: var(--delete-btn-size);
    height: var(--delete-btn-size);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    transition: all 0.3s ease;
    position: relative !important;
    z-index: 100 !important;
    padding: 0;
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.4);
    cursor: pointer;
}

.event-card .btn-danger:hover {
    background: rgba(220, 53, 69, 1) !important;
    color: #ffffff !important;
    transform: scale(1.2);
    border-color: rgba(255, 255, 255, 1) !important;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.6);
}

/* Progress Bars for Stats */
.stat-with-progress {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    max-width: 120px;
}

.progress-bar-mini {
    flex: 1;
    height: 4px;
    background: #e9ecef;
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #228e55);
    border-radius: 2px;
    transition: width 0.6s ease;
    width: 0%;
}


/* Event Image Container */
.event-image-container {
    width: 100%;
    height: var(--image-height);
    overflow: hidden;
    border-radius: 10px;
    padding: var(--image-padding);
    position: relative;
    z-index: 1; /* По-нисък от бутона за изтриване */
}

.event-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    border-radius: 7px;
    transition: transform 0.4s ease;
}

.event-image:hover {
    transform: scale(1.05);
}

.event-image.default-logo {
    object-fit: contain;
    background: #ffffff;
    padding: 1rem;
}

/* Card Body */
.card-body {
    padding: var(--card-padding);
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--section-gap);
}

/* Event Title */
.card-title {
    font-size: var(--title-font-size);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
    padding: 0 10px;
    background: linear-gradient(90deg, rgba(37, 175, 180, 0.05), rgba(255, 255, 255, 0.95));
    border-bottom: 1px solid var(--accent-green);
    transition: transform 0.3s ease;
    position: relative;
    cursor: help;
}

.card-title:hover {
    transform: translateX(3px);
}

/* Author and Date Block */
.author-date-block {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px 5px;
    border-radius: 6px;
    background: #f3f3f3;
    box-shadow: var(--shadow-sm);
}

.author-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.author-avatar {
    width: var(--author-avatar-size);
    height: var(--author-avatar-size);
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid var(--accent-green);
    transition: transform 0.3s ease;
}

/* Placeholder avatar (DIV с инициали) */
.author-avatar.avatar-placeholder {
    width: var(--author-avatar-size);
    height: var(--author-avatar-size);
    border-radius: 50%;
    border: 2px solid var(--accent-green);
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: 700;
    font-size: 14px;
    text-transform: uppercase;
    flex-shrink: 0;
    text-decoration: none !important;
}

/* Премахва подчертаването от родителския <a> таг за placeholder аватари */
.author-info > a .avatar-placeholder {
    text-decoration: none !important;
}

/* Премахва подчертаването от <a> таговете, които съдържат placeholder аватари */
.author-info > a:has(.avatar-placeholder) {
    text-decoration: none !important;
    border: none !important;
    outline: none !important;
}

/* Fallback за браузъри без поддръжка на :has() */
.author-info a[href="javascript:void(0);"] .avatar-placeholder {
    text-decoration: none !important;
}

.author-info a[href="javascript:void(0);"] {
    text-decoration: none !important;
}

.author-avatar:hover,
.author-avatar.avatar-placeholder:hover {
    transform: scale(1.1);
}

.author-info .fw-bold {
    font-size: 0.85rem;
    color: var(--text-primary);
    margin: 0;
}

.author-info .text-muted {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.date-info {
    text-align: right;
}

.date-info .fw-bold,
.date-info .text-muted {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Online/Offline Status */
.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 0.25rem;
}

.bg-success { background: var(--primary-green); }
.bg-danger { background: #dc3545; }

/* Event Stats */
.event-stats {
    padding: 0 5px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: var(--shadow-sm);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.stat-item:last-child {
    margin-bottom: 0;
}

.stat-item .fw-bold {
    color: var(--text-primary);
}

/* Custom Button */
.btn-custom {
    background: linear-gradient(45deg, var(--accent-green), var(--primary-green));
    color: #fff;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: none;
    font-size: var(--btn-custom-font-size);
    font-weight: 600;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    width: fit-content;
    align-self: flex-start;
}

.btn-custom::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: transform 0.4s ease;
}

.btn-custom:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 175, 180, 0.3);
    color: white;
}

.btn-custom:hover::before {
    transform: translateX(100%);
}

/* Delete Modal */
.custom-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
    z-index: 1500;
    display: none;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;

}

.custom-modal.active {
    opacity: 1;
}

.custom-modal-dialog {
    max-width: 500px;
    width: 100%;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
    animation: fadeInScale 0.3s ease-in-out;
}

/*.custom-modal.active .custom-modal-dialog {*/
/*    transform: scale(1);*/
/*}*/

.custom-modal-content {
    padding: 1.5rem;
    border-radius: 16px;
    background: #fff;
}

.custom-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: none;
    padding: 1rem 1.5rem;
    background: #f8f9fa;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
}

.custom-modal-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 900;
    color: #ad4747;
}

.custom-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #333;
    line-height: 1;
    filter: grayscale(1);
    transition: filter 0.2s ease;
}

.custom-modal-close:hover {
    color: #000;
    filter: none;
}

.custom-modal-body {
    padding: 1.5rem;
    font-size: 0.8rem;
    color: #333;
}

.custom-modal-footer {
    display: flex;
    justify-content: center;
    gap: 40px;
    border-top: none;
    padding: 1rem 1.5rem;
    background: #f8f9fa;
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 16px;
}

.custom-btn {
    padding: 6px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 100;
    transition: background-color 0.2s ease;
}

.custom-btn-secondary {
    background: #6c757d;
    color: #fff;
}

.custom-btn-secondary:hover {
    background: #5a6268;
}

.custom-btn-danger {
    background: #dc3545;
    color: #fff;
}

.custom-btn-danger:hover {
    background: rgba(200, 35, 51, 0.18);
}

/* Responsive Adjustments */
@media (max-width: 576px) {
    .event-card {
        width: 100%;
        height: 460px;
    }

    .event-image-container {
        height: calc(var(--image-height) - 20px);
    }

    .author-avatar {
        width: calc(var(--author-avatar-size) - 4px);
        height: calc(var(--author-avatar-size) - 4px);
    }

    .author-info .fw-bold,
    .date-info .fw-bold,
    .stat-item .fw-bold {
        font-size: 0.8rem;
    }

    .author-info .text-muted,
    .date-info .text-muted,
    .stat-item {
        font-size: 0.7rem;
    }

    .btn-custom {
        font-size: calc(var(--btn-custom-font-size) - 0.05rem);
        padding: 0.4rem 0.9rem;
    }
}