/* ============================================================================
   ANNOUNCEMENTS PANEL
   ============================================================================ */

/* Announcement Button in Header */
.notification-announcement-btn-header {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    margin-right: 0.5rem;
}

#announcements-panel {
    width: 90% !important;
    max-width: 1400px !important;
}

/* Side-by-Side Layout for Create Announcement */
.announcement-content-split {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.announcement-editor-left,
.announcement-editor-right {
    flex: 1;
}

.announcement-editor-left {
    border-right: 2px solid #e5e7eb;
    padding-right: 1.5rem;
}

.announcement-editor-right {
    padding-left: 0.5rem;
}

.announcement-preview[contenteditable="true"] {
    cursor: text;
    border-color: #4caac9;
    box-shadow: 0 0 0 3px rgba(76, 170, 201, 0.1);
    min-height: 400px;
}

.announcement-preview[contenteditable="true"]:focus {
    outline: none;
    border-color: #3d98b3;
}

.preview-edit-hint {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(76, 170, 201, 0.1);
    border: 1px solid rgba(76, 170, 201, 0.3);
    border-radius: 6px;
    font-size: 0.75rem;
    color: #4caac9;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.preview-edit-hint i {
    font-size: 0.7rem;
}

.notification-announcement-btn-header:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.notification-announcement-btn-header i {
    font-size: 0.9rem;
}

/* Panel Content */
.announcement-section {
    margin-bottom: 1.5rem;
}

.announcement-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.5rem;
}

.announcement-label-required {
    color: #ef4444;
    margin-left: 0.25rem;
}

.announcement-help-text {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 0.375rem;
    line-height: 1.4;
}

/* Input Fields */
.announcement-input {
    width: 100%;
    padding: 0.625rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.announcement-input:focus {
    outline: none;
    border-color: #4caac9;
    box-shadow: 0 0 0 3px rgba(76, 170, 201, 0.1);
}

.announcement-textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.85rem;
    font-family: 'Courier New', monospace;
    resize: vertical;
    min-height: 400px;
    transition: all 0.2s;
}

.announcement-textarea:focus {
    outline: none;
    border-color: #4caac9;
    box-shadow: 0 0 0 3px rgba(76, 170, 201, 0.1);
}

/* Preview Button */
.announcement-preview-btn {
    width: 100%;
    padding: 0.75rem;
    background: white;
    border: 2px solid #4caac9;
    border-radius: 8px;
    color: #4caac9;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.announcement-preview-btn:hover {
    background: #4caac9;
    color: white;
}

/* Preview Container */
.announcement-preview-container {
    animation: slideDown 0.3s ease;
}

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

.announcement-preview {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem;
    min-height: 150px;
    max-height: 400px;
    overflow-y: auto;
}

.preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: #9ca3af;
    text-align: center;
}

.preview-placeholder i {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

.preview-placeholder p {
    font-size: 0.875rem;
    margin: 0;
}

/* Radio Group */
.announcement-radio-group {
    display: flex;
    gap: 1rem;
}

.announcement-radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.75rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    flex: 1;
    transition: all 0.2s;
}

.announcement-radio-label:hover {
    border-color: #4caac9;
    background: rgba(76, 170, 201, 0.05);
}

.announcement-radio-label input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: #4caac9;
}

.announcement-radio-label input[type="radio"]:checked + span {
    font-weight: 600;
    color: #4caac9;
}

/* User Selection */
.user-search-container {
    margin-bottom: 1rem;
}

.user-list {
    max-height: 300px;
    overflow-y: auto;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.5rem;
}

.user-list-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem;
    color: #6b7280;
}

.user-list-loading .loading-spinner-small {
    width: 20px;
    height: 20px;
    border: 3px solid #e5e7eb;
    border-top-color: #4caac9;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.user-item:hover {
    background: #f9fafb;
}

.user-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #4caac9;
}

.user-item-info {
    flex: 1;
    min-width: 0;
}

