/* Reset & Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #667eea;
    --primary-dark: #5a67d8;
    --success: #48bb78;
    --warning: #ecc94b;
    --danger: #f56565;
    --bg: #f7fafc;
    --bg-dark: #1a202c;
    --text: #2d3748;
    --text-light: #718096;
    --border: #e2e8f0;
    --card-bg: #ffffff;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

.hidden {
    display: none !important;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    background: var(--border);
    color: var(--text);
    transition: all 0.2s;
}

.btn:hover {
    background: #cbd5e0;
}

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

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

.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
    font-size: 0.875rem;
}

.form-group input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Login View */
.login-container {
    max-width: 400px;
    margin: 100px auto;
    padding: 2rem;
    background: var(--card-bg);
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.login-container h1 {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.login-container .subtitle {
    color: var(--text-light);
    margin-bottom: 2rem;
}

.login-container form {
    text-align: left;
}

.login-container .btn {
    width: 100%;
    padding: 0.75rem;
}

.message {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

.message.success {
    background: #c6f6d5;
    color: #276749;
}

.message.error {
    background: #fed7d7;
    color: #9b2c2c;
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-user span {
    font-size: 0.875rem;
    color: var(--text-light);
}

/* Dashboard Layout */
.dashboard {
    display: flex;
    height: calc(100vh - 60px);
}

.sidebar {
    width: 250px;
    padding: 1.5rem;
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    overflow-y: auto;
}

.sidebar h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    color: var(--text-light);
    margin-bottom: 1rem;
}

.sidebar ul {
    list-style: none;
    margin-bottom: 1rem;
}

.sidebar li {
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.25rem;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.875rem;
}

.sidebar li:hover {
    background: var(--bg);
}

.sidebar li.active {
    background: var(--primary);
    color: white;
}

.sidebar li .domain-status {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.5rem;
}

.sidebar li .domain-status.verified {
    background: var(--success);
}

.sidebar li .domain-status.unverified {
    background: var(--warning);
}

/* Content Area */
.content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-light);
}

.empty-state h2 {
    margin-bottom: 0.5rem;
}

/* Analytics Header */
.analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.analytics-header h2 {
    font-size: 1.5rem;
}

.date-range {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.date-range input {
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.card {
    background: var(--card-bg);
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
}

.card h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.card-value {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Sections */
.section {
    background: var(--card-bg);
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    margin-bottom: 1rem;
}

.section h3 {
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

/* Disposition Bars */
.disposition-bars {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.bar-item {
    display: grid;
    grid-template-columns: 100px 1fr 60px;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.bar {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}

.bar-fill.green { background: var(--success); }
.bar-fill.yellow { background: var(--warning); }
.bar-fill.red { background: var(--danger); }

/* Data Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

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

.data-table th {
    font-weight: 500;
    color: var(--text-light);
}

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

/* Setup Info */
.setup-info code {
    display: block;
    padding: 0.75rem;
    background: var(--bg-dark);
    color: #e2e8f0;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 0.5rem;
    width: 100%;
    max-width: 400px;
}

.modal-content h3 {
    margin-bottom: 1rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* Failure Cards */
.failure-cards {
    margin-bottom: 1rem;
}

.card-failure .card-value {
    color: var(--danger);
}

/* Volume Chart */
.volume-chart {
    height: 200px;
    display: flex;
    align-items: flex-end;
    gap: 2px;
    padding: 1rem 0;
}

.volume-bar {
    flex: 1;
    background: var(--primary);
    border-radius: 2px 2px 0 0;
    min-height: 2px;
    transition: height 0.3s;
    position: relative;
}

.volume-bar:hover {
    background: var(--primary-dark);
}

.volume-bar:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-dark);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 10;
}

/* Status badges */
.badge {
    display: inline-block;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-pass {
    background: #c6f6d5;
    color: #276749;
}

.badge-fail {
    background: #fed7d7;
    color: #9b2c2c;
}

.badge-none {
    background: #c6f6d5;
    color: #276749;
}

.badge-quarantine {
    background: #fefcbf;
    color: #744210;
}

.badge-reject {
    background: #fed7d7;
    color: #9b2c2c;
}

/* Sender category badges */
.badge-esp {
    background: #c6f6d5;
    color: #276749;
}

.badge-hosting {
    background: #bee3f8;
    color: #2a4365;
}

.badge-isp {
    background: #e9d8fd;
    color: #553c9a;
}

.badge-corporate {
    background: #e2e8f0;
    color: #4a5568;
}

.badge-suspicious {
    background: #fed7d7;
    color: #9b2c2c;
}

.badge-unknown {
    background: #f7fafc;
    color: #718096;
    border: 1px solid var(--border);
}

/* Forwarded indicator */
.badge-forwarded {
    background: #fefcbf;
    color: #744210;
    font-size: 0.625rem;
    margin-left: 0.25rem;
}

/* Audit page styles */
.badge-success {
    background: #c6f6d5;
    color: #276749;
}

.badge-failed {
    background: #fed7d7;
    color: #9b2c2c;
}

.badge-processing {
    background: #bee3f8;
    color: #2a4365;
}

.badge-received {
    background: #e2e8f0;
    color: #4a5568;
}

/* Audit page layout */
.audit-page {
    padding: 1.5rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.audit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.audit-header h1 {
    font-size: 1.5rem;
}

/* Filters */
.audit-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    align-items: center;
}

.audit-filters select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    background: var(--card-bg);
}

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

.pagination-info {
    font-size: 0.875rem;
    color: var(--text-light);
}

/* Audit table */
.audit-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    background: var(--card-bg);
    border-radius: 0.5rem;
    overflow: hidden;
    border: 1px solid var(--border);
}

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

.audit-table th {
    background: var(--bg);
    font-weight: 500;
    color: var(--text-light);
}

.audit-table tbody tr {
    cursor: pointer;
    transition: background 0.2s;
}

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

.audit-table .time-col {
    white-space: nowrap;
}

.audit-table .subject-col {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Audit modal */
.audit-modal {
    max-width: 700px;
}

.audit-modal h3 {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.audit-modal .close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
}

.audit-detail {
    margin-top: 1rem;
}

.audit-detail-row {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

.audit-detail-row:last-child {
    border-bottom: none;
}

.audit-detail-label {
    font-weight: 500;
    color: var(--text-light);
}

.audit-detail-value {
    word-break: break-all;
}

/* Pipeline stages */
.pipeline-stages {
    margin-top: 1rem;
}

.pipeline-stage {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg);
    border-radius: 0.375rem;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.pipeline-stage-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.pipeline-stage-icon.success {
    background: var(--success);
    color: white;
}

.pipeline-stage-icon.failed {
    background: var(--danger);
    color: white;
}

.pipeline-stage-icon.pending {
    background: var(--border);
    color: var(--text-light);
}

.pipeline-stage-content {
    flex: 1;
}

.pipeline-stage-title {
    font-weight: 500;
}

.pipeline-stage-detail {
    color: var(--text-light);
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

/* Nav links */
.nav-links {
    display: flex;
    gap: 1.5rem;
}

.nav-links a {
    color: var(--text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
}

.nav-links a:hover {
    color: var(--primary);
}

.nav-links a.active {
    color: var(--primary);
}

/* Admin page styles */
.admin-page {
    padding: 1.5rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.admin-header {
    margin-bottom: 1.5rem;
}

.admin-header h1 {
    font-size: 1.5rem;
}

/* Tabs */
.admin-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    color: var(--text-light);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    position: relative;
    transition: color 0.2s;
}

.tab-btn:hover {
    color: var(--text);
}

.tab-btn.active {
    color: var(--primary);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
}

.tab-content {
    background: var(--card-bg);
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    padding: 1rem;
}

.tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.tab-header h2 {
    font-size: 1rem;
    margin: 0;
}

.tab-filters {
    display: flex;
    gap: 0.5rem;
}

.tab-filters select {
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-size: 0.75rem;
    background: var(--card-bg);
}

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

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

.admin-table th {
    background: var(--bg);
    font-weight: 500;
    color: var(--text-light);
    font-size: 0.75rem;
    text-transform: uppercase;
}

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

.admin-table code {
    background: var(--bg);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
}

.admin-table .actions {
    white-space: nowrap;
}

.admin-table .actions .btn {
    margin-left: 0.25rem;
}

/* Badge variants for admin */
.badge-primary {
    background: #bee3f8;
    color: #2a4365;
}

.badge-secondary {
    background: #e2e8f0;
    color: #4a5568;
}

.badge-warning {
    background: #fefcbf;
    color: #744210;
}

/* Danger button */
.btn-danger {
    background: #fed7d7;
    color: #9b2c2c;
}

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

/* Impersonation banner */
.impersonation-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--warning);
    color: #744210;
    padding: 0.5rem 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    font-size: 0.875rem;
    z-index: 1000;
}

.impersonation-banner + .view,
.impersonation-banner ~ #app > .view:not(.hidden) {
    margin-top: 40px;
}

/* Form group select */
.form-group select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    background: var(--card-bg);
}

.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
