@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --bg: #080816;
    --bg-card: rgba(10, 14, 26, 0.85);
    --bg-hover: rgba(0, 120, 255, 0.06);
    --border: rgba(0, 120, 255, 0.15);
    --border-active: rgba(0, 120, 255, 0.4);
    --text: #e2e8f0;
    --text-dim: rgba(200, 220, 255, 0.4);
    --text-dimmer: rgba(200, 220, 255, 0.25);
    --accent: #0080ff;
    --accent2: #00d4ff;
    --purple: #7b68ee;
    --red: #f85149;
    --green: #3fb950;
    --orange: #d29922;
    --gradient: linear-gradient(135deg, var(--accent), var(--accent2), var(--purple));
    --shadow: 0 8px 40px rgba(0, 100, 255, 0.08);
}

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

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

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.bg {
    position: fixed; inset: 0;
    background:
        radial-gradient(ellipse at 15% 40%, rgba(0, 100, 255, 0.05) 0%, transparent 55%),
        radial-gradient(ellipse at 85% 20%, rgba(120, 0, 255, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 85%, rgba(0, 200, 255, 0.025) 0%, transparent 45%);
    z-index: 0;
    pointer-events: none;
}

/* AUTH */
.auth-container {
    position: relative; z-index: 1;
    min-height: 100vh;
    display: flex; flex-direction: column;
    justify-content: center; align-items: center;
    padding: 2rem;
}

.auth-card {
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2.8rem;
    max-width: 420px; width: 100%;
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    box-shadow: var(--shadow);
    animation: fadeUp 0.5s ease;
}

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

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

.auth-card .logo .icon-wrap {
    width: 40px; height: 40px;
    margin: 0 auto 0.5rem;
    background: rgba(0, 128, 255, 0.08);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--border);
}

.auth-card .logo .icon-wrap svg { width: 18px; height: 18px; }

.auth-card .logo h1 {
    font-size: 1.4rem; font-weight: 700;
    background: var(--gradient);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.auth-card .logo p {
    font-size: 0.75rem; color: var(--text-dim);
    margin-top: 0.2rem;
    font-family: 'JetBrains Mono', monospace;
}

/* FORM */
.form-group { margin-bottom: 1.1rem; }

.form-group label {
    display: block;
    font-size: 0.65rem; font-weight: 600;
    color: var(--text-dimmer);
    margin-bottom: 0.4rem;
    text-transform: uppercase; letter-spacing: 0.8px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.7rem 0.9rem;
    background: rgba(0, 8, 24, 0.6);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 0.85rem;
    font-family: 'Inter', sans-serif;
    transition: border-color 0.25s, box-shadow 0.25s;
    outline: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 128, 255, 0.12);
}

.form-group textarea { resize: vertical; min-height: 200px; }

.form-group .hint {
    font-size: 0.65rem; color: var(--text-dimmer);
    margin-top: 0.3rem;
}

/* BUTTONS */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.3rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.8rem; font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: var(--text);
    background: transparent;
}

.btn:hover { border-color: var(--border-active); background: var(--bg-hover); }

.btn-primary {
    background: var(--gradient);
    border: none; color: #fff; font-weight: 600;
}
.btn-primary:hover {
    opacity: 0.9; transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(0, 128, 255, 0.35);
}

.btn-ghost { border: none; color: var(--text-dim); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }

.btn-danger { border-color: rgba(248,81,73,0.3); color: var(--red); }
.btn-danger:hover { border-color: var(--red); background: rgba(248,81,73,0.08); }

.btn-success { border-color: rgba(63,185,80,0.3); color: var(--green); }
.btn-success:hover { border-color: var(--green); background: rgba(63,185,80,0.08); }

.btn-block { width: 100%; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.7rem; }
.btn-xs { padding: 0.25rem 0.5rem; font-size: 0.6rem; border-radius: 6px; }

/* MESSAGES */
.error, .success {
    padding: 0.65rem 0.85rem;
    border-radius: 10px;
    font-size: 0.78rem;
    margin-bottom: 1rem;
    animation: fadeUp 0.3s ease;
}
.error { background: rgba(248,81,73,0.08); border: 1px solid rgba(248,81,73,0.2); color: var(--red); }
.success { background: rgba(63,185,80,0.08); border: 1px solid rgba(63,185,80,0.2); color: var(--green); }

.auth-footer {
    text-align: center; margin-top: 1.5rem;
    font-size: 0.78rem; color: var(--text-dimmer);
}
.auth-footer a { color: var(--accent2); text-decoration: none; font-weight: 500; }
.auth-footer a:hover { text-decoration: underline; }

/* LAYOUT */
.layout {
    position: relative; z-index: 1;
    display: flex; min-height: 100vh;
}

.sidebar {
    width: 230px;
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    padding: 1.25rem; flex-shrink: 0;
}

.sidebar .brand {
    display: flex; align-items: center; gap: 0.5rem;
    margin-bottom: 1.75rem; text-decoration: none; color: var(--text);
}

.sidebar .brand .brand-icon {
    width: 24px; height: 24px;
    flex-shrink: 0;
    background: rgba(0,128,255,0.1);
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
}

