/* Messagerie Interne - Styles iOS Modern */

.sp-messagerie-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    height: 100%;
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

/* ===== SIDEBAR ===== */
.sp-messagerie-sidebar {
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
}

.sp-btn-compose {
    width: 100%;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.sp-btn-compose:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.sp-btn-compose:active {
    transform: translateY(0);
}

.sp-sidebar-folders {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.sp-folder-item {
    padding: 12px 15px;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
}

.sp-folder-item:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.sp-folder-item.active {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.sp-folder-item i {
    font-size: 18px;
    width: 20px;
}

.sp-folder-item span:first-of-type {
    flex: 1;
}

.sp-unread-count,
.sp-draft-count {
    background: rgba(255, 255, 255, 0.3);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.sp-custom-folders {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.sp-folder-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px 10px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sp-add-folder {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.sp-add-folder:hover {
    background: rgba(255, 255, 255, 0.3);
}

.sp-storage-info {
    margin-top: auto;
    padding: 15px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 10px;
}

.sp-storage-bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.sp-storage-used {
    height: 100%;
    background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
    border-radius: 3px;
    transition: width 0.5s ease;
}

.sp-storage-text {
    color: rgba(255, 255, 255, 0.9);
    font-size: 11px;
}

/* ===== MAIN CONTENT ===== */
.sp-messagerie-main {
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
}

.sp-messagerie-header {
    padding: 20px 30px;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.sp-search-box {
    flex: 1;
    max-width: 500px;
    position: relative;
    display: flex;
    align-items: center;
}

.sp-search-box i {
    position: absolute;
    left: 15px;
    color: #999;
    font-size: 16px;
}

.sp-search-input {
    width: 100%;
    padding: 12px 15px 12px 45px;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    font-size: 14px;
    background: #f8f9fa;
    transition: all 0.3s ease;
}

.sp-search-input:focus {
    outline: none;
    border-color: #667eea;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.sp-header-actions {
    display: flex;
    gap: 10px;
}

.sp-btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.sp-btn-icon:hover {
    background: #667eea;
    color: #fff;
    border-color: #667eea;
    transform: translateY(-2px);
}

/* ===== TOOLBAR ===== */
.sp-messagerie-toolbar {
    padding: 15px 30px;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sp-toolbar-left {
    display: flex;
    gap: 10px;
    align-items: center;
}

.sp-checkbox-all {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.sp-checkbox-all input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.sp-sort-select {
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 13px;
    background: #fff;
    cursor: pointer;
}

/* ===== EMAIL LIST ===== */
.sp-email-list {
    flex: 1;
    overflow-y: auto;
    padding: 20px 30px;
}

.sp-emails-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sp-email-item {
    padding: 20px;
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e0e0e0;
    cursor: pointer;
    display: grid;
    grid-template-columns: 40px 1fr auto;
    gap: 15px;
    align-items: center;
    transition: all 0.3s ease;
    position: relative;
}

.sp-email-item:hover {
    border-color: #667eea;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.15);
    transform: translateY(-2px);
}

.sp-email-item.unread {
    background: linear-gradient(135deg, #f0f4ff 0%, #fff 100%);
    border-color: #667eea;
}

.sp-email-item.unread .sp-email-sender,
.sp-email-item.unread .sp-email-subject {
    font-weight: 600;
    color: #333;
}

.sp-email-checkbox {
    display: flex;
    align-items: center;
    justify-content: center;
}

.sp-email-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.sp-email-content {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.sp-email-sender {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sp-email-subject {
    font-size: 15px;
    color: #333;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sp-email-preview {
    font-size: 13px;
    color: #999;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sp-email-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
}

.sp-email-time {
    font-size: 12px;
    color: #999;
    white-space: nowrap;
}

.sp-email-star {
    color: #ffd700;
    font-size: 18px;
}

/* ===== EMAIL DETAIL ===== */
.sp-email-detail {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    z-index: 100;
    display: flex;
    flex-direction: column;
    animation: slideInRight 0.3s ease;
}

.sp-email-header {
    padding: 20px 30px;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    gap: 20px;
}

.sp-back-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.sp-back-btn:hover {
    background: #667eea;
    color: #fff;
    border-color: #667eea;
}

.sp-email-subject {
    flex: 1;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.sp-email-actions {
    display: flex;
    gap: 10px;
}

.sp-email-body {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
}

.sp-sender-info {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.sp-sender-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.sp-sender-details {
    flex: 1;
}

.sp-sender-name {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 3px;
}

.sp-sender-email {
    font-size: 13px;
    color: #999;
    margin-bottom: 5px;
}

.sp-email-date {
    font-size: 12px;
    color: #999;
}

.sp-email-recipients {
    margin-bottom: 25px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.sp-recipients-row {
    font-size: 13px;
    color: #666;
    margin-bottom: 5px;
}

.sp-recipients-row:last-child {
    margin-bottom: 0;
}

.sp-recipients-row strong {
    display: inline-block;
    width: 40px;
    color: #333;
}

.sp-email-content {
    font-size: 15px;
    line-height: 1.7;
    color: #333;
    margin-bottom: 30px;
}

.sp-email-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.sp-attachment-item {
    padding: 15px 20px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.sp-attachment-item:hover {
    background: #fff;
    border-color: #667eea;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.15);
}

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

.sp-modal-content {
    background: #fff;
    border-radius: 20px;
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.sp-modal-large {
    max-width: 900px;
}

.sp-compose-header {
    padding: 20px 25px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sp-compose-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.sp-compose-actions {
    display: flex;
    gap: 10px;
}

.sp-compose-actions .sp-btn-icon {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
}

.sp-compose-actions .sp-btn-icon:hover {
    background: rgba(255, 255, 255, 0.3);
}

.sp-compose-body {
    flex: 1;
    overflow-y: auto;
    padding: 25px;
}

.sp-compose-field {
    margin-bottom: 20px;
}

.sp-compose-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.sp-recipients-input {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    background: #fff;
    min-height: 45px;
    align-items: center;
}

.sp-recipients-input:focus-within {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.sp-recipient-tag {
    padding: 6px 12px;
    background: #667eea;
    color: #fff;
    border-radius: 20px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sp-recipient-tag button {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    line-height: 1;
}

.sp-recipients-input input {
    flex: 1;
    min-width: 200px;
    border: none;
    outline: none;
    font-size: 14px;
}

.sp-cc-bcc-toggle {
    margin-top: 8px;
    display: flex;
    gap: 15px;
}

.sp-cc-bcc-toggle a {
    font-size: 13px;
    color: #667eea;
    text-decoration: none;
}

.sp-cc-bcc-toggle a:hover {
    text-decoration: underline;
}

.sp-subject-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    font-size: 14px;
}

.sp-subject-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.sp-compose-editor {
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
}

.sp-editor-toolbar {
    padding: 10px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.sp-editor-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: #fff;
    border: 1px solid #e0e0e0;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.sp-editor-btn:hover {
    background: #667eea;
    color: #fff;
    border-color: #667eea;
}

.sp-toolbar-divider {
    width: 1px;
    height: 24px;
    background: #e0e0e0;
    align-self: center;
}

.sp-editor-content {
    min-height: 300px;
    padding: 20px;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
}

.sp-editor-content:focus {
    outline: none;
}

.sp-compose-footer {
    padding: 20px 25px;
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 12px;
}

.sp-btn {
    padding: 12px 20px;
    border-radius: 10px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.sp-btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.sp-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.sp-btn-secondary {
    background: #fff;
    color: #666;
    border: 1px solid #e0e0e0;
}

.sp-btn-secondary:hover {
    background: #f8f9fa;
    border-color: #667eea;
    color: #667eea;
}

.sp-btn-text {
    background: transparent;
    color: #ff4757;
}

.sp-btn-text:hover {
    background: rgba(255, 71, 87, 0.1);
}

/* ===== LOADING & EMPTY STATES ===== */
.sp-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #999;
}

.sp-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

.sp-empty-state {
    text-align: center;
    padding: 80px 20px;
    color: #999;
}

.sp-empty-state i {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
}

/* ===== TOAST ===== */
.sp-toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    padding: 15px 25px;
    background: #333;
    color: #fff;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    z-index: 10001;
    animation: slideInRight 0.3s ease;
}

.sp-toast.success {
    background: #00b894;
}

.sp-toast.error {
    background: #ff4757;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

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

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .sp-messagerie-container {
        grid-template-columns: 250px 1fr;
    }
}

@media (max-width: 768px) {
    .sp-messagerie-container {
        grid-template-columns: 1fr;
    }
    
    .sp-messagerie-sidebar {
        display: none;
    }
    
    .sp-messagerie-main {
        width: 100%;
    }
    
    .sp-messagerie-header {
        padding: 15px 20px;
    }
    
    .sp-email-list {
        padding: 15px 20px;
    }
    
    .sp-email-item {
        grid-template-columns: 30px 1fr;
        padding: 15px;
    }
    
    .sp-email-meta {
        grid-column: 2;
        align-items: flex-start;
    }
    
    /* Swipe actions mobile */
    .sp-email-item {
        touch-action: pan-y;
        transition: transform 0.3s ease;
    }
    
    .sp-email-item.swipe-left {
        transform: translateX(-80px);
    }
    
    .sp-email-item.swipe-right {
        transform: translateX(80px);
    }
    
    .sp-swipe-action-left,
    .sp-swipe-action-right {
        position: absolute;
        top: 0;
        height: 100%;
        width: 80px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #fff;
        font-size: 20px;
    }
    
    .sp-swipe-action-left {
        left: 0;
        background: #ff4757;
    }
    
    .sp-swipe-action-right {
        right: 0;
        background: #667eea;
    }
    
    .sp-modal-content {
        width: 95%;
        max-height: 95vh;
        border-radius: 15px;
    }
}