/* style.css — Mail Tracker Premium Dark UI */

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

/* ============================
   CSS Variables & Reset
   ============================ */
:root {
    --bg-primary:    #0d0d1a;
    --bg-secondary:  #13132a;
    --bg-card:       rgba(255,255,255,0.04);
    --bg-card-hover: rgba(255,255,255,0.07);
    --border:        rgba(255,255,255,0.08);
    --border-hover:  rgba(122,90,248,0.4);

    --accent:        #7a5af8;
    --accent-light:  #9d7ffa;
    --accent-glow:   rgba(122,90,248,0.25);

    --green:         #22c55e;
    --green-bg:      rgba(34,197,94,0.12);
    --red:           #ef4444;
    --red-bg:        rgba(239,68,68,0.12);
    --amber:         #f59e0b;
    --amber-bg:      rgba(245,158,11,0.12);
    --blue:          #3b82f6;
    --blue-bg:       rgba(59,130,246,0.12);

    --text-primary:  #f0f0ff;
    --text-secondary:#9494b8;
    --text-muted:    #5c5c8a;

    --radius-sm:  8px;
    --radius-md:  12px;
    --radius-lg:  20px;
    --radius-xl:  28px;

    --shadow-card: 0 4px 24px rgba(0,0,0,0.4);
    --shadow-glow: 0 0 40px rgba(122,90,248,0.15);
    --transition:  all 0.22s cubic-bezier(0.4,0,0.2,1);
}

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

html { scroll-behavior: smooth; }

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

/* ============================
   Background Decoration
   ============================ */
body::before {
    content: '';
    position: fixed;
    top: -200px;
    left: -200px;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(122,90,248,0.12) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}
body::after {
    content: '';
    position: fixed;
    bottom: -200px;
    right: -200px;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(59,130,246,0.08) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* ============================
   Layout
   ============================ */
.page-wrapper {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ============================
   Header / Navbar
   ============================ */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 40px;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}
.navbar-brand .logo-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--accent), #3b82f6);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 16px var(--accent-glow);
}
.navbar-brand .brand-text {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}
.navbar-brand .brand-text span {
    color: var(--accent-light);
}

.navbar-links {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition);
}
.nav-link:hover, .nav-link.active {
    color: var(--text-primary);
    background: var(--bg-card-hover);
}
.nav-link.btn-primary {
    background: linear-gradient(135deg, var(--accent), #5b3fcf);
    color: #fff;
    box-shadow: 0 4px 16px var(--accent-glow);
}
.nav-link.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px var(--accent-glow);
}

/* ============================
   User Avatar & Dropdown
   ============================ */
.user-menu {
    position: relative;
    margin-left: 8px;
}
.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #3b82f6);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
    user-select: none;
}
.user-avatar:hover {
    border-color: var(--accent-light);
    transform: scale(1.05);
}
.user-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    min-width: 220px;
    box-shadow: var(--shadow-card);
    z-index: 999;
    display: none;
    animation: fadeIn 0.15s ease;
    overflow: hidden;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.user-dropdown.open { display: block; }
.user-dropdown-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.user-dropdown-header strong { font-size: 14px; color: var(--text-primary); }
.user-dropdown-header small  { font-size: 12px; color: var(--text-muted); }
.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 16px;
    font-size: 14px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
}
.user-dropdown-item:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.user-dropdown-item.danger { color: var(--red); }
.user-dropdown-item.danger:hover { background: var(--red-bg); }

/* ============================
   Page Header
   ============================ */