.sidebar .brand .brand-icon svg { width: 14px; height: 14px; }

.sidebar .brand span {
    font-size: 1rem; font-weight: 700;
    background: var(--gradient);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.sidebar .nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.sidebar .nav a {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.5rem 0.7rem;
    border-radius: 10px;
    color: var(--text-dim); text-decoration: none;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.sidebar .nav a svg { width: 14px; height: 14px; flex-shrink: 0; opacity: 0.6; }

.sidebar .nav a:hover {
    background: var(--bg-hover); color: var(--text);
}

.sidebar .nav a.active {
    background: rgba(0,120,255,0.1);
    color: var(--accent2);
    border: 1px solid rgba(0,120,255,0.15);
}
.sidebar .nav a.active svg { opacity: 1; }

.sidebar .nav a .badge {
    margin-left: auto;
    background: var(--gradient);
    color: #fff; font-size: 0.6rem;
    padding: 0.1rem 0.4rem;
    border-radius: 8px; font-weight: 600;
}

.sidebar .user-info {
    padding: 0.75rem 0;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.sidebar .user-info .name {
    font-size: 0.78rem; font-weight: 500; color: var(--text);
}

.sidebar .user-info .role {
    font-size: 0.6rem; color: var(--text-dimmer);
    font-family: 'JetBrains Mono', monospace;
}

.main-content {
    flex: 1; padding: 1.5rem 2rem;
    overflow-y: auto;
    max-width: calc(100vw - 230px);
}

.main-content .page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap; gap: 0.5rem;
}

.main-content .page-header h2 {
    font-size: 1.3rem; font-weight: 600;
    display: flex; align-items: center; gap: 0.5rem;
}

.main-content .page-header h2 svg { width: 16px; height: 16px; opacity: 0.7; }

.main-content .subtitle {
    font-size: 0.75rem; color: var(--text-dimmer);
}

/* INBOX */
.inbox-toolbar {
    display: flex; align-items: center; gap: 0.4rem;
    margin-bottom: 1rem; flex-wrap: wrap;
}

.inbox-toolbar .tabs { display: flex; gap: 2px; background: rgba(0,8,24,0.4); padding: 2px; border-radius: 10px; }

.inbox-toolbar .tabs a {
    padding: 0.4rem 0.8rem; border-radius: 8px;
    font-size: 0.75rem; text-decoration: none; color: var(--text-dim);
    transition: all 0.2s; display: flex; align-items: center; gap: 0.3rem;
}
.inbox-toolbar .tabs a svg { width: 14px; height: 14px; }
.inbox-toolbar .tabs a:hover { color: var(--text); }
.inbox-toolbar .tabs a.active { background: rgba(0,128,255,0.15); color: var(--accent2); }

.inbox-toolbar .search-box {
    display: flex; flex: 1; min-width: 180px;
}
.inbox-toolbar .search-box input {
    flex: 1; padding: 0.45rem 0.7rem;
    background: rgba(0,8,24,0.6);
    border: 1px solid var(--border); border-right: none;
    border-radius: 10px 0 0 10px;
    color: var(--text); font-size: 0.78rem; outline: none;
}
.inbox-toolbar .search-box input:focus { border-color: var(--accent); }
.inbox-toolbar .search-box button {
    padding: 0.45rem 0.7rem;
    background: var(--accent); border: none;
    border-radius: 0 10px 10px 0;
    color: #fff; cursor: pointer; font-size: 0.78rem;
    transition: opacity 0.2s;
}
.inbox-toolbar .search-box button:hover { opacity: 0.85; }

.email-list { display: flex; flex-direction: column; gap: 3px; }

.email-item {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.7rem 1rem;
    background: rgba(10, 14, 26, 0.4);
    border: 1px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none; color: var(--text);
}

.email-item:hover {
    background: rgba(0, 120, 255, 0.04);
    border-color: var(--border);
    transform: translateX(2px);
}

.email-item.unread {
    background: rgba(0, 120, 255, 0.05);
    border-left: 3px solid var(--accent);
}

.email-item .avatar {
    width: 28px; height: 28px;
    border-radius: 8px;
    background: var(--gradient);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.6rem; font-weight: 700; color: #fff;
    flex-shrink: 0;
}

.email-item .info { flex: 1; min-width: 0; }

.email-item .info .from {
    font-size: 0.78rem; font-weight: 500;
    margin-bottom: 0.15rem;
    display: flex; align-items: center; gap: 0.4rem;
}

.email-item.unread .info .from { font-weight: 600; color: #fff; }

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

.email-item.unread .info .subject { color: var(--text); }

.email-item .time {
    font-size: 0.65rem; color: var(--text-dimmer);
    white-space: nowrap; flex-shrink: 0;
}

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

.email-item.unread {
    background: rgba(0, 120, 255, 0.04);
    border-left: 3px solid var(--accent);
}

.email-item .avatar {
    width: 28px; height: 28px;
    border-radius: 8px;
    background: var(--gradient);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.6rem; font-weight: 700; color: #fff;
    flex-shrink: 0;
}

.email-item .info { flex: 1; min-width: 0; }

.email-item .info .from {
    font-size: 0.78rem; font-weight: 500;
    margin-bottom: 0.15rem;
    display: flex; align-items: center; gap: 0.4rem;
}

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

.email-item .info .from .tag {
    font-size: 0.55rem; padding: 0.1rem 0.3rem;
    border-radius: 4px;
    background: rgba(0,120,255,0.1); color: var(--accent2);
    font-weight: 500;
}

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

.email-item .time {
    font-size: 0.65rem; color: var(--text-dimmer);
    white-space: nowrap; flex-shrink: 0;
}

/* VIEW */
.email-view { max-width: 800px; }

.email-view .header {
    margin-bottom: 1.5rem; padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
}

.email-view .header h2 {
    font-size: 1.2rem; font-weight: 600;
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.email-view .header .meta {
    display: flex; flex-direction: column; gap: 0.4rem;
    font-size: 0.78rem; color: var(--text-dim);
    background: rgba(0,8,24,0.3);
    padding: 0.75rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.email-view .header .meta .meta-row {
    display: flex; align-items: center; gap: 0.5rem;
}

.email-view .header .meta .label {
    color: var(--text-dimmer); font-weight: 500;
    min-width: 50px; font-size: 0.7rem;
    text-transform: uppercase; letter-spacing: 0.5px;
}

.email-view .header .meta .value { color: var(--text); }

.email-view .body {
    padding: 1.5rem 0.5rem;
    line-height: 1.7; font-size: 0.85rem;
    white-space: pre-wrap; word-wrap: break-word;
    color: var(--text);
}

.email-view .actions {
    display: flex; gap: 0.5rem;
    margin-top: 1.5rem; padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* COMPOSE */
.compose-form { max-width: 700px; }

/* ADMIN */
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }

.admin-table th,
.admin-table td {
    padding: 0.6rem 0.8rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.admin-table th {
    font-weight: 500; color: var(--text-dimmer);
    font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.5px;
}

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

.admin-table .status {
    display: inline-flex; align-items: center; gap: 0.25rem;
    font-size: 0.7rem; padding: 0.15rem 0.45rem;
    border-radius: 6px;
}
.admin-table .status.active { background: rgba(63,185,80,0.08); color: var(--green); }
.admin-table .status.blocked { background: rgba(248,81,73,0.08); color: var(--red); }
.admin-table .status.admin { background: rgba(210,153,34,0.08); color: var(--orange); }

/* PAGINATION */
.pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 0.3rem; margin-top: 1.5rem;
}

.pagination a,
.pagination span {
    padding: 0.35rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.75rem; text-decoration: none; color: var(--text);
    transition: all 0.2s;
}

.pagination a:hover { border-color: var(--accent); background: var(--bg-hover); }
.pagination .current { background: var(--accent); border-color: var(--accent); color: #fff; }

/* EMPTY STATE */
.empty-state {
    text-align: center; padding: 4rem 1rem;
    color: var(--text-dimmer);
}

.empty-state .empty-icon {
    width: 48px; height: 48px; margin: 0 auto 1rem;
    background: rgba(0,128,255,0.04);
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--border);
}

.empty-state .empty-icon svg { width: 20px; height: 20px; opacity: 0.3; }

.empty-state h3 {
    font-size: 0.95rem; font-weight: 500;
    margin-bottom: 0.4rem; color: var(--text);
}

.empty-state p { font-size: 0.78rem; }

/* TOAST NOTIFICATION */
.toast {
    position: fixed; top: 1rem; right: 1rem; z-index: 1000;
    padding: 0.75rem 1.25rem;
    border-radius: 12px;
    font-size: 0.8rem;
    backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    display: flex; align-items: center; gap: 0.5rem;
    animation: slideIn 0.35s ease;
    transform-origin: top right;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(24px) scale(0.95); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

.toast.success { background: rgba(63,185,80,0.15); border: 1px solid rgba(63,185,80,0.25); color: var(--green); }
.toast.error { background: rgba(248,81,73,0.15); border: 1px solid rgba(248,81,73,0.25); color: var(--red); }

/* NEW EMAIL BADGE (animated) */
.new-email-badge {
    display: inline-flex;
    align-items: center; gap: 0.3rem;
    font-size: 0.7rem;
    padding: 0.25rem 0.6rem;
    border-radius: 8px;
    background: var(--gradient);
    color: #fff;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .sidebar { width: 56px; padding: 0.75rem 0.5rem; }
    .sidebar .brand span,
    .sidebar .nav a span,
    .sidebar .user-info { display: none; }
    .sidebar .nav a { justify-content: center; padding: 0.45rem; }
    .sidebar .nav a svg { width: 18px; height: 18px; }
    .sidebar .brand { justify-content: center; }
    .sidebar .brand .brand-icon { margin: 0; }
    .main-content { padding: 1rem; max-width: calc(100vw - 56px); }
}

@media (max-width: 500px) {
    .auth-card { padding: 1.5rem; }
    .email-item { padding: 0.55rem 0.7rem; }
    .inbox-toolbar { flex-direction: column; align-items: stretch; }
    .inbox-toolbar .search-box { width: 100%; }
}
