/* ============================================================
   CEMETERY - Layout
   ============================================================ */

#cemetery-app .hidden {
    display: none !important;
}

#cemetery-app {
    position: relative;
    width: 100%;
    height: calc(100vh - 60px);
    overflow: hidden;
    background: #2d4a2d;
}

/* ============================================================
   MAP
   ============================================================ */

.cem-map {
    width: 100%;
    height: 100%;
    cursor: grab;
    position: relative;
}

.cem-map.dragging {
    cursor: grabbing;
}

.cem-map.placing {
    cursor: crosshair;
}

#cem-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ============================================================
   SEARCH
   ============================================================ */

.cem-search-wrapper {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    width: 320px;
    max-width: 90%;
}

.cem-search-input {
    width: 100%;
    padding: 10px 14px;
    border: none;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 14px;
    outline: none;
    backdrop-filter: blur(8px);
}

.cem-search-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.cem-search-results {
    background: rgba(0, 0, 0, 0.85);
    border-radius: 0 0 8px 8px;
    max-height: 240px;
    overflow-y: auto;
    display: none;
}

.cem-search-results.active {
    display: block;
}

.cem-search-result {
    padding: 10px 14px;
    cursor: pointer;
    color: #ddd;
    font-size: 13px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.cem-search-result:hover {
    background: rgba(255, 255, 255, 0.1);
}

.cem-search-result-name {
    font-weight: 600;
    color: #fff;
}

.cem-search-result-date {
    font-size: 11px;
    color: #999;
    margin-top: 2px;
}

/* ============================================================
   ZOOM CONTROLS
   ============================================================ */

.cem-zoom-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cem-zoom-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
}

.cem-zoom-btn:hover {
    background: rgba(0, 0, 0, 0.85);
}

/* ============================================================
   CREATE BUTTON
   ============================================================ */

.cem-create-btn {
    position: absolute;
    bottom: 20px;
    left: 20px;
    z-index: 100;
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    backdrop-filter: blur(8px);
}

.cem-create-btn:hover {
    background: rgba(0, 0, 0, 0.85);
}

/* ============================================================
   PLACEMENT BAR
   ============================================================ */

.cem-placement-bar {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 110;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 10px 20px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 14px;
    backdrop-filter: blur(8px);
}

/* ============================================================
   SIDE PANEL
   ============================================================ */

.cem-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 380px;
    max-width: 100%;
    height: 100%;
    background: rgba(15, 15, 15, 0.95);
    color: #ddd;
    z-index: 200;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    backdrop-filter: blur(12px);
}

.cem-panel.open {
    transform: translateX(0);
}

/* panel uses transform for animation, overrides generic .hidden */
.cem-panel {
    display: block !important;
}

.cem-panel-close {
    position: absolute;
    top: 10px;
    right: 14px;
    background: none;
    border: none;
    color: #999;
    font-size: 24px;
    cursor: pointer;
    z-index: 1;
}

.cem-panel-close:hover {
    color: #fff;
}

#cem-panel-content {
    padding: 20px;
}

