:root {
    --nav-bg: #1575c0;
    --nav-dark: #105b9e;
    --sidebar-bg: #f5f5f5;
    --sidebar-hover: #e0e0e0;
    --sidebar-active: #c8e1f9;
    --white: #ffffff;
    --border: #e1e1e1;
    --text-primary: #1a1a2e;
    --text-secondary: #6b7280;
    --accent: #1575c0;
    --accent-light: #e6f2fa;
    --unread-bg: #f0f7fc;
    --hover-bg: #f8f9fa;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-primary);
    background: var(--white);
    height: 100vh;
    overflow: hidden;
}

a { text-decoration: none; color: inherit; }

/* Top Navigation */
.top-nav {
    background: var(--nav-bg);
    color: white;
    display: flex;
    align-items: center;
    padding: 0 1rem;
    height: 48px;
    gap: 1rem;
}

.top-nav .logo-area {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.top-nav .logo-area img {
    width: 32px;
    height: 32px;
}

.top-nav .search-bar {
    flex: 1;
    max-width: 400px;
}

.top-nav .search-bar input {
    width: 100%;
    padding: 0.4rem 1rem;
    border: none;
    border-radius: 4px;
    background: rgba(255,255,255,0.2);
    color: white;
    font-size: 0.9rem;
}

.top-nav .search-bar input::placeholder {
    color: rgba(255,255,255,0.7);
}

.top-nav .user-area {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.top-nav .user-area .avatar {
    width: 32px;
    height: 32px;
    background: rgba(255,255,255,0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
}

.top-nav .user-area .user-name {
    font-size: 0.85rem;
}

/* Main Layout - Outlook 3-Column */
.outlook-layout {
    display: grid;
    grid-template-columns: 200px 1fr 1fr;
    height: calc(100vh - 48px);
}

/* Left Sidebar - Folders */
.sidebar {
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding-top: 0.5rem;
}

.sidebar .compose-btn {
    margin: 0.75rem;
    padding: 0.6rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
    display: block;
    transition: background 0.2s;
}

.sidebar .compose-btn:hover {
    background: var(--nav-dark);
}

.sidebar .folder-list {
    list-style: none;
}

.sidebar .folder-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-radius: 4px;
    margin: 2px 0.5rem;
    font-size: 0.9rem;
    transition: background 0.15s;
}

.sidebar .folder-item:hover {
    background: var(--sidebar-hover);
}

.sidebar .folder-item.active {
    background: var(--sidebar-active);
    color: var(--accent);
}

.sidebar .folder-item .folder-icon {
    font-size: 1rem;
}

.sidebar .folder-item .badge-count {
    margin-left: auto;
    background: var(--accent);
    color: white;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
}

.sidebar .sidebar-footer {
    margin-top: auto;
    padding: 0.75rem;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.sidebar .sidebar-footer a {
    color: var(--accent);
}

/* Email List Panel */
.email-list-panel {
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    background: var(--white);
}

.email-list-panel .list-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.email-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
}

.email-item:hover {
    background: var(--hover-bg);
}

.email-item.active {
    background: var(--accent-light);
    border-left: 3px solid var(--accent);
}

.email-item.unread {
    background: var(--unread-bg);
}

.email-item.unread .email-item-sender {
    font-weight: 700;
}

.email-item.unread .email-item-subject {
    font-weight: 600;
}

.email-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.email-item-sender {
    font-size: 0.9rem;
}

.email-item-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.email-item-subject {
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-item-preview {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Email Detail Panel */
.email-detail-panel {
    background: var(--white);
    display: flex;
    flex-direction: column;
}

.email-detail-panel .detail-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.email-detail-panel .detail-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

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

.email-detail-panel .detail-actions .btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 4px;
    transition: background 0.15s;
}

.email-detail-panel .detail-actions .btn-icon:hover {
    background: var(--sidebar-hover);
}

.email-detail-body {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

.email-detail-meta {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.email-detail-meta .avatar-circle {
    width: 40px;
    height: 40px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
}

.email-detail-meta .sender-info h4 {
    font-size: 0.95rem;
}

.email-detail-meta .sender-info p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.email-detail-meta .detail-date {
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.email-detail-content {
    font-size: 0.95rem;
    line-height: 1.7;
    white-space: pre-wrap;
}

/* Buttons */
.btn {
    padding: 0.4rem 0.8rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--nav-dark);
}

.btn-text {
    background: none;
    color: var(--accent);
}

.btn-text:hover {
    background: var(--accent-light);
}

.btn-danger {
    color: #dc3545;
}

.btn-danger:hover {
    background: #fde8ea;
}

/* Auth Pages */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--nav-bg) 0%, var(--nav-dark) 100%);
}

.auth-container {
    background: white;
    padding: 2.5rem;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 420px;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header .logo {
    width: 48px;
    height: 48px;
    margin-bottom: 0.75rem;
}

.auth-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.auth-form .form-group {
    margin-bottom: 1rem;
}

.auth-form label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.auth-form input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.95rem;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(21,117,192,0.15);
}

.alert {
    padding: 0.75rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-success { background: #d1fae5; color: #065f46; }
.alert-error { background: #fee2e2; color: #991b1b; }

/* Compose Modal */
.compose-overlay {
    position: fixed;
    bottom: 0;
    right: 2rem;
    z-index: 100;
    width: 500px;
    background: var(--white);
    border-radius: 8px 8px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
}

.compose-overlay .compose-header {
    background: var(--nav-bg);
    color: white;
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 8px 8px 0 0;
}

.compose-overlay .compose-header h3 {
    font-size: 0.95rem;
    font-weight: 500;
}

.compose-overlay .compose-header button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.25rem;
}

.compose-form {
    padding: 1rem;
}

.compose-form .form-group {
    margin-bottom: 0.75rem;
}

.compose-form input,
.compose-form textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.9rem;
}

.compose-form textarea {
    resize: vertical;
    min-height: 150px;
    font-family: inherit;
}

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

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
}

.empty-state .empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

/* Admin Panel */
.admin-layout {
    display: grid;
    grid-template-columns: 200px 1fr;
    height: 100vh;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.data-table th {
    background: var(--sidebar-bg);
    font-weight: 600;
    color: var(--text-secondary);
}

.data-table tr:hover {
    background: var(--hover-bg);
}

/* Responsive */
@media (max-width: 1024px) {
    .outlook-layout {
        grid-template-columns: 60px 1fr;
    }
    
    .email-detail-panel {
        display: none;
    }
    
    .sidebar .folder-item span:not(.folder-icon) {
        display: none;
    }
    
    .sidebar .compose-btn {
        font-size: 0;
    }
    
    .sidebar .compose-btn::after {
        content: "+";
        font-size: 1.2rem;
    }
}

@media (max-width: 768px) {
    .outlook-layout {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        display: none;
    }
    
    .top-nav .search-bar {
        display: none;
    }
}
