/* CSS Variables & Reset */
:root {
    --primary: #1e3a8a;
    /* Navy Blue */
    --primary-dark: #1e293b;
    --accent: #d97706;
    /* Gold/Amber for subtle highlights */
    --bg-app: #f3f4f6;
    --bg-paper: #ffffff;
    --text-main: #1f2937;
    --text-light: #6b7280;
    --border: #e5e7eb;
    --font-heading: 'Inter', sans-serif;
    --font-body: 'Inter', sans-serif;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);

    /* Premium / Glassmorphism */
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(255, 255, 255, 0.4);
    --glass-shadow: 0 8px 32px rgba(31, 38, 135, 0.15);
    --blur-amount: 12px;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--blur-amount));
    -webkit-backdrop-filter: blur(var(--blur-amount));
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

.premium-input {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #e2e8f0;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

.premium-input:focus {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(30, 58, 138, 0.1);
    border-color: var(--primary);
}

.premium-btn {
    background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
    color: white;
    font-weight: 600;
    letter-spacing: 0.5px;
    border: none;
    transition: all 0.3s ease;
}

.premium-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-app);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    /* App-like feel on desktop */
}

/* Layout */
.app-layout {
    display: flex;
    height: 100vh;
}

.editor-pane {
    width: 400px;
    background: white;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 10;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.05);
}

.preview-pane {
    flex: 1;
    background: #e5e7eb;
    /* Darker bg to make paper pop */
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* Editor Styling */
.editor-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    background: white;
}

.editor-header h1 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    color: var(--primary);
}

.editor-header p {
    font-size: 0.875rem;
    color: var(--text-light);
}

#agendaForm {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 2rem;
}

.form-group h2 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-light);
    margin-bottom: 1rem;
    font-weight: 600;
}

.input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.input-wrapper {
    margin-bottom: 1rem;
}

.input-wrapper label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: var(--text-main);
}

.input-wrapper input,
.input-wrapper textarea,
.input-row input,
.hymn-input-wrapper input {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.input-wrapper input:focus,
.input-wrapper textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.1);
}

.actions-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    background: white;
    display: flex;
    gap: 1rem;
}

.btn {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-secondary {
    background-color: #25D366;
    /* WhatsApp green */
    color: white;
}

/* Paper Preview Styling */
.paper-wrapper {
    width: 100%;
    max-width: 210mm;
    /* A4 width */
    /* aspect-ratio: 210/297;  Remove aspect ratio to allow growth */
    min-height: 297mm;
}

/* Mobile Responsiveness */
@media (max-width: 800px) {
    .app-layout {
        flex-direction: column;
        overflow-y: auto;
    }

    .editor-pane {
        width: 100%;
        height: auto;
        border-right: none;
        box-shadow: none;
    }

    #agendaForm {
        max-height: 50vh;
        /* Allow scrolling form on mobile */
    }

    .preview-pane {
        padding: 1rem;
        min-height: 100vh;
        /* Ensure full view of preview */
    }

    .paper-wrapper {
        transform: scale(0.9);
        /* Scale down slightly for mobile */
        transform-origin: top center;
    }

    .actions-footer {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 100;
        box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.1);
    }

    body {
        padding-bottom: 80px;
        /* Space for fixed footer */
    }
}

/* New Enhancements */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    padding: 0.5rem;
    background: #f8fafc;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.checkbox-wrapper label {
    font-size: 0.9rem;
    cursor: pointer;
}

.helper-text {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.dynamic-list-input {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.input-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn-remove {
    background: #fee2e2;
    color: #ef4444;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-add {
    background: none;
    border: 1px dashed var(--primary);
    color: var(--primary);
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    width: 100%;
    font-size: 0.85rem;
}

.btn-add:hover {
    background: #eff6ff;
}

/* Hymn Search Styles */
.hymn-input-wrapper {
    position: relative;
    margin-bottom: 1rem;
    width: 100%;
}

.hymn-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border);
    border-radius: 0 0 6px 6px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 20;
    display: none;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.hymn-result-item {
    padding: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.hymn-result-item:hover {
    background: #f3f4f6;
}



.speaker-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.speaker-order-controls {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.btn-move {
    font-size: 0.6rem;
    padding: 2px;
    background: #f3f4f6;
    border: none;
    cursor: pointer;
}

/* Action Menu (Meatballs) */
.action-cell {
    position: relative;
    width: 40px;
    text-align: center;
    overflow: visible;
    /* CRITICAL FIX: Allow menu to spill out */
}

.btn-meatballs {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-light);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.btn-meatballs:hover {
    background: #f1f5f9;
    color: var(--primary);
}

.action-menu {
    position: absolute;
    right: 30px;
    /* Position to the left of the dots */
    top: 50%;
    transform: translateY(-50%);
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    z-index: 100;
    min-width: 120px;
    overflow: hidden;
    animation: fadeIn 0.1s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-50%) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }
}

.menu-item {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.1s;
}

.menu-item:hover {
    background: #f8fafc;
    color: var(--primary);
}

.menu-item.danger {
    color: #ef4444;
}

.menu-item.danger:hover {
    background: #fef2f2;
}

/* Full Screen Toggle */
.app-layout.full-screen .editor-pane {
    display: none;
}

.btn-fullscreen-toggle {
    position: absolute;
    top: 1rem;
    right: 2rem;
    /* Avoid scrollbar overlap */
    background: white;
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: var(--shadow);
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-main);
    font-weight: 500;
    transition: all 0.2s;
}

.btn-fullscreen-toggle:hover {
    color: var(--primary);
    background: #f8fafc;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}
/* Simple Mode Header Fix */
.editor-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    background: white;
}
.btn-icon-back {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: var(--text-main);
    background: #f3f4f6;
    transition: all 0.2s;
    text-decoration: none;
    font-size: 1.2rem;
}
.btn-icon-back:hover {
    background: #e5e7eb;
    color: var(--primary);
    transform: translateX(-2px);
}
/* --- Toast Notifications --- */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none; /* Allow clicking through container */
}

.toast-notification {
    background: white;
    color: var(--text-main);
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 250px;
    max-width: 400px;
    border-left: 4px solid var(--primary);
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto; /* Allow clicking on toast */
    font-size: 0.9rem;
    font-weight: 500;
}

.toast-notification.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.toast-notification i {
    font-size: 1.25rem;
}

/* Variants */
.toast-success {
    border-left-color: #10b981; /* Emerald 500 */
}
.toast-success i {
    color: #10b981;
}

.toast-error {
    border-left-color: #ef4444; /* Red 500 */
}
.toast-error i {
    color: #ef4444;
}

.toast-info {
    border-left-color: var(--primary);
}
.toast-info i {
    color: var(--primary);
}
