/* Message System Design CSS */

/* Inherit wizard color variables */
:root {
    --wizard-primary: #8B2784;
    --wizard-primary-light: #B63FAF;
    --wizard-secondary: #2C5CC5;
    --wizard-success: #28a745;
    --wizard-warning: #ffc107;
    --wizard-danger: #dc3545;
    --wizard-light-gray: #f8f9fa;
    --wizard-medium-gray: #6c757d;
    --wizard-dark-gray: #343a40;
    --wizard-white: #ffffff;
    --wizard-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --wizard-shadow-lg: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --wizard-border-radius: 0.375rem;
    --wizard-border-radius-lg: 0.5rem;
}

/* Message System Container */
.message-system-container {
    background-color: var(--wizard-light-gray);
    min-height: 100vh;
    padding: 2rem 1rem;
}

.message-system-header {
    background: linear-gradient(135deg, var(--wizard-primary) 0%, var(--wizard-secondary) 100%);
    color: var(--wizard-white);
    padding: 2.5rem 2rem;
    text-align: center;
    border-radius: var(--wizard-border-radius-lg);
    margin-bottom: 2rem;
    box-shadow: var(--wizard-shadow-lg);
}

.message-system-title {
    font-size: 2.25rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--wizard-white);
}

.message-system-subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 0;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* Quick Replies Cards Layout */
.quick-replies-container {
    max-width: 1400px;
    margin: 0 auto;
}

.quick-replies-actions {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.template-card {
    background: var(--wizard-white);
    border-radius: var(--wizard-border-radius-lg);
    box-shadow: var(--wizard-shadow);
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid #e9ecef;
    position: relative;
}

.template-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--wizard-shadow-lg);
}

.template-card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #f1f3f4;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.template-card-info {
    flex: 1;
}

.template-shortcut {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--wizard-primary);
    margin: 0 0 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.template-meta {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.template-meta-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.85rem;
    color: var(--wizard-medium-gray);
}

.template-card-actions {
    display: flex;
    gap: 0.5rem;
}

.template-action-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--wizard-border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.85rem;
}

.template-action-btn.edit {
    background: #f3e5f5;
    color: var(--wizard-primary);
}

.template-action-btn.delete {
    background: #ffebee;
    color: var(--wizard-danger);
}

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

.template-card-content {
    padding: 1.25rem 1.5rem;
}

.template-caption-preview {
    font-size: 0.95rem;
    color: var(--wizard-dark-gray);
    line-height: 1.5;
    margin-bottom: 1rem;
    max-height: 4.5em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.template-image-preview {
    width: 100%;
    max-height: 150px;
    object-fit: cover;
    border-radius: var(--wizard-border-radius);
    margin-bottom: 1rem;
}

.template-footer {
    padding: 1rem 1.5rem;
    background: #f8f9fa;
    border-top: 1px solid #f1f3f4;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.template-page-tag {
    background: var(--wizard-secondary);
    color: var(--wizard-white);
    padding: 0.25rem 0.75rem;
    border-radius: var(--wizard-border-radius);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Service and Language Icons */
.service-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 600;
}

.service-icon.whatsapp {
    background: #25D366;
    color: var(--wizard-white);
}

.service-icon.email {
    background: #1976d2;
    color: var(--wizard-white);
}

.language-flag {
    width: 20px;
    height: 14px;
    border-radius: 2px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 600;
    border: 1px solid #dee2e6;
}

.language-flag.en {
    background: #012169;
    color: var(--wizard-white);
}

.language-flag.pt {
    background: #046A38;
    color: var(--wizard-white);
}

/* Multi-Step Wizard Dialog */
/* Bootstrap Modal Styling for Template Wizard */
.template-wizard-modal {
    z-index: 1055 !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
}

.template-wizard-modal .modal-dialog {
    max-width: 900px;
    position: relative !important;
    z-index: 1056 !important;
}

.template-wizard-content {
    border: none;
    border-radius: var(--wizard-border-radius-lg);
    box-shadow: var(--wizard-shadow-lg);
    overflow: hidden;
}

.template-wizard-header {
    background: linear-gradient(135deg, var(--wizard-primary) 0%, var(--wizard-secondary) 100%);
    color: var(--wizard-white);
    padding: 1.5rem 2rem;
    border-radius: var(--wizard-border-radius-lg) var(--wizard-border-radius-lg) 0 0;
}

.wizard-step-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
}

