/* ===========================================================================
   Program Notes – стилове (Glassmorphism, светла тема, напълно адаптивен)
   =========================================================================== */

:root {
    /* Акцентни цветове (меко лилаво/синьо) */
    --accent-1: #667eea;
    --accent-2: #764ba2;
    --accent-grad: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

    --text: #2c2150;
    --text-muted: #6b6890;
    --danger: #e05a78;
    --success: #38b48b;

    /* Стъкло */
    --glass-bg: rgba(255, 255, 255, 0.45);
    --glass-bg-strong: rgba(255, 255, 255, 0.62);
    --glass-border: rgba(255, 255, 255, 0.55);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.18);
    --radius: 20px;
    --radius-sm: 12px;
}

* { box-sizing: border-box; }

/* Гарантира, че HTML атрибутът `hidden` винаги скрива елемента,
   дори когато по-долу има правило с явен display (flex/inline-block). */
[hidden] { display: none !important; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text);
    background:
        radial-gradient(1200px 600px at 10% -10%, #eaf0ff 0%, transparent 60%),
        radial-gradient(1000px 500px at 110% 10%, #f3eaff 0%, transparent 55%),
        linear-gradient(180deg, #f7f9ff 0%, #fdfbff 100%);
    background-attachment: fixed;
    min-height: 100vh;
    line-height: 1.5;
}

/* --- Декоративни размазани петна на фона --- */
.bg-blobs { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.blob { position: absolute; border-radius: 50%; filter: blur(70px); opacity: 0.45; }
.blob-1 { width: 380px; height: 380px; background: #a5b4fc; top: -80px; left: -60px; }
.blob-2 { width: 320px; height: 320px; background: #d8b4fe; bottom: -60px; right: -40px; }
.blob-3 { width: 260px; height: 260px; background: #93c5fd; top: 40%; left: 60%; }

/* --- Общ стъклен ефект --- */
.glass {
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: var(--glass-shadow);
}

.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }

/* ===========================================================================
   Бутони
   =========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.65rem 1.2rem;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    text-decoration: none;
    color: var(--text);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
    background: var(--accent-grad);
    color: #fff;
    box-shadow: 0 6px 18px rgba(102, 126, 234, 0.4);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 8px 24px rgba(118, 75, 162, 0.5); }

.btn-ghost {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--glass-border);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.8); }

.btn-sm { padding: 0.45rem 0.9rem; font-size: 0.85rem; }

.link-btn {
    background: none;
    border: none;
    color: var(--accent-1);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    width: 34px;
    height: 34px;
    cursor: pointer;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.9); }

/* --- Спинъри --- */
.spinner {
    width: 16px; height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}
.spinner.big { width: 26px; height: 26px; border-width: 3px; border-color: rgba(102,126,234,0.3); border-top-color: var(--accent-1); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===========================================================================
   Автентикация (вход / регистрация)
   =========================================================================== */
.auth-body { display: flex; }
.auth-wrapper {
    min-height: 100vh;
    width: 100%;
    display: grid;
    place-items: center;
    padding: 1.5rem;
}
.auth-card { width: 100%; max-width: 420px; padding: 2rem; }
.auth-header { text-align: center; margin-bottom: 1.4rem; }
.auth-header h1 { font-size: 1.5rem; margin: 0.6rem 0 0.2rem; }

.logo-badge {
    width: 58px; height: 58px;
    margin: 0 auto;
    display: grid; place-items: center;
    font-size: 1.8rem;
    border-radius: 18px;
    background: var(--accent-grad);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.45);
}
.logo-badge.small { width: 40px; height: 40px; font-size: 1.2rem; border-radius: 12px; }

/* Лого изображение (Симфониета Враца) */
.logo-img {
    display: block;
    height: auto;
    object-fit: contain;
}
.logo-img.auth-logo {
    max-width: 240px;
    width: 100%;
    margin: 0 auto 0.4rem;
}
.logo-img.brand-logo {
    height: 42px;
    max-width: 200px;
    width: auto;
}

.tabs {
    display: flex;
    background: rgba(255, 255, 255, 0.4);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 1.2rem;
}
.tab {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0.6rem;
    border-radius: 9px;
    font: inherit;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.18s ease;
}
.tab.active {
    background: var(--accent-grad);
    color: #fff;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-form label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.9rem; font-weight: 600; }
.auth-form input[type="text"],
.auth-form input[type="email"],
.auth-form input[type="password"] {
    padding: 0.7rem 0.85rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.7);
    font: inherit;
    color: var(--text);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.auth-form input:focus {
    border-color: var(--accent-1);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.18);
}
.checkbox-row { flex-direction: row !important; align-items: center; gap: 0.55rem !important; font-weight: 500; }
.checkbox-row input { width: 18px; height: 18px; accent-color: var(--accent-1); }

.auth-footer { text-align: center; margin-top: 1.2rem; font-size: 0.8rem; }

/* --- Съобщения за грешка / успех --- */
.alert {
    padding: 0.7rem 0.9rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
}
.alert.error { background: rgba(224, 90, 120, 0.15); color: #b03a57; border: 1px solid rgba(224, 90, 120, 0.3); }
.alert.success { background: rgba(56, 180, 139, 0.15); color: #1f7a5b; border: 1px solid rgba(56, 180, 139, 0.3); }

/* ===========================================================================
   Заглавна лента (topbar)
   =========================================================================== */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.8rem 1.2rem;
    margin: 1rem;
    border-radius: var(--radius);
    position: sticky;
    top: 1rem;
    z-index: 20;
}
.brand { display: flex; align-items: center; gap: 0.7rem; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 1rem; }
.brand-text .muted { font-size: 0.78rem; }

.user-area { display: flex; align-items: center; gap: 0.7rem; }
.avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--accent-grad);
    color: #fff;
    display: grid; place-items: center;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}
.username { font-weight: 600; font-size: 0.92rem; }

/* ===========================================================================
   Основно съдържание
   =========================================================================== */
.container { max-width: 1100px; margin: 0 auto; padding: 0 1rem 3rem; }

.panel { padding: 1.4rem; margin-bottom: 1.4rem; }
.panel h2 { margin: 0 0 0.3rem; font-size: 1.15rem; }

/* --- Зона за качване --- */
.dropzone {
    margin-top: 1rem;
    border: 2px dashed rgba(102, 126, 234, 0.45);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.35);
    padding: 1.6rem;
    text-align: center;
    transition: background 0.18s ease, border-color 0.18s ease;
    cursor: pointer;
}
.dropzone.dragover {
    background: rgba(102, 126, 234, 0.12);
    border-color: var(--accent-1);
}
.dropzone-icon { font-size: 1.8rem; display: block; margin-bottom: 0.4rem; }
.upload-actions { margin-top: 1rem; display: flex; justify-content: flex-end; }

/* --- Филтри --- */
.filters {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.4rem;
    flex-wrap: wrap;
}
.month-nav { display: flex; align-items: center; gap: 0.5rem; }
.month-select {
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.6);
    font: inherit;
    font-weight: 600;
    color: var(--text);
    min-width: 180px;
    cursor: pointer;
}

/* --- Зареждане --- */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.7rem;
    padding: 2rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* ===========================================================================
   Карти на събития
   =========================================================================== */
.events-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
    gap: 1.2rem;
    align-items: stretch; /* картите в един ред са с еднаква височина */
}
.event-card {
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    height: 100%; /* запълва клетката на грида → еднакви карти */
}

/* Цвят на картата, пренесен от 3-тата клетка на PDF реда
   (или син, ако текстът в 5-тата клетка е син). */
.event-card.is-tinted {
    background:
        linear-gradient(var(--card-tint, transparent), var(--card-tint, transparent)),
        var(--glass-bg);
    border-left: 6px solid var(--card-color, var(--accent-1));
    border-top: 1px solid var(--card-tint-strong, var(--glass-border));
}
.event-card.is-tinted .time-chip {
    background: var(--card-tint-strong, rgba(102, 126, 234, 0.14));
}

.event-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.6rem; }
.event-date { display: flex; flex-direction: column; }
.day-name { font-weight: 800; font-size: 1.05rem; }
.date-full { color: var(--text-muted); font-size: 0.85rem; }

