:root {
    /* Color Palette */
    --bg-main: #0f172a;
    --bg-glass: rgba(30, 41, 59, 0.7);
    --bg-glass-hover: rgba(30, 41, 59, 0.9);
    --bg-glass-border: rgba(255, 255, 255, 0.1);
    
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    
    --danger: #ef4444;
    --success: #10b981;
    
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background: linear-gradient(135deg, #020617 0%, #0f172a 100%);
    color: var(--text-main);
    min-height: 100vh;
    overflow: hidden;
}

body.light-mode {
    --bg-main: #f1f5f9;
    --bg-glass: rgba(255, 255, 255, 0.7);
    --bg-glass-hover: rgba(255, 255, 255, 0.9);
    --bg-glass-border: rgba(0, 0, 0, 0.1);
    
    --text-main: #1e293b;
    --text-muted: #64748b;
    
    background: linear-gradient(135deg, #e2e8f0 0%, #f8fafc 100%);
}

body.light-mode .btn-secondary {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-main);
}
body.light-mode .btn-secondary:hover {
    background: rgba(0, 0, 0, 0.1);
}
body.light-mode .input-wrapper input {
    background: rgba(255, 255, 255, 0.5);
}
body.light-mode .ai-assistant {
    background: rgba(99, 102, 241, 0.05);
}
body.light-mode .ai-input-group input {
    background: rgba(255, 255, 255, 0.8);
}

/* Utilities */
.hidden { display: none !important; }
.text-primary { color: var(--primary); }
.text-danger { color: var(--danger); }

/* Glassmorphism Panel */
.glass-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--bg-glass-border);
    border-radius: var(--radius-lg);
}

/* Screens */
.screen {
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.4s ease;
}

/* Login Screen */
.login-container {
    width: 100%;
    max-width: 420px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.login-header h1 {
    margin: 15px 0 5px;
    font-size: 1.8rem;
    font-weight: 700;
}

.login-logo {
    max-width: 120px;
    height: auto;
    margin: 0 auto 15px;
    display: block;
    object-fit: contain;
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 30px;
}

.input-group {
    text-align: left;
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper i {
    position: absolute;
    left: 15px;
    color: var(--text-muted);
    font-size: 1.2rem;
}

.input-wrapper input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--bg-glass-border);
    border-radius: var(--radius-md);
    padding: 12px 15px 12px 45px;
    color: var(--text-main);
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
}

.input-wrapper input:focus {
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.3);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -10px var(--primary);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8rem;
}
.btn-text:hover {
    color: var(--primary);
    text-decoration: underline;
}

/* Error Message */
.error-message {
    margin-top: 15px;
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
    padding: 10px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

/* Main App Layout */
.app-layout {
    display: grid;
    grid-template-columns: 260px 350px 1fr;
    gap: 20px;
    width: 100%;
    max-width: 1600px;
    height: calc(100vh - 40px);
    margin: 20px;
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 30px;
}

.brand i {
    font-size: 1.8rem;
}

.btn-compose {
    margin-bottom: 30px;
}

.folders {
    flex: 1;
}

.folder-header {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 15px;
    font-weight: 600;
}

.folder-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
    margin-bottom: 5px;
}

.folder-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.folder-item.active {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
    font-weight: 500;
}

.folder-item i {
    font-size: 1.2rem;
}

.badge {
    margin-left: auto;
    background: var(--primary);
    color: white;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 600;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 15px;
    padding-top: 20px;
    border-top: 1px solid var(--bg-glass-border);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.user-info .email {
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 4px;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Theme Toggle */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 15px;
    margin-top: 15px;
    border-top: 1px dashed var(--bg-glass-border);
}

#theme-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255, 255, 255, 0.2);
    transition: .4s;
}
body.light-mode .slider {
    background-color: rgba(0, 0, 0, 0.2);
}
.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}
input:checked + .slider {
    background-color: var(--primary);
}
input:checked + .slider:before {
    transform: translateX(20px);
}
.slider.round { border-radius: 20px; }
.slider.round:before { border-radius: 50%; }

/* Mail List */
.mail-list-container {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.list-header {
    padding: 20px;
    border-bottom: 1px solid var(--bg-glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.list-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
}

.mail-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

/* Custom Scrollbar */
.mail-list::-webkit-scrollbar {
    width: 6px;
}
.mail-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.mail-item {
    padding: 15px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    margin-bottom: 8px;
    position: relative;
}

.mail-item:hover {
    background: var(--bg-glass-hover);
    border-color: var(--bg-glass-border);
}

.mail-item.selected {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.3);
}

.mail-item.unread::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
}

.mail-item.unread .mail-subject {
    font-weight: 700;
    color: var(--text-main);
}

.mail-sender {
    font-size: 0.85rem;
    color: var(--text-main);
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
}

.mail-date {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.mail-subject {
    font-size: 0.95rem;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mail-snippet {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    gap: 15px;
}

.loading-state i {
    font-size: 2rem;
}

/* Mail View */
.mail-view-container {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.view-state {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 30px;
}

.view-state.active {
    display: flex;
}

#view-empty {
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-align: center;
    gap: 20px;
}

.read-header {
    border-bottom: 1px solid var(--bg-glass-border);
    padding-bottom: 20px;
    margin-bottom: 20px;
}

.read-subject {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}

.read-subject h2 {
    font-size: 1.5rem;
    line-height: 1.3;
}

.read-date {
    color: var(--text-muted);
    font-size: 0.85rem;
    white-space: nowrap;
    margin-left: 20px;
}

.read-sender {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.sender-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.sender-email {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.read-actions {
    display: flex;
    gap: 10px;
}

.read-body {
    flex: 1;
    overflow-y: auto;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-main);
}
.read-body::-webkit-scrollbar { width: 6px; }
.read-body::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 10px; }

/* Composer */
.compose-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.compose-field {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--bg-glass-border);
    padding: 10px 0;
}

.compose-field label {
    width: 70px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.compose-field input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 0.95rem;
    outline: none;
}

textarea#compose-body {
    width: 100%;
    height: 100%;
    min-height: 200px;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 0.95rem;
    resize: none;
    outline: none;
    padding: 15px 0;
}
textarea#compose-body::-webkit-scrollbar { width: 6px; }
textarea#compose-body::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 10px; }

.compose-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--bg-glass-border);
}

.status-msg {
    font-size: 0.85rem;
}
.status-msg.success { color: var(--success); }
.status-msg.error { color: var(--danger); }

/* AI Assistant */
.ai-assistant {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius-md);
    padding: 15px;
    margin: 15px 0;
}

.ai-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.ai-input-group {
    display: flex;
    gap: 10px;
}

.ai-input-group input {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--bg-glass-border);
    border-radius: var(--radius-sm);
    padding: 10px 15px;
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
}
.ai-input-group input:focus {
    border-color: var(--primary);
}