.wizard-step-subtitle {
    font-size: 1rem;
    opacity: 0.9;
    margin: 0;
}

.wizard-step-progress {
    background: var(--wizard-white);
    padding: 1rem 2rem;
    margin: 0 -1rem;
    border-bottom: 1px solid #e9ecef;
}

.step-progress-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

.step-indicator {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.step-indicator.completed {
    background: var(--wizard-success);
    color: var(--wizard-white);
}

.step-indicator.active {
    background: var(--wizard-primary);
    color: var(--wizard-white);
}

.step-indicator.pending {
    background: #e9ecef;
    color: var(--wizard-medium-gray);
}

.step-connector {
    width: 40px;
    height: 2px;
    background: #e9ecef;
    transition: all 0.3s ease;
}

.step-connector.completed {
    background: var(--wizard-success);
}

.wizard-step-content {
    padding: 2rem;
}

/* Step 1: Basic Info */
.basic-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-label {
    font-weight: 600;
    color: var(--wizard-dark-gray);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.form-input {
    padding: 0.75rem 1rem !important;
    border: 2px solid #e9ecef !important;
    border-radius: var(--wizard-border-radius) !important;
    font-size: 1rem !important;
    transition: border-color 0.3s ease !important;
}

.form-input:focus {
    border-color: var(--wizard-primary) !important;
    box-shadow: 0 0 0 0.2rem rgba(139, 39, 132, 0.25) !important;
    outline: none !important;
}

.form-select {
    padding: 0.75rem 1rem !important;
    border: 2px solid #e9ecef !important;
    border-radius: var(--wizard-border-radius) !important;
    background: var(--wizard-white) !important;
    transition: border-color 0.3s ease !important;
}

.form-select:focus {
    border-color: var(--wizard-primary) !important;
    box-shadow: 0 0 0 0.2rem rgba(139, 39, 132, 0.25) !important;
}

/* Step 2: Content */
.content-section {
    margin-bottom: 2rem;
}

.rich-editor-container {
    border: 2px solid #e9ecef;
    border-radius: var(--wizard-border-radius);
    overflow: hidden;
    transition: border-color 0.3s ease;
}

.rich-editor-container:focus-within {
    border-color: var(--wizard-primary);
    box-shadow: 0 0 0 0.2rem rgba(139, 39, 132, 0.25);
}

.format-preview-toggle {
    background: var(--wizard-light-gray);
    padding: 1rem;
    border-radius: var(--wizard-border-radius);
    margin-top: 1rem;
}

.format-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.format-tab {
    padding: 0.5rem 1rem;
    border: 1px solid #dee2e6;
    border-radius: var(--wizard-border-radius);
    background: var(--wizard-white);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.format-tab.active {
    background: var(--wizard-primary);
    color: var(--wizard-white);
    border-color: var(--wizard-primary);
}

.format-preview {
    padding: 1rem;
    background: var(--wizard-white);
    border: 1px solid #dee2e6;
    border-radius: var(--wizard-border-radius);
    min-height: 100px;
    font-family: monospace;
    white-space: pre-wrap;
    font-size: 0.9rem;
}

.image-upload-section {
    margin-top: 1.5rem;
}

.image-upload-area {
    border: 2px dashed #dee2e6;
    border-radius: var(--wizard-border-radius-lg);
    padding: 2rem;
    text-align: center;
    background: #fafbfc;
    transition: all 0.3s ease;
    cursor: pointer;
}

.image-upload-area:hover {
    border-color: var(--wizard-primary-light);
    background: #f8f9fa;
}

.image-upload-area.has-image {
    border-style: solid;
    border-color: var(--wizard-success);
    background: #f8fff9;
}

.upload-icon {
    font-size: 2rem;
    color: var(--wizard-medium-gray);
    margin-bottom: 1rem;
}

.image-preview {
    max-width: 200px;
    max-height: 200px;
    border-radius: var(--wizard-border-radius);
    margin-bottom: 1rem;
}

/* Step 3: Preview */
.preview-container {
    background: var(--wizard-white);
    border: 1px solid #e9ecef;
    border-radius: var(--wizard-border-radius-lg);
    overflow: hidden;
}

.preview-header {
    background: var(--wizard-light-gray);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.preview-device-icon {
    font-size: 1.5rem;
    color: var(--wizard-primary);
}

.preview-device-info h4 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--wizard-dark-gray);
}

.preview-device-info small {
    color: var(--wizard-medium-gray);
}

.preview-content {
    padding: 2rem;
}

.preview-meta {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #f1f3f4;
}

.preview-meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--wizard-medium-gray);
}

