/* ============================================================
   Email Opens Tracker — Stylesheet
   ============================================================ */

/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                 Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f8fafc;
    color: #0f172a;
    font-size: 14px;
    line-height: 1.6;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

code {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Mono', Consolas, monospace;
    font-size: 12px;
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    color: #334155;
}

/* === NAVBAR === */
.navbar {
    background: #1e293b;
    height: 60px;
    display: flex;
    align-items: center;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0,0,0,.25);
}

.navbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    text-decoration: none;
}
.navbar-brand:hover { text-decoration: none; opacity: .9; }

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

.nav-link {
    color: #94a3b8;
    font-weight: 500;
    font-size: 14px;
    transition: color .15s;
}
.nav-link:hover,
.nav-link.active { color: #fff; text-decoration: none; }

.btn-outline-nav {
    display: inline-block;
    background: transparent;
    border: 1px solid #475569;
    color: #94a3b8;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color .15s, color .15s;
    text-decoration: none;
}
.btn-outline-nav:hover {
    border-color: #94a3b8;
    color: #fff;
    text-decoration: none;
}

/* === LAYOUT === */
.main {
    padding: 32px 24px;
    min-height: calc(100vh - 60px - 50px);
}
.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* === PAGE HEADER === */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 28px;
    gap: 16px;
    flex-wrap: wrap;
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
    margin: 0;
}

.page-subtitle {
    font-size: 14px;
    color: #64748b;
    margin: 4px 0 0;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #64748b;
    font-size: 13px;
    margin-bottom: 18px;
}
.back-link:hover { color: #0f172a; text-decoration: none; }

/* === CARDS === */
.card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 0 0 1px rgba(0,0,0,.04);
    padding: 24px;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid #f1f5f9;
    flex-wrap: wrap;
    gap: 8px;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

/* === STATS GRID === */
.stats-grid {
    display: grid;
    gap: 16px;
    margin-bottom: 20px;
}
.stats-grid-3 { grid-template-columns: repeat(3, 1fr); }
.stats-grid-4 { grid-template-columns: repeat(4, 1fr); }

.stat-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 0 0 1px rgba(0,0,0,.04);
    padding: 20px 22px;
}

.stat-card-accent {
    height: 3px;
    border-radius: 3px;
    margin-bottom: 14px;
}

.stat-value {
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.5px;
    line-height: 1;
    margin-bottom: 6px;
}

.stat-label {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .06em;
}

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, opacity .15s;
    line-height: 1;
    white-space: nowrap;
    font-family: inherit;
}
.btn:hover { text-decoration: none; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; margin-top: 8px; }

.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; color: #fff; }

.btn-secondary { background: #f1f5f9; color: #334155; }
.btn-secondary:hover { background: #e2e8f0; color: #1e293b; }

/* === FORM === */
.form-card { max-width: 560px; }

.form-group { margin-bottom: 20px; }

.form-label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    font-size: 14px;
    color: #374151;
}

.required { color: #ef4444; margin-left: 2px; }

.form-hint {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 5px;
    margin-bottom: 0;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    color: #0f172a;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    background: #fff;
    font-family: inherit;
}
.form-control:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 28px;
}

/* === ALERTS === */
.alert {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.5;
}
.alert-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

/* === TABLE === */
.table-wrapper { overflow-x: auto; }

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

thead th {
    text-align: left;
    padding: 11px 16px;
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .06em;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
}

tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafbfc; }

.td-subject {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.td-number { font-variant-numeric: tabular-nums; font-weight: 600; }
.td-date   { color: #64748b; white-space: nowrap; }

/* === BADGES === */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}
.badge-blue  { background: #dbeafe; color: #1d4ed8; }
.badge-green { background: #d1fae5; color: #065f46; }
.badge-gray  { background: #f1f5f9; color: #475569; }

/* === CODE BLOCK === */
.code-block-wrapper { position: relative; }

.code-block {
    background: #0f172a;
    color: #94a3b8;
    padding: 16px 54px 16px 16px;
    border-radius: 8px;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Mono', Consolas, monospace;
    font-size: 13px;
    word-break: break-all;
    white-space: pre-wrap;
    line-height: 1.65;
    margin: 0;
}

.copy-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #334155;
    color: #94a3b8;
    border: none;
    border-radius: 6px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, color .15s;
    font-family: inherit;
}
.copy-btn:hover { background: #475569; color: #e2e8f0; }
.copy-btn.copied { background: #065f46; color: #6ee7b7; }

/* === CHARTS === */
.charts-grid {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 20px;
    margin-bottom: 20px;
}
.chart-wrapper { position: relative; height: 260px; }

/* === PROGRESS BAR === */
.progress-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}
.progress-bar {
    height: 6px;
    background: #2563eb;
    border-radius: 9999px;
    min-width: 2px;
    max-width: 120px;
    flex-shrink: 0;
}
.progress-label {
    font-size: 12px;
    color: #64748b;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* === EMPTY STATE === */
.empty-state { text-align: center; padding: 60px 24px; }
.empty-state-icon  { font-size: 44px; margin-bottom: 14px; }
.empty-state-title { font-size: 17px; font-weight: 600; color: #475569; margin: 0 0 8px; }
.empty-state-text  { font-size: 14px; color: #94a3b8; margin: 0 0 20px; }

/* === SECTION === */
.section-subtitle { font-size: 13px; color: #64748b; }

/* === LOGIN PAGE === */
.login-body {
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-wrap {
    width: 100%;
    max-width: 400px;
    padding: 24px;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0,0,0,.08), 0 0 0 1px rgba(0,0,0,.04);
    padding: 36px 32px;
}

.login-header {
    text-align: center;
    margin-bottom: 28px;
}

.login-title {
    font-size: 20px;
    font-weight: 700;
    margin: 12px 0 6px;
}

.login-subtitle {
    font-size: 14px;
    color: #64748b;
    margin: 0;
}

/* === FOOTER === */
.site-footer {
    background: #fff;
    border-top: 1px solid #e2e8f0;
    padding: 14px 24px;
}

.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    font-size: 12px;
    color: #94a3b8;
}

/* === RESPONSIVE === */
@media (max-width: 900px) {
    .charts-grid    { grid-template-columns: 1fr; }
    .stats-grid-4   { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    .main           { padding: 20px 16px; }
    .stats-grid-3   { grid-template-columns: repeat(2, 1fr); }
    .page-header    { flex-direction: column; }
    .navbar-links   { gap: 14px; }
}

@media (max-width: 420px) {
    .stats-grid-3,
    .stats-grid-4   { grid-template-columns: 1fr; }
    .login-card     { padding: 28px 20px; }
}

/* === CLICK TRACKING ADDITIONS === */

/* 5-column stats grid */
.stats-grid-5 { grid-template-columns: repeat(5, 1fr); }

/* Highlighted "Combined Unique" stat card */
.stat-card-highlight {
    border: 2px solid #ede9fe;
    background: #faf5ff;
}
.stat-card-highlight .stat-value { color: #7c3aed; }

.stat-sublabel {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 3px;
}

/* Method indicator dots on card titles */
.method-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
    flex-shrink: 0;
}
.method-dot-pixel { background: #2563eb; }
.method-dot-click { background: #10b981; }

/* Responsive: collapse 5-col grid on smaller screens */
@media (max-width: 1100px) {
    .stats-grid-5 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
    .stats-grid-5 { grid-template-columns: repeat(2, 1fr); }
}
