/* ProjectMail - Modern UI */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --bg: #0f1117;
    --bg-card: #1a1d27;
    --bg-card-hover: #22263a;
    --bg-input: #151821;
    --border: #2a2e3d;
    --border-light: #353a4d;
    --text: #e4e6ef;
    --text-muted: #8b8fa3;
    --text-dim: #5c6078;
    --accent: #6c8aff;
    --accent-hover: #8ba3ff;
    --accent-bg: rgba(108, 138, 255, 0.1);
    --green: #4ade80;
    --green-bg: rgba(74, 222, 128, 0.1);
    --orange: #fb923c;
    --orange-bg: rgba(251, 146, 60, 0.1);
    --red: #f87171;
    --red-bg: rgba(248, 113, 113, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
}

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

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* NAV */
.nav {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.nav-brand {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-brand svg { width: 24px; height: 24px; }

.nav-actions { display: flex; gap: 8px; align-items: center; }

/* CONTAINER */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.btn-ghost:hover {
    background: var(--bg-card-hover);
    color: var(--text);
    border-color: var(--border-light);
}

.btn-sm { padding: 6px 12px; font-size: 13px; }

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}
.btn-icon:hover { background: var(--bg-card-hover); color: var(--text); }

/* CARDS */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    transition: all 0.2s;
}

.card-clickable {
    cursor: pointer;
    text-decoration: none;
    display: block;
    color: inherit;
}
.card-clickable:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
}

/* STATS */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.stat {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.2;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* TIMELINE */
.timeline { position: relative; padding-left: 32px; }

.timeline::before {
    content: '';
    position: absolute;
    left: 11px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    margin-bottom: 16px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -32px;
    top: 20px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg);
    z-index: 1;
}

.timeline-date {
    font-size: 12px;
    color: var(--text-dim);
    font-family: 'JetBrains Mono', monospace;
    margin-bottom: 4px;
}

.timeline-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    transition: all 0.2s;
    text-decoration: none;
    color: inherit;
    display: block;
}

.timeline-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-light);
    box-shadow: var(--shadow);
}

.timeline-subject {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 4px;
}

.timeline-from {
    font-size: 13px;
    color: var(--text-muted);
}

.timeline-preview {
    font-size: 13px;
    color: var(--text-dim);
    margin-top: 8px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* MAIL DETAIL */
.mail-header {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
}

.mail-subject {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 16px;
    line-height: 1.3;
}

.mail-meta {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 16px;
    font-size: 14px;
}

.mail-meta dt {
    color: var(--text-dim);
    font-weight: 500;
}

.mail-meta dd { color: var(--text-muted); }

.mail-body {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    font-size: 15px;
    line-height: 1.7;
    overflow-wrap: break-word;
}

.mail-body-html { all: initial; font-family: 'DM Sans', sans-serif; color: var(--text); }
.mail-body-html * { max-width: 100%; }

/* ATTACHMENTS */
.attachments {
    margin-top: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.attachment {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--accent-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--accent);
    text-decoration: none;
    transition: all 0.2s;
}
.attachment:hover { background: var(--bg-card-hover); }

/* BADGES */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-accent { background: var(--accent-bg); color: var(--accent); }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-orange { background: var(--orange-bg); color: var(--orange); }
.badge-red { background: var(--red-bg); color: var(--red); }

/* EMPTY STATE */
.empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-dim);
}

.empty svg { width: 48px; height: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-title { font-size: 18px; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; }
.empty-text { font-size: 14px; }

/* PAGE HEADER */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
}

.page-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* SEARCH */
.search-box {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 12px;
    transition: border-color 0.2s;
}

.search-box:focus-within { border-color: var(--accent); }

.search-box input {
    background: transparent;
    border: none;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    padding: 10px 8px;
    outline: none;
    width: 100%;
}

.search-box input::placeholder { color: var(--text-dim); }

/* FORMS */
.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus { border-color: var(--accent); }

textarea.form-input { min-height: 80px; resize: vertical; }

/* TOAST / FLASH */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.flash-success { background: var(--green-bg); color: var(--green); border: 1px solid rgba(74,222,128,0.2); }
.flash-error { background: var(--red-bg); color: var(--red); border: 1px solid rgba(248,113,113,0.2); }

/* RESPONSIVE */
@media (max-width: 640px) {
    .nav { padding: 0 16px; }
    .container { padding: 16px 12px; }
    .page-title { font-size: 20px; }
    .stats { grid-template-columns: repeat(2, 1fr); }
    .mail-subject { font-size: 18px; }
    .mail-meta { grid-template-columns: 1fr; }
}