.preview-message {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--wizard-dark-gray);
    margin-bottom: 1rem;
}

.preview-image {
    max-width: 100%;
    border-radius: var(--wizard-border-radius);
    margin-bottom: 1rem;
}

/* Wizard Navigation */
.wizard-navigation {
    padding: 1.5rem 2rem;
    background: var(--wizard-light-gray);
    border-top: 1px solid #e9ecef;
    margin: 0 -1rem -1rem -1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.wizard-nav-left,
.wizard-nav-right {
    display: flex;
    gap: 1rem;
}

.wizard-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--wizard-border-radius);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.wizard-btn-primary {
    background: linear-gradient(135deg, var(--wizard-primary) 0%, var(--wizard-primary-light) 100%);
    color: var(--wizard-white);
    box-shadow: var(--wizard-shadow);
}

.wizard-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--wizard-shadow-lg);
}

.wizard-btn-secondary {
    background: var(--wizard-white);
    color: var(--wizard-medium-gray);
    border: 2px solid #e9ecef;
}

.wizard-btn-secondary:hover {
    border-color: var(--wizard-primary-light);
    color: var(--wizard-primary);
}

.wizard-btn-success {
    background: linear-gradient(135deg, var(--wizard-success) 0%, #20c997 100%);
    color: var(--wizard-white);
}

.wizard-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Empty State */
.templates-empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--wizard-white);
    border-radius: var(--wizard-border-radius-lg);
    box-shadow: var(--wizard-shadow);
}

.empty-state-icon {
    font-size: 4rem;
    color: var(--wizard-medium-gray);
    margin-bottom: 2rem;
}

.empty-state-title {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--wizard-dark-gray);
    margin-bottom: 1rem;
}

.empty-state-description {
    font-size: 1.1rem;
    color: var(--wizard-medium-gray);
    margin-bottom: 2rem;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

/* Loading State */
.templates-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    background: var(--wizard-white);
    border-radius: var(--wizard-border-radius-lg);
    box-shadow: var(--wizard-shadow);
}