.event-times { display: flex; flex-direction: column; gap: 0.25rem; align-items: flex-end; }
.time-chip {
    background: rgba(102, 126, 234, 0.14);
    color: var(--accent-2);
    border-radius: 999px;
    padding: 0.2rem 0.7rem;
    font-size: 0.82rem;
    font-weight: 700;
    white-space: nowrap;
}

.event-location {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.event-location::before { content: "📍"; }
.event-location:empty { display: none; }

.event-description {
    font-size: 0.9rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.4);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.75rem;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 7.5rem;   /* дългите описания не разтягат картата */
    overflow-y: auto;
}
.event-description:empty { display: none; }

/* --- Секция с бележки --- */
.notes-section {
    border-top: 1px solid rgba(102, 126, 234, 0.18);
    padding-top: 0.8rem;
    margin-top: auto;          /* притиска секцията към дъното на картата */
    display: flex;
    flex-direction: column;
}
.notes-title { margin: 0 0 0.6rem; font-size: 0.95rem; }
.notes-count { color: var(--text-muted); font-weight: 600; }

.notes-list {
    list-style: none;
    margin: 0 0 0.8rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    max-height: 210px;        /* много бележки → скрол, картите остават уеднаквени */
    overflow-y: auto;
}
.notes-list:empty { margin: 0; }