/* Panel sections */
.cem-panel-header {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.cem-panel-name {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    margin: 0 0 6px 0;
}

.cem-panel-dates {
    font-size: 13px;
    color: #999;
}

.cem-panel-wiki {
    display: inline-block;
    margin-top: 8px;
    color: #6ba3d6;
    font-size: 13px;
    text-decoration: none;
}

.cem-panel-wiki:hover {
    text-decoration: underline;
}

.cem-panel-description {
    margin-top: 8px;
    font-size: 13px;
    color: #aaa;
    line-height: 1.5;
    font-style: italic;
}

/* Flowers section */
.cem-panel-section {
    margin-bottom: 20px;
}

.cem-panel-section-title {
    font-size: 14px;
    font-weight: 600;
    color: #aaa;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cem-flowers-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cem-flower-item {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.08);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
}

.cem-flower-item img {
    width: 24px;
    height: 24px;
    image-rendering: pixelated;
}

/* Flower picker */
.cem-flower-picker {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.cem-flower-option {
    width: 40px;
    height: 40px;
    border: 2px solid transparent;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cem-flower-option:hover {
    border-color: rgba(255, 255, 255, 0.3);
}

.cem-flower-option.selected {
    border-color: #6ba3d6;
}

.cem-flower-option img {
    width: 28px;
    height: 28px;
    image-rendering: pixelated;
}

/* Comments */
.cem-comment {
    background: rgba(255, 255, 255, 0.05);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 8px;
}

.cem-comment.pinned {
    border-left: 3px solid #d4a647;
}

.cem-comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.cem-comment-user {
    font-weight: 600;
    color: #fff;
    font-size: 13px;
}

.cem-comment-date {
    font-size: 11px;
    color: #777;
}

.cem-comment-text {
    font-size: 14px;
    line-height: 1.5;
    color: #ccc;
}

.cem-comment-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.cem-comment-action {
    background: none;
    border: none;
    color: #777;
    font-size: 12px;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

.cem-comment-action:hover {
    color: #bbb;
}

.cem-comment-action.liked {
    color: #e06060;
}

/* Comment form */
.cem-comment-form {
    margin-top: 12px;
}

.cem-comment-form textarea {
    width: 100%;
    min-height: 60px;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    color: #ddd;
    font-size: 13px;
    resize: vertical;
    font-family: inherit;
}

.cem-comment-form textarea:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.3);
}

/* ============================================================
   MODAL
   ============================================================ */

.cem-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cem-modal.hidden {
    display: none;
}

.cem-modal-content {
    background: #1a1a1a;
    color: #ddd;
    border-radius: 12px;
    padding: 24px;
    width: 420px;
    max-width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.cem-modal-content h3 {
    margin: 0 0 16px 0;
    color: #fff;
}

.cem-modal-content label {
    display: block;
    font-size: 13px;
    color: #aaa;
    margin: 12px 0 4px 0;
}

.cem-modal-content input[type="text"],
.cem-modal-content input[type="date"],
.cem-modal-content input[type="url"] {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    color: #ddd;
    font-size: 14px;
}

.cem-modal-content input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.3);
}

.cem-modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 20px;
    justify-content: flex-end;
}

/* Sprite picker */
.cem-sprite-picker {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.cem-sprite-option {
    width: 48px;
    height: 48px;
    border: 2px solid transparent;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cem-sprite-option:hover {
    border-color: rgba(255, 255, 255, 0.3);
}

.cem-sprite-option.selected {
    border-color: #6ba3d6;
}

.cem-sprite-option img {
    max-width: 36px;
    max-height: 36px;
    image-rendering: pixelated;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.cem-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
}

.cem-btn-primary {
    background: #4a7c4a;
    color: #fff;
}

.cem-btn-primary:hover {
    background: #5a9a5a;
}

.cem-btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #ccc;
}

.cem-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.cem-btn-danger {
    background: #7c3a3a;
    color: #fff;
}

.cem-btn-danger:hover {
    background: #9a4a4a;
}

/* ============================================================
   CLOUD BUBBLE
   ============================================================ */

.cem-cloud {
    position: absolute;
    z-index: 90;
    background: rgba(255, 255, 255, 0.55);
    color: #222;
    padding: 6px 10px;
    border-radius: 8px;
    max-width: 180px;
    font-size: 11px;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: opacity 0.8s ease, transform 0.1s ease;
    transform-origin: bottom left;
    backdrop-filter: blur(4px);
}

.cem-cloud.visible {
    opacity: 1;
}

.cem-cloud.hidden {
    display: none;
}

.cem-cloud::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 16px;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid rgba(255, 255, 255, 0.55);
}

.cem-cloud-user {
    font-weight: 600;
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
}

.cem-cloud-text {
    line-height: 1.4;
}

/* ============================================================
   DEBUG PANEL (admin only)
   ============================================================ */

.cem-debug-panel {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    background: rgba(0, 0, 0, 0.7);
    padding: 6px 14px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #ccc;
    font-size: 12px;
    backdrop-filter: blur(8px);
}

.cem-debug-panel input[type="range"] {
    width: 120px;
    accent-color: #6ba3d6;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
    .cem-panel {
        width: 100%;
    }

    .cem-search-wrapper {
        width: 260px;
    }

    .cem-placement-bar {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
}

/* ============================================================
   ADMIN PANEL STYLES (in admin template)
   ============================================================ */

.cem-admin-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}

.cem-admin-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.cem-admin-card-actions {
    display: flex;
    gap: 6px;
}

.cem-admin-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0;
}

.cem-admin-tab {
    padding: 8px 16px;
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.cem-admin-tab.active {
    color: #fff;
    border-bottom-color: #6ba3d6;
}

.cem-admin-tab:hover {
    color: #ccc;
}
