/**
 * Memorial Editor Styles
 * Full-width two-column layout with navigation
 */

/* =================================================================
   BASE LAYOUT
   ================================================================= */
.qrcg-memorial-editor {
    width: 100%;
    min-height: 100vh;
    background: #f8f9fa;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Header */
.qrcg-editor-header {
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.qrcg-editor-header h1 {
    margin: 0;
    font-size: 24px;
    color: #333;
}

.qrcg-editor-header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.qrcg-editor-status {
    color: #666;
    font-size: 14px;
}

/* =================================================================
   TWO COLUMN LAYOUT
   ================================================================= */
.qrcg-editor-body {
    display: flex;
    min-height: calc(100vh - 70px);
}

/* Left Column - Navigation */
.qrcg-editor-nav-column {
    width: 280px;
    background: #2c3e50;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* Right Column - Content */
.qrcg-editor-content-column {
    flex: 1;
    padding: 30px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* =================================================================
   NAVIGATION
   ================================================================= */
.qrcg-editor-nav {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.qrcg-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #ecf0f1;
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.3s ease;
    font-size: 14px;
}

.qrcg-nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.qrcg-nav-item.active {
    background: #3498db;
    color: #fff;
}

.qrcg-nav-item .nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.qrcg-nav-item .nav-text {
    flex: 1;
}

/* Navigation Actions */
.qrcg-editor-actions {
    margin-top: 30px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* =================================================================
   CONTENT SECTIONS
   ================================================================= */
.qrcg-editor-section {
    display: none;
    animation: fadeIn 0.3s ease;
}

.qrcg-editor-section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.qrcg-editor-section h2 {
    margin: 0 0 30px 0;
    font-size: 28px;
    color: #333;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
}

.qrcg-editor-section h3 {
    margin: 30px 0 15px 0;
    font-size: 18px;
    color: #555;
}

/* =================================================================
   FORMS
   ================================================================= */
.qrcg-form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.qrcg-form-field {
    margin-bottom: 20px;
}

.qrcg-form-field label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.qrcg-input,
.qrcg-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s ease;
    background: #fff;
}

.qrcg-input:focus,
.qrcg-textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.qrcg-textarea {
    resize: vertical;
    min-height: 120px;
    font-family: inherit;
}

.qrcg-color-input {
    width: 80px;
    height: 40px;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
}

.qrcg-input-group {
    display: flex;
    gap: 10px;
}

.qrcg-input-group .qrcg-input {
    flex: 1;
}

/* Checkboxes */
.qrcg-checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.qrcg-checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* =================================================================
   BUTTONS
   ================================================================= */
.qrcg-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
}

.qrcg-btn-primary {
    background: #3498db;
    color: white;
}

.qrcg-btn-primary:hover {
    background: #2980b9;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.qrcg-btn-secondary {
    background: #95a5a6;
    color: white;
}

.qrcg-btn-secondary:hover {
    background: #7f8c8d;
}

.qrcg-btn-danger {
    background: #e74c3c;
    color: white;
}

.qrcg-btn-danger:hover {
    background: #c0392b;
}

.qrcg-btn-warning {
    background: #ff9800 !important;
    color: #ffffff;
    border: none;
}

.qrcg-btn-warning:hover {
    background: #f57c00 !important;
}

.qrcg-btn-small {
    padding: 8px 16px;
    font-size: 13px;
    width: auto;
}

.qrcg-btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    opacity: 0.6;
}

.qrcg-btn-icon:hover {
    opacity: 1;
    background: #f8f9fa;
}

.btn-icon {
    font-size: 16px;
}

/* Cancel Edit Button */
#cancel-timeline-edit {
    background: #6c757d;
    color: #ffffff;
    border: none;
}

#cancel-timeline-edit:hover {
    background: #5a6268;
}

/* =================================================================
   MEDIA UPLOAD AREAS
   ================================================================= */
.qrcg-media-section {
    background: #fff;
    padding: 25px;
    border-radius: 8px;
    margin-bottom: 25px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.qrcg-media-upload-area {
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

#section-media .qrcg-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.qrcg-image-preview {
    margin-bottom: 15px;
    min-height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qrcg-image-preview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.qrcg-banner-preview {
    min-height: 200px;
}

.qrcg-banner-preview img {
    max-height: 300px;
}

.qrcg-image-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: #999;
}

.placeholder-icon {
    font-size: 48px;
    opacity: 0.5;
}

.placeholder-text {
    font-size: 14px;
}

.qrcg-media-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* ===================================================================================
 * Gallery Grid 
   ===================================================================================*/

.qrcg-gallery-area {
    background: #fff;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.qrcg-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
    min-height: 100px;
}

.qrcg-gallery-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    background: #f0f0f0;
}

.qrcg-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.qrcg-gallery-item .remove-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(231, 76, 60, 0.9);
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.qrcg-gallery-item:hover .remove-btn {
    opacity: 1;
}

/**=====================================================================
 Fix image orientation based on EXIF data
 ======================================================================*/

/* Auto-rotate images based on EXIF orientation */
.qrcg-gallery-item img,
.qrcg-image-preview img {
    image-orientation: from-image;
    max-width: 100%;
    height: 100%;
    object-fit: cover;
}

/* For browsers that don't support image-orientation */
@supports not (image-orientation: from-image) {
    .qrcg-gallery-item img {
        transform-origin: top left;
    }
}

/* =================================================================
   TRIBUTES ICON PICKER
   ================================================================= */

.qrcg-icon-picker-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.qrcg-icon-picker-modal.show {
    display: flex;
}

