/**
 * Inbox Module Styles
 * Clean, professional email client UI
 * @version 2.0
 * @date Jan 11, 2026
 */

/* ============================================
   HIDE PAGE SCROLLBAR WHEN INBOX IS VISIBLE
   The inbox is self-contained and doesn't need page scroll
   ============================================ */

body:has(.inbox-app) {
    overflow: hidden;
}

/* Fallback for browsers that don't support :has() */
body.inbox-view {
    overflow: hidden;
}

/* ============================================
   MAIN LAYOUT
   ============================================ */

.inbox-app {
    display: flex;
    height: calc(100vh - 80px);
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.05);
    margin: -24px;
}

.inbox-sidebar {
    width: 240px;
    min-width: 240px;
    flex-shrink: 0;
    border-right: 1px solid #e5e7eb;
    background: #fafbfc;
    display: flex;
    flex-direction: column;
    padding: 16px;
}

.inbox-list {
    width: 400px;
    min-width: 400px;
    flex-shrink: 0;
    border-right: 1px solid #e5e7eb;
    background: #fff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.inbox-detail {
    flex: 1;
    min-width: 400px;
    background: #fff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.inbox-customer-panel {
    width: 320px;
    min-width: 320px;
    flex-shrink: 0;
    border-left: 1px solid #e5e7eb;
    background: #fafbfc;
    overflow-y: auto;
}

.inbox-customer-panel.hidden {
    display: none;
}

/* ============================================
   SIDEBAR
   ============================================ */

.inbox-sidebar .compose-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    margin-bottom: 20px;
}

.inbox-sidebar .compose-btn:hover {
    background: #1d4ed8;
}

.inbox-sidebar .compose-btn svg {
    width: 18px;
    height: 18px;
}

.inbox-sidebar .account-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
    margin-bottom: 16px;
}

.inbox-sidebar nav {
    margin-bottom: 20px;
}

.inbox-sidebar .folder-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    color: #4b5563;
    font-size: 14px;
    transition: all 0.15s;
    margin-bottom: 2px;
}

.inbox-sidebar .folder-item:hover {
    background: #e5e7eb;
}

.inbox-sidebar .folder-item.active {
    background: #dbeafe;
    color: #1d4ed8;
    font-weight: 500;
}

.inbox-sidebar .folder-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.inbox-sidebar .folder-item .count {
    margin-left: auto;
    font-size: 12px;
    background: #e5e7eb;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 24px;
    text-align: center;
}

.inbox-sidebar .folder-item.active .count {
    background: #bfdbfe;
}

.inbox-sidebar .section-title {
    font-size: 11px;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    padding: 0 12px;
}

.inbox-sidebar .settings-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    color: #6b7280;
    font-size: 14px;
    transition: all 0.15s;
    margin-top: auto;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.inbox-sidebar .settings-btn:hover {
    background: #e5e7eb;
    color: #374151;
}

/* ============================================
   THREAD LIST
   ============================================ */

.inbox-list .search-container {
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
}

.inbox-list .search-wrapper {
    position: relative;
}

.inbox-list .search-input {
    width: 100%;
    padding: 10px 12px 10px 40px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.inbox-list .search-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.inbox-list .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    width: 18px;
    height: 18px;
}

/* Filters */
.inbox-list .filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    flex-wrap: wrap;
}

.inbox-list .filter-btn {
    padding: 6px 14px;
    font-size: 13px;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    background: #fff;
    cursor: pointer;
    transition: all 0.15s;
    color: #4b5563;
}

.inbox-list .filter-btn:hover {
    border-color: #d1d5db;
    background: #f9fafb;
}

