/**
 * Elementor Webmail Widget Styles
 * @since 3.8.0
 */

.aew-webmail {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, sans-serif;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    max-width: 100%;
}

/* Header & Navigation */
.aew-webmail-header {
    padding: 15px 20px;
    border-bottom: 1px solid #ddd;
}

.aew-webmail-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.aew-nav-btn {
    padding: 8px 16px;
    border: 1px solid #ddd;
    background: #f8f9fa;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.aew-nav-btn:hover {
    background: #e9ecef;
}

.aew-nav-btn.active {
    background: #007cba;
    color: #fff;
    border-color: #007cba;
}

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

.aew-unread-badge {
    background: #d63638;
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
}

/* Search */
.aew-webmail-search {
    display: flex;
    gap: 8px;
}

.aew-search-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.aew-search-btn {
    padding: 8px 16px;
    border: 1px solid #ddd;
    background: #f8f9fa;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
}

.aew-search-btn:hover {
    background: #e9ecef;
}

/* Content Area */
.aew-webmail-content {
    position: relative;
    min-height: 400px;
}

.aew-view {
    display: none;
    padding: 20px;
}

.aew-view.active {
    display: block;
}

/* Toolbar */
.aew-toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.aew-btn {
    padding: 8px 16px;
    border: 1px solid #ddd;
    background: #f8f9fa;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.aew-btn:hover {
    background: #e9ecef;
}

.aew-btn-primary {
    background: #007cba;
    color: #fff;
    border-color: #007cba;
}

.aew-btn-primary:hover {
    background: #006ba1;
}

.aew-filter-select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
    cursor: pointer;
}

/* Message List */
.aew-message-list {
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
}

.aew-message-item {
    padding: 15px;
    border-bottom: 1px solid #ddd;
    cursor: pointer;
    transition: background-color 0.2s;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 15px;
    align-items: start;
}

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

.aew-message-item:hover {
    background-color: var(--hover-bg, #f5f5f5);
}

.aew-message-item.unread {
    background-color: var(--unread-bg, #e3f2fd);
}

.aew-message-item.read {
    background-color: var(--read-bg, #ffffff);
}

.aew-message-icon {
    font-size: 20px;
    margin-top: 2px;
}

.aew-message-item.unread .aew-message-icon {
    opacity: 1;
}

.aew-message-item.read .aew-message-icon {
    opacity: 0.3;
}

.aew-message-info {
    min-width: 0;
}

.aew-message-from {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.aew-message-item.unread .aew-message-from {
    font-weight: 700;
}

.aew-message-subject {
    font-size: 14px;
    margin-bottom: 4px;
    color: #333;
}

.aew-message-preview {
    font-size: 13px;
    color: #666;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.aew-message-date {
    font-size: 12px;
    color: #666;
    white-space: nowrap;
}

.aew-loading {
    text-align: center;
    padding: 40px;
    color: #666;
    font-size: 14px;
}

.aew-empty {
    text-align: center;
    padding: 40px;
    color: #999;
    font-size: 14px;
}

/* Pagination */
.aew-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 20px;
}

.aew-page-btn {
    padding: 8px 16px;
    border: 1px solid #ddd;
    background: #f8f9fa;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.aew-page-btn:hover:not(:disabled) {
    background: #e9ecef;
}

.aew-page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.aew-page-info {
    font-size: 14px;
    color: #666;
}

/* Compose Form */
.aew-compose-view h3 {
    margin: 0 0 20px 0;
    font-size: 20px;
    font-weight: 600;
}

.aew-compose-form {
    max-width: 800px;
}

.aew-form-group {
    margin-bottom: 20px;
}

.aew-form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 14px;
}

.aew-required {
    color: #d63638;
}

.aew-form-group input[type="text"],
.aew-form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
}

.aew-form-group textarea {
    resize: vertical;
    font-family: 'Courier New', monospace;
}

.aew-form-group small {
    display: block;
    margin-top: 6px;
    color: #666;
    font-size: 12px;
}

/* Recipients Container */
.aew-recipients-container {
    position: relative;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px;
    background: #fff;
    min-height: 45px;
}

.aew-recipient-search,
.aew-cc-search {
    border: none;
    padding: 6px;
    font-size: 14px;
    width: 100%;
    box-sizing: border-box;
}

.aew-recipient-search:focus,
.aew-cc-search:focus {
    outline: none;
}

.aew-recipient-tags,
.aew-cc-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}

.aew-recipient-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: #e3f2fd;
    border-radius: 3px;
    font-size: 13px;
}

.aew-tag-remove {
    cursor: pointer;
    font-weight: bold;
    color: #666;
}

.aew-tag-remove:hover {
    color: #d63638;
}

.aew-recipient-dropdown,
.aew-cc-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-top: 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.aew-recipient-option {
    padding: 10px 12px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid #f0f0f0;
}

.aew-recipient-option:hover {
    background: #f8f9fa;
}

.aew-recipient-option:last-child {
    border-bottom: none;
}

.aew-recipient-name {
    font-weight: 600;
    display: block;
}

