/* ─── Email Dashboard v2.1 — Caroleo Branded ─── */

:root {
    --primary: #1a4c7a;
    --primary-light: #2b6cb0;
    --primary-hover: #163d63;
    --primary-faint: #e8f0f8;
    --success: #107c10;
    --danger: #c4314b;
    --warning: #ca5010;
    --bg: #f4f6f8;
    --surface: #ffffff;
    --text: #1a1a2e;
    --text-secondary: #5a6577;
    --border: #dce1e8;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(26,76,122,0.08);
    --shadow-lg: 0 4px 16px rgba(26,76,122,0.12);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 0.9375rem;
}

/* ─── Layout ─── */
.container { max-width: 1140px; margin: 0 auto; padding: 0 1.5rem; }
.main-content { padding: 2rem 0; min-height: calc(100vh - 140px); }

/* ─── Navbar ─── */
.navbar {
    background: var(--primary);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container { display: flex; justify-content: space-between; align-items: center; }

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: white;
    font-weight: 700;
    font-size: 1rem;
    padding: 0.6rem 0;
}

.nav-logo { height: 32px; width: 32px; border-radius: 50%; }

.nav-menu { display: flex; align-items: center; gap: 0; }

.nav-link {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    padding: 0.85rem 0.9rem;
    font-weight: 500;
    font-size: 0.8125rem;
    letter-spacing: 0.01em;
    transition: all 0.15s;
    border-bottom: 2px solid transparent;
}

.nav-link:hover { color: white; background: rgba(255,255,255,0.08); }
.nav-link.active { color: white; border-bottom-color: white; background: rgba(255,255,255,0.1); }

.nav-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-left: 0.75rem;
    padding-left: 0.75rem;
    border-left: 1px solid rgba(255,255,255,0.2);
}

.user-name { font-weight: 500; font-size: 0.8125rem; color: rgba(255,255,255,0.9); }

/* ─── Badges ─── */
.badge {
    background: var(--primary);
    color: white;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.badge-role { background: var(--text-secondary); }

/* ─── Buttons ─── */
.btn, .btn-primary, .btn-secondary, .btn-danger, .btn-logout {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: all 0.15s;
}

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

.btn-secondary { background: #e5e7eb; color: var(--text); }
.btn-secondary:hover { background: #d1d5db; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #a8283e; }

.btn-logout {
    background: rgba(255,255,255,0.12);
    color: white;
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
    border: 1px solid rgba(255,255,255,0.25);
}
.btn-logout:hover { background: rgba(255,255,255,0.2); }

.btn-small { padding: 0.3rem 0.6rem; font-size: 0.75rem; }

.btn-full { width: 100%; justify-content: center; padding: 0.65rem; font-size: 0.9375rem; }

.btn-refresh {
    background: transparent;
    border: 1px solid var(--border);
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--text-secondary);
    transition: all 0.15s;
}
.btn-refresh:hover { background: var(--primary-faint); }

/* ─── Alerts ─── */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.alert-success { background: #dff6dd; border-left: 3px solid var(--success); color: #0a5c0a; }
.alert-error   { background: #fde7e9; border-left: 3px solid var(--danger); color: #8b1a2b; }
.alert-info    { background: var(--primary-faint); border-left: 3px solid var(--primary); color: var(--primary); }

/* ─── Cards ─── */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.card h2 {
    font-size: 1.0625rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border);
    color: var(--primary);
}

/* ─── Connect Card (M365 linking) ─── */
.connect-card {
    text-align: center;
    padding: 3rem 2rem;
    max-width: 540px;
    margin: 0 auto;
}

.connect-icon { font-size: 3rem; margin-bottom: 1rem; }

.connect-card h2 {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0.5rem;
}

.connect-card p { color: var(--text-secondary); margin-bottom: 0.5rem; }

.connect-buttons { display: flex; gap: 0.75rem; justify-content: center; margin-top: 1.5rem; }

/* ─── Dashboard ─── */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

.dashboard-header h1 { font-size: 1.5rem; margin-bottom: 0.15rem; color: var(--primary); }
.subtitle { color: var(--text-secondary); font-size: 0.875rem; }
.page-title { font-size: 1.5rem; margin-bottom: 1.5rem; color: var(--primary); }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface);
    padding: 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: opacity 0.2s;
    border-top: 3px solid var(--primary);
}

.stat-card[data-loading="true"] { opacity: 0.5; }
.stat-icon { font-size: 2rem; }
.stat-label { font-size: 0.8125rem; color: var(--text-secondary); margin-bottom: 0.1rem; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--primary); }

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.25rem;
}