.qrcg-icon-picker-content {
    background: white;
    padding: 30px;
    border-radius: 8px;
    max-width: 700px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.qrcg-icon-categories h4 {
    margin: 20px 0 10px 0;
    font-size: 14px;
    color: #666;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.qrcg-icon-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 8px;
    margin-bottom: 20px;
}

.qrcg-icon-grid button {
    padding: 8px 4px;
    border: 1px solid #ddd;
    background: white;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 65px;
    transition: all 0.2s;
}

.qrcg-icon-grid button span {
    font-size: 24px;
    margin-bottom: 3px;
}

.qrcg-icon-grid button small {
    font-size: 10px;
    color: #666;
    text-align: center;
    line-height: 1.2;
}

.qrcg-icon-grid button:hover {
    background: #f0f0f0;
    transform: scale(1.05);
    border-color: #999;
}

.timeline-icon-preview {
    font-size: 20px;
}

/* Responsive adjustments for icon picker */
@media (max-width: 640px) {
    .qrcg-icon-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

@media (max-width: 480px) {
    .qrcg-icon-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* =================================================================
   TIMELINE
   ================================================================= */
.qrcg-timeline-editor {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.qrcg-timeline-form,
.qrcg-timeline-list {
    background: #fff;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.qrcg-timeline-event {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 10px;
    position: relative;
    border-left: 3px solid #3498db;
}

.qrcg-timeline-event-date {
    font-weight: 600;
    color: #3498db;
    margin-bottom: 5px;
}

.qrcg-timeline-event-title {
    font-size: 16px;
    margin-bottom: 5px;
}

.qrcg-timeline-event-description {
    color: #666;
    font-size: 14px;
}

.qrcg-timeline-event .remove-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    color: #e74c3c;
    cursor: pointer;
    font-size: 18px;
}

/* Timeline Events List Styles */
.timeline-events-list {
    margin-top: 20px;
}

.timeline-event-item {
    background: #ffffff;
    border: 1px solid #e1e1e1;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    transition: all 0.3s ease;
    position: relative;
}

.timeline-event-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.timeline-event-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f0f0f0;
}

.timeline-event-icon {
    font-size: 24px;
    margin-right: 10px;
}

.timeline-event-date {
    flex: 1;
    color: #666;
    font-weight: 500;
    font-size: 14px;
}

.timeline-event-actions {
    display: flex;
    gap: 8px;
}

.edit-timeline-event:hover {
    background: #e3f2fd;
}

.delete-timeline-event:hover {
    background: #ffebee;
}

.timeline-event-content h4 {
    margin: 0 0 8px 0;
    color: #333;
    font-size: 16px;
    font-weight: 600;
}

.timeline-event-content p {
    margin: 0 0 8px 0;
    color: #666;
    font-size: 14px;
    line-height: 1.5;
}

.timeline-location {
    color: #888;
    font-size: 13px;
    font-style: italic;
    margin-top: 5px;
}

/* Timeline Form Editing Mode */
.qrcg-timeline-form.editing-mode {
    background: #fffbf0;
    border: 2px solid #ffa726;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    position: relative;
    animation: highlight 0.5s ease;
}

@keyframes highlight {
    0% {
        background: #fff;
        border-color: #e1e1e1;
    }
    50% {
        background: #fff9e6;
        border-color: #ffb74d;
    }
    100% {
        background: #fffbf0;
        border-color: #ffa726;
    }
}

/* Timeline Messages */
.timeline-message {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 14px;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.timeline-message-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.timeline-message-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.timeline-message-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

.timeline-message-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* No Events Message */
.no-events {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 30px;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 20px 0;
}

/* Location Field (Optional) */
#timeline-location {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    margin-top: 10px;
}

/* =================================================================
   TRIBUTES
   ================================================================= */
.qrcg-tributes-list {
    background: #fff;
    padding: 25px;
    border-radius: 8px;
    margin-top: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.qrcg-tribute-item {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
}

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

.qrcg-tribute-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.qrcg-tribute-author {
    font-weight: 600;
    color: #333;
}

.qrcg-tribute-date {
    color: #999;
    font-size: 13px;
}

.qrcg-tribute-message {
    color: #555;
    line-height: 1.6;
}

/* =================================================================
   RESPONSIVE
   ================================================================= */
@media (max-width: 1024px) {
    .qrcg-editor-body {
        flex-direction: column;
    }
    
    .qrcg-editor-nav-column {
        width: 100%;
        padding: 15px;
    }
    
    .qrcg-editor-nav {
        flex-direction: row;
        overflow-x: auto;
        gap: 10px;
        padding-bottom: 10px;
    }
    
    .qrcg-nav-item {
        white-space: nowrap;
    }
    
    .qrcg-editor-actions {
        flex-direction: row;
        margin-top: 15px;
    }
    
    .qrcg-editor-content-column {
        padding: 20px;
    }
    
    .qrcg-timeline-editor {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .timeline-event-header {
        flex-wrap: wrap;
    }
    
    .timeline-event-date {
        width: 100%;
        margin-bottom: 8px;
    }
    
    .timeline-event-actions {
        margin-left: auto;
    }
    
    .qrcg-btn-icon {
        font-size: 16px;
        padding: 6px 10px;
    }
}

@media (max-width: 640px) {
    .qrcg-form-row {
        grid-template-columns: 1fr;
    }
    
    .qrcg-gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
}

/* =================================================================
   OVERRIDE THEME STYLES
   ================================================================= */
.qrcg-memorial-editor * {
    box-sizing: border-box;
}

/* Force full width */
body.memorial-editor-active .site-container,
body.memorial-editor-active .content-area,
body.memorial-editor-active .site-main {
    max-width: 100% !important;
    padding: 0 !important;
}