:root {
    --mail-bg: #0b0f19;
    --mail-panel-bg: rgba(255, 255, 255, 0.03);
    --mail-panel-blur: blur(12px);
    --mail-border: rgba(255, 255, 255, 0.1);
    --mail-hover: rgba(255, 255, 255, 0.08);
    --mail-active: rgba(99, 102, 241, 0.15);
    --mail-active-border: #6366f1;
    --mail-glow: rgba(99, 102, 241, 0.5);
}

body {
    background: var(--mail-bg);
    background-image: radial-gradient(circle at 15% 50%, rgba(99, 102, 241, 0.15), transparent 25%),
                      radial-gradient(circle at 85% 30%, rgba(236, 72, 153, 0.1), transparent 25%);
    margin: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Outfit', sans-serif;
}

/* Navbar */
.navbar {
    background: rgba(11, 15, 25, 0.8) !important;
    backdrop-filter: var(--mail-panel-blur);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
    z-index: 100;
}

/* Centered Wrapper */
.mail-wrapper {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    box-sizing: border-box;
}

.mail-app-container {
    display: flex;
    width: 100%;
    max-width: 1400px;
    height: 100%;
    background: var(--mail-panel-bg);
    backdrop-filter: var(--mail-panel-blur);
    border: 1px solid var(--mail-border);
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 20px rgba(99, 102, 241, 0.1);
    overflow: hidden;
    animation: fadeInScale 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.98) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Sidebar */
.mail-sidebar {
    width: 260px;
    border-right: 1px solid var(--mail-border);
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    position: relative;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px dashed var(--mail-border);
}

.folder-list {
    list-style: none;
    padding: 15px 10px;
    margin: 0;
    overflow-y: auto;
    flex: 1;
}

.folder-item {
    padding: 12px 15px;
    margin-bottom: 5px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
    color: var(--text-muted);
    border: 1px solid transparent;
}

.folder-item ion-icon {
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

.folder-item:hover {
    background: var(--mail-hover);
    color: var(--text-color);
    transform: translateX(5px);
    border-color: rgba(255, 255, 255, 0.05);
}

.folder-item.active {
    background: var(--mail-active);
    color: var(--mail-active-border);
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
    font-weight: 600;
}

.folder-item.active ion-icon {
    transform: scale(1.2);
    color: var(--mail-active-border);
    filter: drop-shadow(0 0 5px var(--mail-glow));
}

/* Mail List Panel */
.mail-list-panel {
    width: 380px;
    border-right: 1px solid var(--mail-border);
    display: flex;
    flex-direction: column;
    background: rgba(15, 23, 42, 0.4);
    position: relative;
}

.panel-header {
    padding: 20px;
    border-bottom: 1px dashed var(--mail-border);
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.1);
}

.panel-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-color);
}

.mail-list {
    flex: 1;
    overflow-y: auto;
}

.mail-item {
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.mail-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--mail-active-border);
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.mail-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.mail-item.active {
    background: var(--mail-active);
}

.mail-item.active::before {
    transform: scaleY(1);
    box-shadow: 0 0 10px var(--mail-glow);
}

.mail-item.unread .mail-subject {
    font-weight: bold;
    color: #fff;
}

.mail-item.unread::after {
    content: '';
    position: absolute;
    right: 20px;
    top: 20px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
}

.mail-sender {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 15px;
}

.mail-subject {
    font-size: 1.05rem;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: rgba(255, 255, 255, 0.9);
}

.mail-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    position: absolute;
    top: 18px;
    right: 20px;
}

/* Mail View Panel */
.mail-view-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: transparent;
    overflow: hidden;
}

.mail-view-header {
    padding: 30px 40px 10px 40px;
    border-bottom: 1px dashed var(--mail-border);
}

.avatar-placeholder {
    width: 45px;
    height: 45px;
    border-radius: 12px;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    color: white;
}

.mail-body-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 30px 40px;
}

.mail-body-content {
    font-family: 'Inter', Arial, sans-serif;
    line-height: 1.7;
    background: white;
    color: #1f2937;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    min-height: 100%;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.empty-state ion-icon {
    font-size: 5rem;
    margin-bottom: 1.5rem;
    color: rgba(255, 255, 255, 0.1);
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.05));
    transition: transform 0.5s ease;
}

.empty-state:hover ion-icon {
    transform: scale(1.1) rotate(5deg);
}

/* Styled Inputs & Buttons */
.styled-select, .sys-input {
    width: 100%;
    padding: 12px 15px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: white;
    outline: none;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.styled-select:focus, .sys-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.3);
    background: rgba(0, 0, 0, 0.6);
}

.sys-btn {
    padding: 10px 20px;
    border-radius: 12px;
    border: 1px solid transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
    font-family: inherit;
}

.sys-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px currentColor;
    filter: brightness(1.2);
}

.sys-btn ion-icon {
    font-size: 1.2rem;
}

#btn-refresh {
    padding: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
}

#btn-refresh:hover {
    background: var(--mail-active);
    color: var(--mail-active-border);
    box-shadow: 0 0 10px var(--mail-glow);
    transform: rotate(180deg);
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}
/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--mail-bg);
    border: 1px solid var(--mail-border);
    border-radius: 20px;
    padding: 30px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 20px var(--mail-glow);
    position: relative;
    animation: fadeInScale 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 1.8rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: 0.3s;
}

.close-modal:hover {
    color: #ef4444;
    transform: rotate(90deg);
}

.spinner {
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Mail Settings Sidebar */
.mail-settings-sidebar {
    position: fixed;
    top: 0;
    right: -350px;
    width: 350px;
    height: 100vh;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(25px) saturate(150%);
    border-left: 1px solid rgba(255,255,255,0.15);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    transition: right 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: -10px 0 30px rgba(0,0,0,0.5);
}

.mail-settings-sidebar.open {
    right: 0;
}

/* Drag and Drop styles */
.folder-item.drag-over {
    background: rgba(16, 185, 129, 0.2);
    border-color: #10b981;
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.3);
}

.mail-item.dragging {
    opacity: 0.5;
    background: rgba(255, 255, 255, 0.1);
    cursor: grabbing !important;
}

.mail-item {
    cursor: grab;
}

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

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

/* Mobile Responsiveness for Mail UI */
@media (max-width: 950px) {
    body {
        overflow-y: auto !important;
        height: auto !important;
    }
    .mail-wrapper {
        padding: 0;
        height: auto;
        display: block;
    }
    .mail-app-container {
        flex-direction: column;
        height: auto;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    .mail-sidebar, .mail-list-panel, .mail-view-panel {
        width: 100% !important;
        border-right: none;
        border-bottom: 1px solid var(--mail-border);
        height: auto;
        min-height: 400px;
    }
    .mail-settings-sidebar {
        width: 100% !important;
        right: -100% !important;
    }
    .mail-settings-sidebar.open {
        right: 0 !important;
    }
}