.dashboard-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

.section-header h2 { font-size: 0.9375rem; color: var(--primary); border: none; margin: 0; padding: 0; }

/* ─── Lists ─── */
.data-list { display: flex; flex-direction: column; gap: 0.5rem; }

.list-item {
    padding: 0.75rem;
    background: var(--bg);
    border-radius: 6px;
    border-left: 3px solid var(--primary-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.list-item-content { display: flex; flex-direction: column; gap: 0.1rem; }

.list-item-badge {
    background: var(--primary);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8125rem;
    font-weight: 600;
    min-width: 28px;
    text-align: center;
}

.text-small { font-size: 0.8125rem; color: var(--text-secondary); }
.text-muted { color: var(--text-secondary); font-style: italic; font-size: 0.875rem; }

/* ─── Profile ─── */
.profile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.25rem;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 0.625rem 0;
    border-bottom: 1px solid var(--border);
}
.info-row:last-child { border-bottom: none; }
.info-label { font-weight: 500; color: var(--text-secondary); }

/* ─── Page Header ─── */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.page-header h1 { font-size: 1.5rem; color: var(--primary); }

/* ─── Rules ─── */
.rules-container {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.rules-list { display: flex; flex-direction: column; gap: 0.75rem; }

.rule-card {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    transition: box-shadow 0.15s;
}
.rule-card:hover { box-shadow: var(--shadow-lg); }

.rule-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; }
.rule-header h3 { font-size: 1rem; }

.rule-status { padding: 0.2rem 0.5rem; border-radius: 10px; font-size: 0.8125rem; font-weight: 500; }
.rule-status.enabled { background: #dff6dd; color: var(--success); }
.rule-status.disabled { background: #f3f2f1; color: var(--text-secondary); }

.rule-details { margin-bottom: 0.75rem; font-size: 0.875rem; }
.rule-condition, .rule-action { margin-bottom: 0.25rem; }
.rule-actions { display: flex; gap: 0.5rem; }

/* ─── Tables ─── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.data-table th {
    text-align: left;
    padding: 0.5rem 0.625rem;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.data-table td {
    padding: 0.5rem 0.625rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tr:hover td { background: var(--primary-faint); }

.action-cell { white-space: nowrap; display: flex; gap: 0.35rem; }

.form-control-inline {
    padding: 0.2rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: inherit;
    background: white;
}

.status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 0.3rem;
}
.status-dot.status-active { background: var(--success); }
.status-dot.status-suspended { background: var(--danger); }
.status-dot.status-pending { background: var(--warning); }

/* ─── Modal ─── */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--surface);
    border-radius: 12px;
    padding: 1.75rem;
    max-width: 480px;
    width: 92%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; }
.modal-header h2 { font-size: 1.125rem; color: var(--primary); }

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0.25rem;
}

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.3rem; font-weight: 500; font-size: 0.8125rem; color: var(--text-secondary); }

.form-control {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.875rem;
    font-family: inherit;
    transition: border-color 0.15s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,76,122,0.1); }

.form-row { display: flex; gap: 1rem; }
.form-half { flex: 1; }

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

/* ─── Login ─── */
.login-body {
    background: var(--primary);
    background: linear-gradient(135deg, #0d2b45 0%, #1a4c7a 40%, #2b6cb0 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container { padding: 2rem; width: 100%; max-width: 420px; }

.login-card {
    background: var(--surface);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
    padding: 2.5rem 2rem;
}

.login-header { text-align: center; margin-bottom: 2rem; }

.login-logo {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    margin-bottom: 0.75rem;
    box-shadow: 0 2px 8px rgba(26,76,122,0.2);
}

.login-header h1 {
    font-size: 1.375rem;
    color: var(--primary);
    margin-bottom: 0;
}

.login-form { display: flex; flex-direction: column; gap: 0; }

.login-footer {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

/* ─── Footer ─── */
.footer {
    margin-top: 3rem;
    padding: 1.25rem 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .nav-menu { flex-wrap: wrap; gap: 0; }
    .nav-user { margin-left: 0; padding-left: 0; border: none; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .dashboard-grid, .profile-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; gap: 0.75rem; align-items: flex-start; }
    .dashboard-header { flex-direction: column; gap: 0.75rem; }
    .form-row { flex-direction: column; gap: 0; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .login-card { padding: 1.75rem 1.25rem; }
    .login-container { padding: 1rem; }
}