.user-item-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-item-email {
    font-size: 0.75rem;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.selected-count {
    margin-top: 0.75rem;
    padding: 0.5rem;
    background: rgba(76, 170, 201, 0.1);
    border-radius: 6px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: #4caac9;
}

/* Send Button */
.announcement-send-btn {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, #4caac9, #3d98b3);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.announcement-send-btn:hover {
    background: linear-gradient(135deg, #3d98b3, #2e7a8f);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(76, 170, 201, 0.3);
}

.announcement-send-btn:active {
    transform: translateY(0);
}

.announcement-send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Template Selection */
.announcement-template-btn {
    width: 100%;
    padding: 0.75rem;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    color: #374151;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-align: left;
}

.announcement-template-btn:hover {
    border-color: #4caac9;
    background: rgba(76, 170, 201, 0.05);
}

.announcement-template-btn i:first-child {
    color: #4caac9;
    font-size: 1rem;
}

.announcement-template-btn span {
    flex: 1;
}

.template-arrow {
    font-size: 0.75rem;
    transition: transform 0.2s;
}

.announcement-template-btn.active .template-arrow {
    transform: rotate(180deg);
}

/* Templates Dropdown */
.templates-dropdown {
    margin-top: 0.75rem;
    background: white;
    border: 2px solid #4caac9;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-height: 400px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.templates-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #4caac9, #3d98b3);
    color: white;
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
}

.templates-header h4 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
}

.template-action-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.template-action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.templates-list {
    overflow-y: auto;
    overflow-x: hidden; /* Prevent horizontal scroll */
    max-height: 320px;
}

.templates-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem;
    color: #6b7280;
}

.templates-loading .loading-spinner-small {
    width: 20px;
    height: 20px;
    border: 3px solid #e5e7eb;
    border-top-color: #4caac9;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.template-item {
    padding: 1rem;
    border-bottom: 1px solid #e5e7eb;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-width: 0; /* Allow flex items to shrink below content size */
}

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

.template-item:hover {
    background: #f9fafb;
}

.template-item-info {
    flex: 1;
    min-width: 0; /* Allow text truncation */
    margin-right: 0.75rem; /* Space before buttons */
}

.template-item-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.25rem;
}

.template-item-preview {
    font-size: 0.75rem;
    color: #6b7280;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.template-item-actions {
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s;
    flex-shrink: 0; /* Prevent buttons from shrinking */
}

.template-item:hover .template-item-actions {
    opacity: 1;
}

/* Always show actions on mobile/touch devices */
@media (max-width: 1024px), (hover: none) {
    .template-item-actions {
        opacity: 1;
    }
}

.template-item-btn {
    background: transparent;
    border: none;
    color: #6b7280;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.template-item-btn:hover {
    background: #e5e7eb;
    color: #1f2937;
}

.template-item-btn.delete:hover {
    background: #fee2e2;
    color: #ef4444;
}

/* Template Editor Modal */
.template-editor-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.template-editor-overlay.show {
    display: flex;
}

.template-editor-modal {
    background: white;
    border-radius: 12px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.template-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, #4caac9, #3d98b3);
    color: white;
    border-radius: 12px 12px 0 0;
}