.note-item {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.7rem;
}
.note-item.done .note-content { text-decoration: line-through; opacity: 0.6; }

.note-check { position: relative; display: inline-flex; cursor: pointer; padding-top: 2px; }
.note-check input { position: absolute; opacity: 0; width: 0; height: 0; }
.checkmark {
    width: 20px; height: 20px;
    border-radius: 6px;
    border: 2px solid var(--accent-1);
    display: inline-block;
    transition: background 0.15s ease;
    position: relative;
}
.note-check input:checked + .checkmark { background: var(--accent-grad); border-color: transparent; }
.note-check input:checked + .checkmark::after {
    content: "✓";
    color: #fff;
    font-size: 0.8rem;
    font-weight: 800;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
}

.note-body { flex: 1; min-width: 0; }
.note-content {
    font-size: 0.9rem;
    word-break: break-word;
    white-space: pre-wrap;
    cursor: pointer;
    /* подсказваме, че текстът се отваря в по-голям изглед */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.15s ease;
}
.note-content:hover { color: var(--accent-2); }
.note-meta { display: flex; gap: 0.5rem; font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; }
.note-author { font-weight: 700; }

.note-actions { display: flex; gap: 0.3rem; }
.note-actions.hidden { display: none; }

.note-edit-area { width: 100%; display: flex; flex-direction: column; gap: 0.4rem; }
.note-edit-area textarea {
    width: 100%;
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.8);
    padding: 0.5rem;
    font: inherit;
    font-size: 0.9rem;
    resize: vertical;
}
.note-edit-buttons { display: flex; gap: 0.4rem; }

/* --- Форма за добавяне на бележка --- */
.add-note-form { display: flex; gap: 0.5rem; align-items: flex-end; margin-top: auto; }
.note-input {
    flex: 1;
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.7);
    padding: 0.55rem 0.7rem;
    font: inherit;
    font-size: 0.9rem;
    resize: vertical;
    outline: none;
}
.note-input:focus { border-color: var(--accent-1); box-shadow: 0 0 0 3px rgba(102,126,234,0.15); }

/* --- Празно състояние --- */
.empty-state { text-align: center; padding: 2.5rem 1.5rem; }
.empty-icon { font-size: 2.5rem; display: block; margin-bottom: 0.5rem; }

/* ===========================================================================
   Известия (toast)
   =========================================================================== */
.toast-container {
    position: fixed;
    bottom: 1.2rem;
    right: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    z-index: 100;
}
.toast {
    min-width: 240px;
    max-width: 360px;
    padding: 0.8rem 1rem;
    border-radius: var(--radius-sm);
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    animation: toast-in 0.25s ease;
}
.toast.success { background: linear-gradient(135deg, #38b48b, #2e9d99); }
.toast.error { background: linear-gradient(135deg, #e05a78, #c0466a); }
.toast.info { background: var(--accent-grad); }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ===========================================================================
   Модален прозорец за бележка
   =========================================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.2rem;
    background: rgba(44, 33, 80, 0.35);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    animation: overlay-in 0.18s ease;
}
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
    position: relative;
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 1.6rem 1.6rem 1.8rem;
    background: var(--glass-bg-strong);
    animation: modal-in 0.22s ease;
}
@keyframes modal-in {
    from { transform: translateY(14px) scale(0.98); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-close {
    position: absolute;
    top: 0.9rem;
    right: 0.9rem;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    color: var(--text);
    font-size: 1rem;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: background 0.15s ease;
}
.modal-close:hover { background: rgba(255, 255, 255, 0.95); }

.modal-author-row {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 1rem;
    padding-right: 2.5rem;
}
.modal-avatar { width: 46px; height: 46px; font-size: 1.1rem; flex-shrink: 0; }
.modal-author { font-weight: 800; font-size: 1.05rem; }
.modal-time { font-size: 0.85rem; }

.modal-status {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    font-weight: 700;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    margin-bottom: 0.9rem;
}
.modal-status.done { background: rgba(56, 180, 139, 0.16); color: #1f7a5b; }
.modal-status.pending { background: rgba(102, 126, 234, 0.14); color: var(--accent-2); }

.modal-content-text {
    font-size: 1.15rem;
    line-height: 1.6;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
}

/* ===========================================================================
   Адаптивност
   =========================================================================== */
@media (max-width: 640px) {
    .topbar { flex-direction: column; align-items: stretch; gap: 0.7rem; text-align: center; }
    .user-area { justify-content: center; }
    .events-grid { grid-template-columns: 1fr; }
    .filters { flex-direction: column; align-items: stretch; }
    .month-nav { justify-content: space-between; }
    .month-select { flex: 1; }
    .brand { justify-content: center; }
    .modal-content-text { font-size: 1.05rem; }
}