.page-header {
    margin-bottom: 32px;
}
.page-header h1 {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -0.8px;
    background: linear-gradient(to right, var(--text-primary), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.page-header p {
    color: var(--text-secondary);
    font-size: 15px;
    margin-top: 6px;
}

/* ============================
   Stats Cards
   ============================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 36px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 22px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
}
.stat-card:hover {
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
    transform: translateY(-2px);
}
.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
.stat-icon.purple { background: rgba(122,90,248,0.15); }
.stat-icon.green  { background: var(--green-bg); }
.stat-icon.red    { background: var(--red-bg); }
.stat-icon.blue   { background: var(--blue-bg); }

.stat-info h3 {
    font-size: 26px;
    font-weight: 700;
    line-height: 1;
}
.stat-info p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ============================
   Alert / Flash Messages
   ============================ */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    font-size: 14px;
    border: 1px solid;
    animation: slideDown 0.3s ease;
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.alert.success { background: var(--green-bg);  border-color: rgba(34,197,94,0.3);   color: #4ade80; }
.alert.error   { background: var(--red-bg);    border-color: rgba(239,68,68,0.3);   color: #f87171; }
.alert.info    { background: var(--blue-bg);   border-color: rgba(59,130,246,0.3);  color: #60a5fa; }
.alert-icon    { font-size: 18px; flex-shrink: 0; margin-top: 1px; }

/* ============================
   Table
   ============================ */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.table-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.table-header h2 {
    font-size: 16px;
    font-weight: 600;
}
.table-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    font-size: 14px;
    color: var(--text-secondary);
    transition: var(--transition);
}
.table-search:focus-within {
    border-color: var(--accent);
    color: var(--text-primary);
}
.table-search input {
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    width: 200px;
}
.table-search input::placeholder { color: var(--text-muted); }

table {
    width: 100%;
    border-collapse: collapse;
}
thead {
    background: var(--bg-secondary);
}
th {
    padding: 12px 20px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
td {
    padding: 16px 20px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr {
    transition: var(--transition);
}
tbody tr:hover {
    background: var(--bg-card-hover);
}

.email-to {
    font-weight: 500;
    color: var(--text-primary);
}
.email-addr {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}
.email-subject {
    color: var(--text-secondary);
    font-size: 13px;
}

/* ============================
   Status Badges
   ============================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.badge.read     { background: var(--green-bg); color: var(--green); border: 1px solid rgba(34,197,94,0.2); }
.badge.unread   { background: var(--amber-bg); color: var(--amber); border: 1px solid rgba(245,158,11,0.2); }
.badge.sent     { background: var(--blue-bg);  color: var(--blue);  border: 1px solid rgba(59,130,246,0.2); }
.badge.count    { background: var(--bg-secondary); color: var(--text-secondary); border: 1px solid var(--border); }

.badge .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.badge.read .dot     { animation: pulse-green 1.5s infinite; }
.badge.unread .dot   { background: var(--amber); }

@keyframes pulse-green {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

/* ============================
   Action Buttons
   ============================ */
.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: var(--transition);
    cursor: pointer;
    border: none;
    font-family: inherit;
}
.action-btn.view {
    background: var(--blue-bg);
    color: var(--blue);
    border: 1px solid rgba(59,130,246,0.2);
}
.action-btn.view:hover {
    background: rgba(59,130,246,0.2);
    transform: translateY(-1px);
}
.action-btn.delete {
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid rgba(239,68,68,0.15);
}
.action-btn.delete:hover {
    background: rgba(239,68,68,0.2);
}

/* ============================
   Compose Form
   ============================ */
.form-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 40px;
    box-shadow: var(--shadow-card), var(--shadow-glow);
    max-width: 720px;
    margin: 0 auto;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

.form-group {
    margin-bottom: 24px;
}
.form-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.form-group .required { color: var(--red); }

.form-control {
    width: 100%;
    padding: 13px 16px;
    background: var(--bg-primary);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 15px;
    transition: var(--transition);
    outline: none;
}
.form-control::placeholder { color: var(--text-muted); font-size: 14px; }
.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: var(--bg-secondary);
}
textarea.form-control {
    resize: vertical;
    min-height: 160px;
    line-height: 1.6;
}

.form-divider {
    height: 1px;
    background: var(--border);
    margin: 28px 0;
    position: relative;
}
.form-divider span {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-card);
    padding: 0 12px;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.btn-submit {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, var(--accent) 0%, #5b3fcf 100%);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    letter-spacing: 0.3px;
    box-shadow: 0 6px 24px var(--accent-glow);
}
.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 32px var(--accent-glow);
}
.btn-submit:active { transform: translateY(0); }

.info-box {
    background: var(--blue-bg);
    border: 1px solid rgba(59,130,246,0.2);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    font-size: 13px;
    color: #60a5fa;
    margin-bottom: 24px;
    display: flex;
    gap: 10px;
}

/* ============================
   View Page (Email Detail)
   ============================ */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 24px;
    align-items: start;
}
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }

.detail-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.detail-card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}
.detail-card-header h3 { font-size: 16px; font-weight: 600; }
.detail-card-body { padding: 24px; }

.meta-row {
    display: flex;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.meta-row:last-child { border-bottom: none; }
.meta-label { color: var(--text-muted); font-weight: 500; width: 110px; flex-shrink: 0; font-size: 13px; }
.meta-value { color: var(--text-primary); }

.message-body {
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 20px;
    font-size: 15px;
    line-height: 1.8;
    color: var(--text-secondary);
    white-space: pre-wrap;
    margin-top: 16px;
    border: 1px solid var(--border);
}

.status-banner {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 14px;
}
.status-banner.read   { background: var(--green-bg); border-bottom: 1px solid rgba(34,197,94,0.2); }
.status-banner.unread { background: var(--amber-bg); border-bottom: 1px solid rgba(245,158,11,0.25); }
.status-icon { font-size: 32px; }
.status-text h3 { font-size: 17px; font-weight: 700; }
.status-text p  { font-size: 13px; opacity: 0.8; margin-top: 3px; }
.read-status-text   { color: var(--green); }
.unread-status-text { color: var(--amber); }

/* Open History Timeline */
.timeline { padding: 0; list-style: none; }
.timeline-item {
    display: flex;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
    position: relative;
}
.timeline-item:last-child { border-bottom: none; }
.timeline-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--blue-bg);
    border: 2px solid rgba(59,130,246,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    margin-top: 2px;
}
.timeline-dot.first {
    background: var(--green-bg);
    border-color: rgba(34,197,94,0.4);
}
.timeline-content {}
.timeline-time {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.timeline-detail {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 3px;
}

.no-data {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.no-data .no-data-icon { font-size: 48px; margin-bottom: 14px; display: block; opacity: 0.4; }
.no-data p { font-size: 15px; }

/* ============================
   Empty State
   ============================ */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 56px; margin-bottom: 16px; opacity: 0.3; display: block; }
.empty-state h3 { font-size: 20px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p  { font-size: 14px; margin-bottom: 24px; }

/* ============================
   Footer
   ============================ */
.page-footer {
    text-align: center;
    padding: 40px 0 30px;
    color: var(--text-muted);
    font-size: 13px;
    border-top: 1px solid var(--border);
    margin-top: 60px;
}

/* ============================
   Utilities
   ============================ */
.text-accent   { color: var(--accent-light); }
.text-muted    { color: var(--text-muted); }
.text-sm       { font-size: 13px; }
.mt-4          { margin-top: 16px; }
.mb-4          { margin-bottom: 16px; }
.flex          { display: flex; }
.items-center  { align-items: center; }
.gap-8         { gap: 8px; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* Responsive */
@media (max-width: 768px) {
    .page-wrapper { padding: 0 16px; }
    .navbar { flex-direction: column; align-items: flex-start; gap: 12px; }
    .form-card { padding: 24px 20px; }
    .page-header h1 { font-size: 26px; }
    table { font-size: 13px; }
    th, td { padding: 12px 14px; }
}