.inbox-list .filter-btn.active {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

.inbox-list .filter-sort {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.inbox-list .filter-sort select {
    padding: 6px 10px;
    font-size: 13px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
}

.inbox-list .filter-sort .more-filters {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    font-size: 13px;
    color: #2563eb;
    cursor: pointer;
    border: none;
    background: none;
}

.inbox-list .filter-sort .more-filters:hover {
    text-decoration: underline;
}

/* Thread count */
.inbox-list .thread-count {
    padding: 8px 16px;
    font-size: 12px;
    color: #6b7280;
    border-bottom: 1px solid #f3f4f6;
    background: #fafbfc;
}

/* Thread items container */
.inbox-list .thread-items {
    flex: 1;
    overflow-y: auto;
}

/* Individual thread item */
.inbox-thread-item {
    padding: 14px 16px;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    transition: background 0.1s;
    position: relative;
}

.inbox-thread-item:hover {
    background: #f9fafb;
}

.inbox-thread-item.selected {
    background: #eff6ff;
    border-left: 3px solid #2563eb;
    padding-left: 13px;
}

.inbox-thread-item.unread {
    background: #fff;
}

.inbox-thread-item.unread::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    background: #2563eb;
    border-radius: 50%;
}

.inbox-thread-item .thread-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 4px;
}

.inbox-thread-item .thread-sender {
    font-weight: 500;
    color: #111827;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.inbox-thread-item.unread .thread-sender {
    font-weight: 600;
}

.inbox-thread-item .thread-time {
    font-size: 12px;
    color: #9ca3af;
    flex-shrink: 0;
}

.inbox-thread-item .thread-subject {
    color: #374151;
    font-size: 14px;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 20px;
}

.inbox-thread-item.unread .thread-subject {
    color: #111827;
    font-weight: 500;
}

