/* Mailbox Improved.css - Interface de messagerie améliorée */

/* === STRUCTURE PRINCIPALE === */
.mailbox-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease-out;
}

.mailbox-content {
    background: linear-gradient(135deg, rgba(13, 21, 46, 0.98) 0%, rgba(27, 38, 79, 0.98) 100%);
    border: 2px solid rgba(0, 168, 255, 0.5);
    border-radius: 20px;
    width: 90%;
    max-width: 1200px;
    height: 85%;
    max-height: 800px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 50px rgba(0, 168, 255, 0.3);
    overflow: hidden;
    backdrop-filter: blur(10px);
}

/* === HEADER === */
.mailbox-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    background: linear-gradient(135deg, rgba(0, 168, 255, 0.15) 0%, rgba(138, 43, 226, 0.15) 100%);
    border-bottom: 2px solid rgba(0, 168, 255, 0.3);
    backdrop-filter: blur(5px);
}

.mailbox-title {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mailbox-title h2 {
    color: var(--color-accent);
    font-family: var(--font-title);
    margin: 0;
    font-size: 1.8rem;
    background: linear-gradient(135deg, var(--color-accent), #8A2BE2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.mailbox-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-name {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
    font-weight: 500;
}

.unread-indicator {
    background: linear-gradient(135deg, #ff4444, #ff6666);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: bold;
    display: none;
    animation: glow 2s ease-in-out infinite alternate;
}

.mailbox-header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.refresh-mailbox {
    background: rgba(0, 168, 255, 0.2);
    border: 2px solid rgba(0, 168, 255, 0.5);
    color: var(--color-accent);
    border-radius: 12px;
    padding: 0.8rem 1.2rem;
    font-family: var(--font-text);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.refresh-mailbox:hover {
    background: rgba(0, 168, 255, 0.3);
    border-color: var(--color-accent);
    box-shadow: 0 0 15px rgba(0, 168, 255, 0.5);
    transform: translateY(-2px);
}

.close-mailbox {
    background: rgba(255, 68, 68, 0.2);
    border: 2px solid rgba(255, 68, 68, 0.5);
    color: white;
    padding: 0.8rem 1rem;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    font-weight: bold;
}

.close-mailbox:hover {
    background: rgba(255, 68, 68, 0.4);
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(255, 68, 68, 0.5);
}

/* === NAVIGATION === */
.mailbox-navigation {
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 2px solid rgba(0, 168, 255, 0.3);
    backdrop-filter: blur(5px);
}

.mailbox-tabs {
    display: flex;
    align-items: stretch;
}

.mailbox-tab {
    flex: 1;
    padding: 1.2rem 1.5rem;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-family: var(--font-title);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    position: relative;
}

.tab-icon {
    font-size: 1.2rem;
}

.tab-label {
    font-weight: 600;
}

.tab-count {
    background: rgba(0, 168, 255, 0.3);
    color: var(--color-accent);
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: bold;
    min-width: 1.5rem;
    text-align: center;
}

.mailbox-tab:hover {
    background: rgba(0, 168, 255, 0.1);
    color: white;
    transform: translateY(-2px);
}

.mailbox-tab.active {
    background: rgba(0, 168, 255, 0.2);
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
    box-shadow: 0 0 20px rgba(0, 168, 255, 0.3);
}

.mailbox-tab.active .tab-count {
    background: var(--color-accent);
    color: #0d152e;
}

/* === PANNEAUX === */
.mailbox-panels {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.mailbox-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
}

.mailbox-panel.active {
    display: flex;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(0, 168, 255, 0.2);
}

.panel-header h3 {
    color: var(--color-accent);
    font-family: var(--font-title);
    margin: 0;
    font-size: 1.2rem;
}

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

.mark-all-read {
    background: rgba(76, 175, 80, 0.2);
    color: #4CAF50;
    border: 1px solid rgba(76, 175, 80, 0.5);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mark-all-read:hover {
    background: rgba(76, 175, 80, 0.3);
    transform: translateY(-1px);
}

/* === CONTENEURS DE MESSAGES === */
.messages-container {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.messages-list {
    height: 100%;
    overflow-y: auto;
    padding: 1rem;
}

/* === ÉTATS === */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--color-accent);
    gap: 1rem;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 168, 255, 0.3);
    border-top: 3px solid var(--color-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    gap: 1rem;
}

.empty-icon {
    font-size: 4rem;
    opacity: 0.7;
}

.empty-state h4 {
    font-size: 1.5rem;
    color: var(--color-accent);
    margin: 0;
}

.empty-state p {
    font-size: 1rem;
    margin: 0;
}

.empty-info {
    background: rgba(0, 168, 255, 0.1);
    border: 1px solid rgba(0, 168, 255, 0.3);
    border-radius: 10px;
    padding: 1rem;
    margin: 1rem 0;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: rgba(0, 168, 255, 0.9);
}

.empty-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.empty-actions .btn {
    min-width: 180px;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 12px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.empty-actions .btn-primary {
    background: linear-gradient(135deg, #FF6B35, #FF8E53, #00A8FF);
    background-size: 200% 200%;
    border: 3px solid transparent;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    box-shadow: 
        0 4px 15px rgba(255, 107, 53, 0.4),
        0 0 0 0 rgba(255, 107, 53, 0.7);
    animation: writeMessagePulse 2s infinite;
}

.empty-actions .btn-primary:hover {
    transform: translateY(-3px) scale(1.05);
    background-position: 100% 0;
    box-shadow: 
        0 12px 35px rgba(255, 107, 53, 0.6),
        0 0 0 8px rgba(255, 107, 53, 0.2);
    animation: none;
}

.empty-actions .btn-primary::before {
    content: '✨';
    position: absolute;
    left: -10px;
    opacity: 0;
    transition: all 0.3s ease;
}

.empty-actions .btn-primary:hover::before {
    left: 8px;
    opacity: 1;
}

/* Animation de pulsation pour attirer l'attention */
@keyframes writeMessagePulse {
    0%, 100% {
        box-shadow: 
            0 4px 15px rgba(255, 107, 53, 0.4),
            0 0 0 0 rgba(255, 107, 53, 0.7);
    }
    50% {
        box-shadow: 
            0 4px 15px rgba(255, 107, 53, 0.4),
            0 0 0 10px rgba(255, 107, 53, 0.2);
    }
}

.empty-actions .btn-secondary {
    background: rgba(108, 117, 125, 0.1);
    border: 2px solid rgba(108, 117, 125, 0.3);
    color: rgba(255, 255, 255, 0.8);
}

.empty-actions .btn-secondary:hover {
    background: rgba(108, 117, 125, 0.2);
    border-color: rgba(108, 117, 125, 0.5);
    transform: translateY(-2px);
}

.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
    text-align: center;
    color: #ff6666;
    gap: 1rem;
}

.error-icon {
    font-size: 3rem;
}

.error-state h4 {
    color: #ff6666;
    margin: 0;
}

/* === MESSAGES === */
.message-item {
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(0, 168, 255, 0.3);
    border-radius: 15px;
    margin-bottom: 1rem;
    overflow: hidden;
    transition: all 0.3s ease;
}

.message-item:hover {
    border-color: rgba(0, 168, 255, 0.6);
    box-shadow: 0 0 20px rgba(0, 168, 255, 0.2);
    transform: translateY(-2px);
}

.message-item.unread {
    border-color: rgba(255, 215, 0, 0.6);
    background: rgba(255, 215, 0, 0.1);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: rgba(0, 168, 255, 0.1);
    border-bottom: 1px solid rgba(0, 168, 255, 0.3);
}

.message-info {
    flex: 1;
}

.message-user-line {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.3rem;
}

.message-from {
    color: var(--color-accent);
    font-weight: bold;
}

.message-time-line {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.message-date {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.85rem;
    font-style: italic;
}

.message-subject {
    padding: 0.8rem 1.5rem;
    background: rgba(0, 168, 255, 0.05);
    border-left: 3px solid rgba(0, 168, 255, 0.3);
}

.message-subject h4 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--color-accent);
    font-family: var(--font-title);
}

.message-content {
    padding: 1.5rem;
    color: white;
}

.message-content p {
    margin: 0;
    line-height: 1.6;
    white-space: pre-line;
    word-wrap: break-word;
}

/* === BADGES === */
.unread-badge {
    background: linear-gradient(135deg, #ff4444, #ff6666);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 5px rgba(255, 68, 68, 0.3);
    animation: glow 2s ease-in-out infinite alternate;
}

.trade-badge {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #2c1810;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 5px rgba(255, 215, 0, 0.3);
}

/* === ACTIONS DE MESSAGES === */
.message-actions {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
}

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.reply-btn {
    background: rgba(0, 168, 255, 0.2);
    color: var(--color-accent);
    border: 1px solid rgba(0, 168, 255, 0.4);
}

.reply-btn:hover {
    background: rgba(0, 168, 255, 0.3);
    border-color: var(--color-accent);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 168, 255, 0.3);
}

.delete-btn {
    background: rgba(255, 68, 68, 0.2);
    color: #ff6666;
    border: 1px solid rgba(255, 68, 68, 0.4);
}

.delete-btn:hover {
    background: rgba(255, 68, 68, 0.3);
    border-color: #ff4444;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(255, 68, 68, 0.3);
}

/* === FORMULAIRE DE COMPOSITION === */
.compose-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.compose-form-panel {
    max-width: 800px;
    margin: 0 auto;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 15px;
    padding: 2rem;
    border: 1px solid rgba(0, 168, 255, 0.2);
}

.form-section {
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
    position: relative;
}

.form-group label {
    display: block;
    color: var(--color-accent);
    margin-bottom: 0.5rem;
    font-weight: bold;
    font-family: var(--font-title);
}

.required {
    color: #ff6666;
    font-weight: bold;
}

.input-wrapper {
    position: relative;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(0, 168, 255, 0.3);
    border-radius: 10px;
    color: white;
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.3s ease;
    resize: none;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 15px rgba(0, 168, 255, 0.3);
}

.form-group textarea {
    resize: vertical;
    min-height: 150px;
}

.char-count {
    text-align: right;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 0.3rem;
}

.validation-success {
    color: #4CAF50;
    font-size: 0.9rem;
    margin-top: 0.3rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.validation-error {
    color: #ff6666;
    font-size: 0.9rem;
    margin-top: 0.3rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.validation-warning {
    color: #ffb366;
    font-size: 0.9rem;
    margin-top: 0.3rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-validation {
    min-height: 1.2rem;
}

/* === AUTOCOMPLÉTION === */
.autocomplete-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(13, 21, 46, 0.95);
    border: 2px solid rgba(0, 168, 255, 0.5);
    border-top: none;
    border-radius: 0 0 10px 10px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.autocomplete-suggestion {
    padding: 0.8rem 1rem;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    border-bottom: 1px solid rgba(0, 168, 255, 0.2);
    transition: all 0.3s ease;
    font-family: var(--font-text);
}

.autocomplete-suggestion:hover,
.autocomplete-suggestion.selected {
    background: rgba(0, 168, 255, 0.2);
    color: var(--color-accent);
    text-shadow: 0 0 5px rgba(0, 168, 255, 0.5);
}

.autocomplete-suggestion:last-child {
    border-bottom: none;
}

/* === ACTIONS DU FORMULAIRE === */
.form-actions-panel {
    display: flex;
    gap: 1rem;
    justify-content: center;
    padding-top: 1rem;
    border-top: 1px solid rgba(0, 168, 255, 0.2);
}

.btn {
    padding: 1rem 2rem;
    border: none;
    border-radius: 10px;
    font-family: var(--font-title);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.btn-icon {
    font-size: 1.1rem;
}

.btn-primary {
    background: linear-gradient(135deg, rgba(0, 168, 255, 0.8) 0%, rgba(138, 43, 226, 0.8) 100%);
    color: white;
    border: 2px solid rgba(0, 168, 255, 0.5);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0, 168, 255, 0.4);
}

.btn-secondary {
    background: rgba(100, 100, 100, 0.3);
    color: white;
    border: 2px solid rgba(150, 150, 150, 0.5);
}

.btn-secondary:hover {
    background: rgba(150, 150, 150, 0.3);
    transform: translateY(-2px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* === ANIMATIONS === */
@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

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

@keyframes glow {
    from { box-shadow: 0 2px 5px rgba(255, 68, 68, 0.3); }
    to { box-shadow: 0 2px 15px rgba(255, 68, 68, 0.6); }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

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

.autocomplete-suggestions {
    animation: slideDown 0.2s ease-out;
}

/* === SCROLLBARS === */
.messages-list::-webkit-scrollbar,
.compose-container::-webkit-scrollbar {
    width: 8px;
}

.messages-list::-webkit-scrollbar-track,
.compose-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.messages-list::-webkit-scrollbar-thumb,
.compose-container::-webkit-scrollbar-thumb {
    background: rgba(0, 168, 255, 0.3);
    border-radius: 4px;
}

.messages-list::-webkit-scrollbar-thumb:hover,
.compose-container::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 168, 255, 0.5);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .mailbox-content {
        width: 95%;
        height: 90%;
    }
    
    .mailbox-header {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
    }
    
    .mailbox-title {
        text-align: center;
    }
    
    .mailbox-tabs {
        flex-direction: column;
    }
    
    .mailbox-tab {
        padding: 1rem;
        flex-direction: row;
        justify-content: center;
    }
    
    .tab-label {
        display: none;
    }
    
    .message-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .compose-form-panel {
        padding: 1rem;
    }
    
    .form-actions-panel {
        flex-direction: column;
    }
    
    .btn {
        justify-content: center;
    }
}