.template-editor-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.template-editor-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.template-editor-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.template-editor-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.template-editor-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.template-save-btn {
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #4caac9, #3d98b3);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.template-save-btn:hover {
    background: linear-gradient(135deg, #3d98b3, #2e7a8f);
    transform: translateY(-1px);
}

.template-cancel-btn {
    padding: 0.75rem 1.5rem;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    color: #374151;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.template-cancel-btn:hover {
    border-color: #d1d5db;
    background: #f9fafb;
}

/* Empty state */
.templates-empty {
    padding: 3rem 2rem;
    text-align: center;
    color: #9ca3af;
}

.templates-empty i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.templates-empty p {
    font-size: 0.875rem;
    margin: 0;
}

/* Template Editor - Side by Side Layout */
.template-editor-with-preview {
    max-width: 1400px;
    width: 95%;
}

.template-editor-split {
    display: flex;
    gap: 1.5rem;
    padding: 1.5rem;
    overflow: hidden;
}

.template-editor-left,
.template-editor-right {
    flex: 1;
    overflow-y: auto;
    max-height: calc(80vh - 180px);
}

.template-editor-left {
    border-right: 2px solid #e5e7eb;
    padding-right: 1.5rem;
}

.template-editor-right {
    padding-left: 0.5rem;
}

.template-editor-textarea {
    min-height: 400px;
    font-size: 0.85rem;
    line-height: 1.5;
}

.template-editor-preview {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    padding: 1.5rem;
    min-height: 400px;
    overflow-y: auto;
    position: sticky;
    top: 0;
}


/* Editable Preview Styles */
.announcement-preview[contenteditable="true"] {
    cursor: text;
    border-color: #4caac9;
    box-shadow: 0 0 0 3px rgba(76, 170, 201, 0.1);
}

.announcement-preview[contenteditable="true"]:focus {
    outline: none;
    border-color: #3d98b3;
}

.template-editor-preview[contenteditable="true"] {
    cursor: text;
    border-color: #4caac9;
    box-shadow: 0 0 0 3px rgba(76, 170, 201, 0.1);
}

.template-editor-preview[contenteditable="true"]:focus {
    outline: none;
    border-color: #3d98b3;
}

/* Edit Mode Indicator */
.edit-mode-indicator {
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(76, 170, 201, 0.1);
    border: 1px solid rgba(76, 170, 201, 0.3);
    border-radius: 6px;
    font-size: 0.75rem;
    color: #4caac9;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.edit-mode-indicator.active {
    display: flex;
}

.edit-mode-indicator i {
    font-size: 0.7rem;
}

/* Mobile adjustments for template editor */
@media (max-width: 1024px) {
    .template-editor-overlay {
        padding: 0; /* Remove padding for full screen */
    }
    
    .template-editor-with-preview {
        width: 100%;
        max-width: 100%;
        max-height: 100vh; /* Full height */
        border-radius: 0; /* Remove rounded corners on mobile */
    }
    
    .template-editor-header {
        border-radius: 0; /* Match modal */
    }
    
    .template-editor-split {
        flex-direction: column;
        max-height: none; /* Allow natural scrolling */
        overflow-y: auto; /* Enable scrolling for entire body */
        overflow-x: hidden;
    }
    
    .template-editor-left {
        border-right: none;
        border-bottom: 2px solid #e5e7eb;
        padding-right: 0;
        padding-bottom: 1.5rem;
        max-height: none; /* Remove height restriction */
        overflow-y: visible; /* No individual scroll */
    }
    
    .template-editor-right {
        padding-left: 0;
        padding-top: 0.5rem;
        max-height: none; /* Remove height restriction */
        overflow-y: visible; /* No individual scroll */
    }
    
    .template-editor-textarea {
        min-height: 500px; /* Much bigger on mobile */
        max-height: none;
    }
    
    .template-editor-preview {
        position: static;
        min-height: 400px; /* Taller preview too */
    }
    
    .template-editor-footer {
        position: sticky;
        bottom: 0;
        background: white;
        z-index: 10;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    }
}

/* Mobile adjustments */
@media (max-width: 1024px) {
    .template-editor-overlay {
        padding: 1rem;
    }
    
    .template-editor-modal {
        max-height: 90vh;
    }
}

/* Mobile Adjustments */
@media (max-width: 1024px) {
    .announcement-section {
        margin-bottom: 1.25rem;
    }

    .announcement-textarea {
        min-height: 150px;
        font-size: 0.8rem;
    }

    .announcement-radio-group {
        flex-direction: column;
        gap: 0.5rem;
    }

    .user-list {
        max-height: 200px;
    }
}

@media (max-width: 1024px) {
    #announcements-panel {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .announcement-content-split {
        flex-direction: column;
        gap: 1rem;
    }
    
    .announcement-editor-left {
        border-right: none;
        border-bottom: 2px solid #e5e7eb;
        padding-right: 0;
        padding-bottom: 1rem;
    }
    
    .announcement-editor-right {
        padding-left: 0;
    }
}