.aew-recipient-email {
    font-size: 12px;
    color: #666;
}

.aew-toggle-cc {
    background: transparent;
    border: none;
    color: #007cba;
    cursor: pointer;
    font-size: 14px;
    padding: 4px 0;
}

.aew-toggle-cc:hover {
    text-decoration: underline;
}

.aew-form-actions {
    display: flex;
    gap: 10px;
    margin-top: 25px;
}

/* Message Read View */
.aew-message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 15px;
    flex-wrap: wrap;
}

.aew-message-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.aew-message-content {
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 20px;
    margin-bottom: 20px;
}

.aew-message-meta {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #ddd;
}

.aew-meta-row {
    display: grid;
    grid-template-columns: 80px 1fr;
    margin-bottom: 8px;
    font-size: 14px;
}

.aew-meta-label {
    font-weight: 600;
    color: #666;
}

.aew-meta-value {
    color: #333;
}

.aew-message-subject-display {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 15px;
}

.aew-message-body {
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 14px;
}

.aew-message-body strong {
    font-weight: 700;
}

.aew-message-body em {
    font-style: italic;
}

.aew-message-body code {
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.aew-message-body a {
    color: #007cba;
    text-decoration: none;
}

.aew-message-body a:hover {
    text-decoration: underline;
}

.aew-message-attachments {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #ddd;
}

.aew-attachments-title {
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 14px;
}

.aew-attachment-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.aew-attachment-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    text-decoration: none;
    color: #333;
}

.aew-attachment-item:hover {
    background: #f8f9fa;
    border-color: #007cba;
}

/* Thread Messages */
.aew-thread-messages {
    margin-top: 30px;
}

.aew-thread-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 15px;
}

.aew-thread-item {
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 15px;
}

.aew-thread-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 13px;
}

.aew-thread-from {
    font-weight: 600;
}

.aew-thread-date {
    color: #666;
}

.aew-thread-body {
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 14px;
}

/* Status Messages */
.aew-status-message {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    z-index: 1000;
    max-width: 400px;
}

.aew-status-message.success {
    background: #00a32a;
    color: #fff;
}

.aew-status-message.error {
    background: #d63638;
    color: #fff;
}

/* Responsive Design */
/* Desktop/PC - minimum width */
@media (min-width: 1025px) {
    .aew-webmail {
        min-width: 1000px;
    }
}

/* Tablet (768px - 1024px) */
@media (max-width: 1024px) {
    .aew-webmail-container {
        padding: 1.25rem;
    }

    .aew-webmail-header {
        padding: 0.75rem 1rem;
    }

    .aew-nav-btn {
        padding: 0.5rem 1rem;
        font-size: 0.95rem;
    }

    .aew-view {
        padding: 1.25rem;
    }
}

/* Mobile (up to 767px) */
@media (max-width: 767px) {
    .aew-webmail-container {
        padding: 1rem;
    }

    .aew-webmail-header {
        padding: 0.625rem 1rem;
    }

    .aew-webmail-nav {
        gap: 0.375rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .aew-nav-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
        min-height: 44px; /* Touch target */
        flex-shrink: 0;
    }

    .aew-view {
        padding: 1rem;
    }

    .aew-message-item {
        grid-template-columns: auto 1fr;
        gap: 0.625rem;
    }

    .aew-message-date {
        grid-column: 2;
        text-align: right;
        margin-top: 0.375rem;
        font-size: 0.85rem;
    }

    .aew-message-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .aew-message-actions {
        width: 100%;
    }

    .aew-message-actions button {
        min-height: 44px;
    }

    .aew-form-actions {
        flex-direction: column;
        gap: 0.5rem;
    }

    .aew-form-actions .aew-btn {
        width: 100%;
        min-height: 44px;
    }

    .aew-input,
    .aew-textarea,
    .aew-select {
        font-size: 16px; /* Prevent iOS zoom */
    }
}

/* Extra Small (up to 480px) */
@media (max-width: 480px) {
    .aew-webmail-container {
        padding: 0.75rem;
    }

    .aew-webmail-header {
        padding: 0.5rem 0.75rem;
    }

    .aew-nav-btn {
        padding: 0.5rem 0.625rem;
        font-size: 0.8rem;
        min-height: 48px;
    }

    .aew-view {
        padding: 0.75rem;
    }

    .aew-message-item {
        gap: 0.5rem;
    }

    .aew-form-actions .aew-btn,
    .aew-message-actions button {
        min-height: 48px;
        padding: 0.875rem 1rem;
    }
}

/* Mobile: Match user portal button styling - 25px height for all buttons */
@media (max-width: 768px) {
    .aew-btn,
    .aew-btn-primary,
    .aew-nav-btn,
    .aew-search-btn,
    .aew-page-btn,
    .aew-toggle-cc,
    button.aew-btn,
    button.aew-nav-btn,
    button.aew-page-btn,
    button.aew-search-btn {
        height: 25px !important;
        min-height: 25px !important;
        max-height: 25px !important;
        line-height: 1 !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
    }
}
