/* General styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Arial', sans-serif;
}

body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: #f5f5f5;
}

/* Control bar */
.control-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background-color: #fff;
    border-bottom: 1px solid #e0e0e0;
    z-index: 100;
}

.left-controls, .right-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.icon-button {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
    color: #333;
}

.icon-button:hover {
    color: #007bff;
}

.copy-success {
    color: #28a745 !important;
}

.primary-button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

.primary-button:hover {
    background-color: #0069d9;
}

.primary-button.copy-success {
    background-color: #28a745 !important;
    color: white !important;
}

.secondary-button {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
}

.danger-button {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
}

/* Dropdown */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: #f9f9f9;
    min-width: 160px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    z-index: 1;
    border-radius: 4px;
}

.dropdown-content a {
    color: black;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
}

.dropdown-content a:hover {
    background-color: #f1f1f1;
}

.dropdown:hover .dropdown-content {
    display: block;
}

/* Content area */
.content-area {
    display: flex;
    flex: 1;
    overflow: hidden;
    background-color: #f5f5f5;
}

/* Item center */
.item-center {
    width: 45%;
    padding: 20px;
    background-color: #f5f5f5;
    overflow-y: auto;
}

.elements-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Element styling - more like cards in the image */
.element-item {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    background-color: #fff;
    margin-bottom: 15px;
}

.element-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background-color: #f4f4f4;
    border-bottom: 1px solid #e0e0e0;
}

.element-title {
    font-weight: bold;
    font-size: 0.9rem;
    color: #333;
}

.element-controls {
    display: flex;
    gap: 5px;
    align-items: center;
}

/* Make element header match image better */
.element-menu-button, .element-drag-handle {
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
    display: flex;
    align-items: center;
    font-size: 1rem;
}

/* Element content - cleaner spacing */
.element-content {
    padding: 15px;
    background-color: #fff;
}

.element-content input,
.element-content textarea {
    width: 100%;
    padding: 8px;
    border: none;
    background-color: #f9f9f9;
    font-size: 16px;
    font-weight: 500;
    color: #333;
    resize: none;
    border-radius: 4px;
    margin-bottom: 8px;
    font-family: 'M PLUS Rounded 1c', sans-serif;
}

.element-content textarea {
    min-height: 100px;
    max-height: 480px; /* 20 lines x 24px line-height */
    overflow-y: auto; /* Always show scrollbar when content exceeds max height */
    resize: none;
    transition: height 0.2s ease;
    line-height: 24px;
    font-size: 16px;
    font-weight: 500;
    font-family: 'M PLUS Rounded 1c', sans-serif;
    width: 100%;
    box-sizing: border-box;
}

.element-content .content-textarea,
.element-content .prayer-list-textarea,
.element-content .centered-textarea {
    min-height: 100px;
    max-height: 480px; /* 20 lines x 24px */
    line-height: 24px;
    font-size: 16px;
    font-weight: 500;
    font-family: 'M PLUS Rounded 1c', sans-serif;
    overflow-y: auto;
    resize: none;
    width: 100%;
    box-sizing: border-box;
}

.element-content input:focus,
.element-content textarea:focus {
    outline: none;
}

/* Label styling for button elements */
.element-content label {
    display: none;
}

/* Preview section */
.preview-section {
    flex: 1;
    padding: 20px;
    background-color: #f5f5f5;
}

.email-preview {
    background-color: #fff;
    border-radius: 8px;
    height: 100%;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    padding: 0;
}

.email-preview iframe {
    width: 100%;
    height: 100%;
    border: none;
    background-color: white;
}

/* Section headings */
.item-center h2,
.preview-section h2 {
    margin-bottom: 15px;
    font-size: 1.1rem;
    color: #666;
    font-weight: normal;
}

/* Dropdown menu for element options */
.element-dropdown {
    position: relative;
    display: inline-block;
}

.element-dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    background-color: #fff;
    min-width: 120px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 1;
    border-radius: 4px;
}

.element-dropdown-content a {
    color: #333;
    padding: 8px 12px;
    text-decoration: none;
    display: block;
    font-size: 0.9rem;
}

.element-dropdown-content a:hover {
    background-color: #f1f1f1;
}

.element-dropdown:hover .element-dropdown-content {
    display: block;
}

/* Modal styling */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    overflow-y: auto;
}

/* Add a new class for when modal is visible */
.modal.visible {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 30px 0;
}

.modal-content {
    background-color: #fff;
    margin: auto;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    position: relative;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    transform: translateY(0);
    transition: transform 0.3s ease;
}

.close {
    position: absolute;
    right: 20px;
    top: 24px;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
}

.form-group {
    margin-bottom: 15px;
    width: 100%;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
}

.form-group input, 
.form-group textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
}

.form-hint {
    display: block;
    font-size: 12px;
    color: #666;
    margin-top: 4px;
}

.form-error {
    display: block;
    font-size: 12px;
    color: #dc3545;
    margin-top: 4px;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* Template options */
.template-options {
    display: flex;
    gap: 20px;
    margin-top: 15px;
}

.template-option {
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 4px;
    padding: 10px;
    text-align: center;
}

.template-option:hover {
    background-color: #f1f1f1;
}

.template-option.selected {
    border-color: #007bff;
}

.template-option img {
    width: 100%;
    max-width: 150px;
    height: auto;
    border-radius: 4px;
}

.image-input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.image-url {
    flex-grow: 1;
}

.upload-button {
    background-color: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 7px 12px;
    cursor: pointer;
    color: #333;
    font-size: 0.9rem;
    white-space: nowrap;
    display: flex;
    align-items: center;
}

.upload-button:hover {
    background-color: #e0e0e0;
}

.upload-button i {
    margin-right: 5px;
}

/* Message Modal Styling */
#message-modal .modal-content {
    text-align: center;
    padding: 30px;
    max-width: 600px;
}