.loading-spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--wizard-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Placeholder Support */
.placeholders-help {
    background: #cce5ff;
    border: 1px solid #b3d7ff;
    border-radius: var(--wizard-border-radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

.placeholders-title {
    font-weight: 600;
    color: #004085;
    margin-bottom: 0.5rem;
}

.placeholders-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.placeholders-list li {
    padding: 0.25rem 0;
    font-family: monospace;
    font-size: 0.9rem;
    color: #004085;
}

/* Responsive Design */
@media (max-width: 768px) {
    .message-system-container {
        padding: 1rem 0.5rem;
    }
    
    .message-system-header {
        padding: 2rem 1rem;
    }
    
    .message-system-title {
        font-size: 1.75rem;
    }
    
    .templates-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 1rem;
    }
    
    .template-card-header {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .template-card-actions {
        justify-content: center;
    }
    
    .basic-info-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .wizard-step-content {
        padding: 1rem;
    }
    
    .wizard-navigation {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
    }
    
    .wizard-nav-left,
    .wizard-nav-right {
        width: 100%;
        justify-content: center;
    }
    
    .step-progress-bar {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .step-connector {
        width: 2px;
        height: 20px;
    }
}

@media (max-width: 576px) {
    .templates-grid {
        grid-template-columns: 1fr;
    }
    
    .template-meta {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .format-tabs {
        flex-direction: column;
    }
    
    .wizard-btn {
        width: 100%;
        justify-content: center;
    }
}

/* Scheduled Messages System */
.scheduled-messages-container {
    max-width: 1400px;
    margin: 0 auto;
}

.messages-filters {
    background: var(--wizard-white);
    border-radius: var(--wizard-border-radius-lg);
    box-shadow: var(--wizard-shadow);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    align-items: end;
}

.messages-grid-container {
    background: var(--wizard-white);
    border-radius: var(--wizard-border-radius-lg);
    box-shadow: var(--wizard-shadow);
    overflow: hidden;
}

.message-status-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 0.8rem;
}

.message-status-indicator.sent {
    background: var(--wizard-success);
    color: var(--wizard-white);
}

.message-status-indicator.pending {
    background: var(--wizard-warning);
    color: var(--wizard-white);
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

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

.slide-up {
    animation: slideUp 0.3s ease-out;
}

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

/* Utility Classes */
.text-center { text-align: center; }
.text-muted { color: var(--wizard-medium-gray) !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.5rem !important; }
.mb-2 { margin-bottom: 1rem !important; }
.mb-3 { margin-bottom: 1.5rem !important; }
.mb-4 { margin-bottom: 2rem !important; }
.mt-2 { margin-top: 1rem !important; }
.mt-3 { margin-top: 1.5rem !important; }
.mt-4 { margin-top: 2rem !important; }
.w-100 { width: 100% !important; }
.d-flex { display: flex !important; }
.align-items-center { align-items: center !important; }
.justify-content-center { justify-content: center !important; }
.gap-1 { gap: 0.5rem !important; }
.gap-2 { gap: 1rem !important; }

/* ===== QR CODE RESPONSIVE STYLES ===== */

/* QR Code Container */
.qr-code-container {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: hidden; /* Prevent overflow */
    width: 100%;
    box-sizing: border-box;
}

/* QR Code Inner Container */
.qr-code-inner {
    transform-origin: center top;
    display: flex;
    justify-content: center;
    width: auto;
    max-width: none;
}

/* QR Code Text */
.qr-code-text {
    font-size: 8px;
    line-height: 8px;
    margin: 0;
    font-family: 'Courier New', Courier, monospace;
    white-space: pre;
    text-align: center;
}

/* Desktop and Large Screens */
@media (min-width: 768px) {
    .qr-code-inner {
        transform: scale(0.4);
    }
}

/* Tablet Portrait */
@media (max-width: 767px) and (min-width: 577px) {
    .qr-code-inner {
        transform: scale(0.35);
    }
}

/* Mobile Landscape and Small Tablets */
@media (max-width: 576px) and (min-width: 481px) {
    .qr-code-inner {
        transform: scale(0.3);
    }
}

/* iPhone Portrait Mode - Most Critical */
@media (max-width: 480px) {
    .qr-code-container {
        padding: 0.75rem 0.5rem; /* Reduce padding on very small screens */
    }
    
    .qr-code-inner {
        transform: scale(0.25); /* Smaller scale for iPhone portrait */
    }
}

/* Extra Small Phones (iPhone SE, etc.) */
@media (max-width: 380px) {
    .qr-code-container {
        padding: 0.5rem 0.25rem;
    }
    
    .qr-code-inner {
        transform: scale(0.22); /* Even smaller for very narrow screens */
    }
    
    .qr-code-text {
        font-size: 7px;
        line-height: 7px;
    }
}

/* High DPI Displays (Retina) - Ensure clarity */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .qr-code-text {
        -webkit-font-smoothing: none;
        -moz-osx-font-smoothing: unset;
    }
}