.inbox-thread-item .thread-snippet {
    color: #6b7280;
    font-size: 13px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.inbox-thread-item .thread-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.inbox-thread-item .meta-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.inbox-thread-item .meta-badge.stripe {
    background: #eff6ff;
    color: #1d4ed8;
}

.inbox-thread-item .meta-badge.user {
    background: #f0fdf4;
    color: #15803d;
}

.inbox-thread-item .meta-badge.unknown {
    background: #f3f4f6;
    color: #6b7280;
}

.inbox-thread-item .meta-badge svg {
    width: 12px;
    height: 12px;
}

.inbox-thread-item .msg-count {
    font-size: 11px;
    color: #9ca3af;
}

/* Load more */
.inbox-list .load-more {
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
}

.inbox-list .load-more button {
    width: 100%;
    padding: 10px;
    font-size: 13px;
    color: #2563eb;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.inbox-list .load-more button:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

/* ============================================
   THREAD DETAIL (Center panel)
   ============================================ */

.inbox-detail .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #9ca3af;
    text-align: center;
    padding: 40px;
}

.inbox-detail .empty-state svg {
    width: 64px;
    height: 64px;
    color: #d1d5db;
    margin-bottom: 16px;
}

.inbox-detail .empty-state h3 {
    font-size: 16px;
    font-weight: 500;
    color: #6b7280;
    margin-bottom: 8px;
}

.inbox-detail .empty-state p {
    font-size: 14px;
    color: #9ca3af;
}

.inbox-detail .detail-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.inbox-detail .detail-subject {
    font-size: 18px;
    font-weight: 600;
    color: #111827;
}

.inbox-detail .detail-tags {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.inbox-detail .detail-actions {
    display: flex;
    gap: 4px;
}

.inbox-detail .detail-actions button {
    padding: 8px;
    border-radius: 6px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: #6b7280;
    transition: all 0.15s;
}

.inbox-detail .detail-actions button:hover {
    background: #f3f4f6;
    color: #111827;
}

.inbox-detail .detail-actions button svg {
    width: 20px;
    height: 20px;
}

/* Messages */
.inbox-detail .messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.inbox-message {
    margin-bottom: 16px;
    padding: 16px;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #f3f4f6;
}

.inbox-message.outbound {
    background: #eff6ff;
    border-color: #dbeafe;
    margin-left: 40px;
}

.inbox-message .message-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.inbox-message .message-sender {
    font-weight: 500;
    color: #111827;
    font-size: 14px;
}

.inbox-message .message-email {
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
}

.inbox-message .message-time {
    font-size: 12px;
    color: #9ca3af;
}

.inbox-message .message-body {
    color: #374151;
    font-size: 14px;
    line-height: 1.7;
}

.inbox-message .message-body p {
    margin-bottom: 12px;
}

.inbox-message .message-body a {
    color: #2563eb;
}

/* Reply composer */
.inbox-detail .reply-composer {
    padding: 16px 20px;
    border-top: 1px solid #e5e7eb;
    background: #fafbfc;
}

.inbox-detail .reply-composer textarea {
    width: 100%;
    min-height: 120px;
    padding: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    resize: vertical;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.6;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.inbox-detail .reply-composer textarea:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.inbox-detail .reply-composer .composer-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
}

.inbox-detail .reply-composer .composer-tools {
    display: flex;
    gap: 4px;
}

.inbox-detail .reply-composer .composer-tools button {
    padding: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: #6b7280;
    border-radius: 4px;
}

.inbox-detail .reply-composer .composer-tools button:hover {
    background: #e5e7eb;
}

.inbox-detail .reply-composer .send-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.inbox-detail .reply-composer .send-btn:hover {
    background: #1d4ed8;
}

/* ============================================
   CUSTOMER PANEL (Right sidebar)
   ============================================ */

.inbox-customer-panel .panel-header {
    padding: 16px;
    border-bottom: 1px solid #e5e7eb;
}

.inbox-customer-panel .customer-name {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 4px;
}

.inbox-customer-panel .customer-email {
    font-size: 13px;
    color: #6b7280;
}

.inbox-customer-panel .panel-section {
    padding: 16px;
    border-bottom: 1px solid #e5e7eb;
}

.inbox-customer-panel .section-title {
    font-size: 11px;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.inbox-customer-panel .info-grid {
    display: grid;
    gap: 10px;
}

.inbox-customer-panel .info-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}

.inbox-customer-panel .info-label {
    color: #6b7280;
}

.inbox-customer-panel .info-value {
    color: #111827;
    font-weight: 500;
    text-align: right;
}

.inbox-customer-panel .status-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.inbox-customer-panel .status-badge.active {
    background: #dcfce7;
    color: #15803d;
}

.inbox-customer-panel .status-badge.canceled {
    background: #fee2e2;
    color: #dc2626;
}

.inbox-customer-panel .status-badge.past-due {
    background: #fef3c7;
    color: #d97706;
}

/* Other threads */
.inbox-customer-panel .other-threads {
    padding: 0;
}

.inbox-customer-panel .other-thread-item {
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    transition: background 0.1s;
}

.inbox-customer-panel .other-thread-item:hover {
    background: #f3f4f6;
}

.inbox-customer-panel .other-thread-item .thread-subject {
    font-size: 13px;
    color: #374151;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inbox-customer-panel .other-thread-item .thread-meta {
    font-size: 11px;
    color: #9ca3af;
}

/* ============================================
   EMPTY STATES
   ============================================ */

.inbox-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px;
    text-align: center;
}

.inbox-empty svg {
    width: 64px;
    height: 64px;
    color: #d1d5db;
    margin-bottom: 16px;
}

.inbox-empty h3 {
    font-size: 16px;
    font-weight: 500;
    color: #6b7280;
    margin-bottom: 8px;
}

.inbox-empty p {
    font-size: 14px;
    color: #9ca3af;
}

/* ============================================
   LOADING STATES
   ============================================ */

.inbox-skeleton {
    animation: inbox-pulse 1.5s ease-in-out infinite;
}

@keyframes inbox-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.inbox-skeleton-line {
    height: 12px;
    background: #e5e7eb;
    border-radius: 4px;
    margin-bottom: 8px;
}

.inbox-skeleton-line.short {
    width: 60%;
}

.inbox-skeleton-line.medium {
    width: 80%;
}

/* ============================================
   UTILITY OVERRIDES
   ============================================ */

/* Override any conflicting Tailwind-like classes */
.inbox-app .flex { display: flex; }
.inbox-app .flex-col { flex-direction: column; }
.inbox-app .flex-1 { flex: 1; }
.inbox-app .items-center { align-items: center; }
.inbox-app .justify-center { justify-content: center; }
.inbox-app .justify-between { justify-content: space-between; }
.inbox-app .gap-2 { gap: 8px; }
.inbox-app .gap-3 { gap: 12px; }
.inbox-app .hidden { display: none !important; }
.inbox-app .h-full { height: 100%; }
.inbox-app .w-full { width: 100%; }
.inbox-app .overflow-hidden { overflow: hidden; }
.inbox-app .overflow-auto { overflow: auto; }
.inbox-app .overflow-y-auto { overflow-y: auto; }
.inbox-app .border-r { border-right: 1px solid #e5e7eb; }
.inbox-app .border-l { border-left: 1px solid #e5e7eb; }
.inbox-app .border-b { border-bottom: 1px solid #e5e7eb; }
.inbox-app .border-t { border-top: 1px solid #e5e7eb; }
.inbox-app .p-3 { padding: 12px; }
.inbox-app .p-4 { padding: 16px; }
.inbox-app .px-3 { padding-left: 12px; padding-right: 12px; }
.inbox-app .py-2 { padding-top: 8px; padding-bottom: 8px; }
.inbox-app .text-sm { font-size: 14px; }
.inbox-app .text-xs { font-size: 12px; }
.inbox-app .font-medium { font-weight: 500; }
.inbox-app .text-gray-500 { color: #6b7280; }
.inbox-app .text-gray-600 { color: #4b5563; }
.inbox-app .bg-white { background: #fff; }
.inbox-app .bg-gray-50 { background: #fafbfc; }
.inbox-app .rounded-lg { border-radius: 8px; }

/* Fix SVG icons */
.inbox-app svg {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}

/* SVG sizing utilities */
.inbox-app .w-4 { width: 16px; }
.inbox-app .h-4 { height: 16px; }
.inbox-app .w-5 { width: 20px; }
.inbox-app .h-5 { height: 20px; }
.inbox-app .w-6 { width: 24px; }
.inbox-app .h-6 { height: 24px; }

.inbox-app svg.w-4 { width: 16px; height: 16px; }
.inbox-app svg.w-5 { width: 20px; height: 20px; }
.inbox-app svg.h-5 { width: 20px; height: 20px; }
.inbox-app svg.w-6 { width: 24px; height: 24px; }

/* Compose button fix */
.inbox-sidebar .compose-btn svg {
    width: 18px !important;
    height: 18px !important;
}

/* Search icon fix */
.inbox-list .search-wrapper svg {
    width: 18px !important;
    height: 18px !important;
}

/* Folder icons fix */
.inbox-sidebar .folder-item svg,
.inbox-sidebar button svg {
    width: 18px !important;
    height: 18px !important;
}

/* Empty state icon fix */
.inbox-detail .empty-state svg,
.inbox-empty svg {
    width: 64px !important;
    height: 64px !important;
    color: #d1d5db;
}

/* Thread action button icons */
.inbox-detail .detail-actions button svg {
    width: 20px !important;
    height: 20px !important;
}

/* Customer panel icons */
.inbox-customer-panel svg {
    width: 16px;
    height: 16px;
}

/* Responsive */
@media (max-width: 1200px) {
    .inbox-customer-panel {
        display: none;
    }
}

@media (max-width: 900px) {
    .inbox-sidebar {
        width: 200px;
        min-width: 200px;
    }
    
    .inbox-list {
        width: 320px;
        min-width: 320px;
    }
}

/* ============================================
   LAZY LOADING IMAGES
   ============================================ */

/* Image loading placeholder */
.inbox-lazy-img {
    opacity: 1;
    transition: opacity 0.3s ease, transform 0.3s ease;
    background: #f3f4f6;
    border-radius: 8px;
}

/* Loading animation */
.inbox-lazy-img[data-loading="true"] {
    animation: inbox-img-pulse 1.5s ease-in-out infinite;
}

@keyframes inbox-img-pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 0.4; }
}

/* Loaded state */
.inbox-lazy-img.inbox-img-loaded {
    animation: none;
    background: transparent;
}

/* Image error state */
.inbox-lazy-img[data-error="true"] {
    border: 2px dashed #e5e7eb;
    cursor: pointer;
}

/* Message inline images - !important to override inline width/style from emails */
#inbox-messages-container img {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    border-radius: 8px;
}

/* Smooth reveal animation */
@keyframes inbox-img-reveal {
    from {
        opacity: 0;
        transform: scale(0.98);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.inbox-img-loaded {
    animation: inbox-img-reveal 0.3s ease forwards;
}