#message-title {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 24px;
}

#message-text {
    margin-bottom: 25px;
    font-size: 16px;
    line-height: 1.5;
    white-space: pre-line;
    text-align: left;
    max-height: 300px;
    overflow-y: auto;
}

#message-modal .modal-buttons {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

#message-ok {
    min-width: 100px;
    font-weight: bold;
}

/* Status colors */
.success-text {
    color: #28a745;
}

.error-text {
    color: #dc3545;
}

.info-text {
    color: #007bff;
}

/* Attachment Styles */
.attachment-container {
    margin-top: 8px;
    width: 100%;
}

.attachments-list {
    margin-top: 10px;
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 4px;
    padding: 4px;
    background-color: #f9f9f9;
}

.attachments-list:empty {
    display: none;
}

.attachment-size-indicator {
    margin: 10px 0;
    font-size: 12px;
    color: #666;
    display: none; /* Hidden by default, shown when attachments exist */
}

.size-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.size-bar-container {
    height: 5px;
    background-color: #e9ecef;
    border-radius: 2px;
    overflow: hidden;
}

.size-bar {
    height: 100%;
    border-radius: 2px;
}

.size-ok {
    background-color: #28a745;
}

.size-warning {
    background-color: #ffc107;
}

.size-danger {
    background-color: #dc3545;
}

.attachment-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f8f9fa;
    padding: 8px 12px;
    border-radius: 4px;
    margin-bottom: 8px;
    border: 1px solid #e0e0e0;
}

.attachment-info {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    flex: 1;
}

.attachment-icon {
    color: #6c757d;
    font-size: 16px;
    min-width: 16px;
}

.attachment-name {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attachment-size {
    font-size: 12px;
    color: #6c757d;
    margin-left: 8px;
}

.attachment-remove {
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
}

.attachment-remove:hover {
    color: #bd2130;
}

#add-attachment-button {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Send email modal specific styles */
#send-email-modal .modal-content {
    max-width: 550px;
}

/* Make sure form elements don't overflow */
.form-group {
    margin-bottom: 15px;
    width: 100%;
}

/* Make sure buttons fit in modal */
.modal form button[type="submit"] {
    margin-top: 10px;
}

.content-textarea, 
.prayer-list-textarea,
.centered-textarea {
  min-height: 100px;
  max-height: 480px; /* 20 lines x 24px line-height */
  line-height: 24px;
  overflow-y: auto;
  resize: vertical;
  width: 100%;
  box-sizing: border-box;
  font-size: 16px;
  font-family: inherit;
}

/* Contacts Modal - Updated Header */
.contacts-modal-content {
    max-width: 700px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.contacts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid black;
    background: white;
    border-radius: 8px 8px 0 0;
    margin: -20px -20px 0 -20px;
}

.contacts-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.contacts-icon {
    font-size: 24px;
    color: black;
}

.contacts-header h2 {
    margin: 0;
    color: black;
    font-size: 24px;
    font-weight: 600;
}

.contacts-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.add-contact-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background-color: rgba(255, 255, 255, 0.2);
    color: black;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.add-contact-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.close-btn {
    background: none;
    border: none;
    color: black;
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.close-btn:hover {
    transform: scale(1.1);
}

.contacts-search-bar {
    position: relative;
    margin: 20px 0 15px 0;
    padding: 0;
}

.contacts-search-bar i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 16px;
}

.contacts-search-bar input {
    width: 100%;
    padding: 12px 12px 12px 42px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.2s;
}

.contacts-search-bar input:focus {
    outline: none;
    border-color: black;
}

.add-contact-section {
    background-color: #f9f9f9;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 15px;
    border: 1px solid #e0e0e0;
}

.add-contact-section h3 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 16px;
}

.form-row {
    display: flex;
    gap: 10px;
}

.form-row .form-group {
    flex: 1;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 10px;
}

.contacts-list-view {
    flex: 1;
    overflow-y: auto;
    min-height: 300px;
}

.contact-tile {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    margin-bottom: 10px;
    transition: box-shadow 0.2s;
}

.contact-tile:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.contact-tile-content {
    flex: 1;
}

.contact-tile-name {
    font-weight: bold;
    font-size: 16px;
    margin-bottom: 4px;
    color: #333;
}

.contact-tile-email {
    font-size: 14px;
    color: #666;
    margin-bottom: 2px;
}

.contact-tile-phone {
    font-size: 13px;
    color: #999;
}

.contact-tile-actions {
    position: relative;
}

.contact-action-menu {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: #666;
    font-size: 16px;
}

.contact-action-menu:hover {
    color: #333;
}

.contact-action-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    min-width: 150px;
}

.contact-action-dropdown.show {
    display: block;
}

.contact-action-dropdown button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 15px;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    color: #333;
}

.contact-action-dropdown button:hover {
    background-color: #f5f5f5;
}

.contact-action-dropdown button i {
    width: 16px;
}

.contact-delete {
    color: #dc3545 !important;
}

.contact-delete:hover {
    background-color: #fee !important;
}

.contact-edit {
    color: #007bff !important;
}

.contact-edit:hover {
    background-color: #e7f3ff !important;
}
/* Menu Modal Header */
.menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.menu-header h2 {
    margin: 0;
}

.menu-header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.menu-contacts-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #007bff;
    color: white;
    border: none;
    padding: 10px 18px;
    margin-right: 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.menu-contacts-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.menu-contacts-btn i {
    font-size: 16px;
}
