/* CSS Design System - Central Email Service Gateway */

:root {
    --bg-main: #070913;
    --bg-card: rgba(255, 255, 255, 0.03);
    --border-card: rgba(255, 255, 255, 0.07);
    --border-focus: rgba(99, 102, 241, 0.4);
    
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.25);
    
    --purple: #8b5cf6;
    --emerald: #10b981;
    --red: #f43f5e;
    --blue: #3b82f6;
    --amber: #f59e0b;
    
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dim: #6b7280;
    
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* Ambient glow blobs */
.blob {
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    filter: blur(140px);
    z-index: -1;
    opacity: 0.15;
    pointer-events: none;
    animation: floatBlob 20s infinite alternate;
}

.blob-1 {
    background: var(--purple);
    top: -100px;
    left: -100px;
}

.blob-2 {
    background: var(--blue);
    bottom: -150px;
    right: -100px;
    animation-delay: -5s;
}

.blob-3 {
    background: var(--primary);
    top: 40%;
    left: 30%;
    width: 500px;
    height: 500px;
    opacity: 0.08;
    animation-delay: -10s;
}

@keyframes floatBlob {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 30px) scale(1.15); }
}

/* Glassmorphism base utility */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* Auth Screens Styling */
.auth-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.auth-container {
    width: 100%;
    max-width: 480px;
    padding: 20px;
}

.auth-card {
    padding: 40px;
    text-align: center;
    border-radius: 24px;
}

.brand {
    margin-bottom: 30px;
}

.logo {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.brand-logo-img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 14px;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}

.logo-icon {
    width: 32px;
    height: 32px;
    color: white;
}

.brand h1 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #ffffff, #c7d2fe);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-tagline {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

.auth-form {
    display: none;
    opacity: 0;
    transform: translateY(10px);
    transition: var(--transition-smooth);
}

.auth-form.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.auth-form h2 {
    font-size: 20px;
    margin-bottom: 6px;
    font-weight: 600;
}

.form-desc {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* General Input Styling */
.input-group {
    text-align: left;
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
select {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 14px;
    transition: var(--transition-smooth);
    outline: none;
}

input:focus, select:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.input-disabled {
    background: rgba(255, 255, 255, 0.01) !important;
    color: var(--text-dim) !important;
    cursor: not-allowed;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Button Component */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: var(--transition-smooth);
    gap: 8px;
    outline: none;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-main);
    border: 1px solid var(--border-card);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-mini {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

.btn-mini-action {
    background: rgba(99, 102, 241, 0.1);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

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

.btn-arrow {
    width: 16px;
    height: 16px;
    transition: var(--transition-smooth);
}

.btn-primary:hover .btn-arrow {
    transform: translateX(3px);
}

.toggle-text {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 20px;
}

.toggle-text a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.toggle-text a:hover {
    text-decoration: underline;
}

/* App Layout Grid */
.dashboard-body {
    overflow: hidden;
}

.app-layout {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    padding: 16px;
    gap: 16px;
}

/* Sidebar navigation styling */
.sidebar {
    width: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
    padding-left: 8px;
}

.sidebar-logo {
    width: 28px;
    height: 28px;
    color: var(--primary);
}

.sidebar-logo-img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.sidebar-brand h2 {
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(to right, white, #e0e7ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.user-profile-badge {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--purple), var(--blue));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    font-size: 14px;
}

.user-info h4 {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-admin {
    background: rgba(139, 92, 246, 0.15);
    color: #c084fc;
}

.badge-monitor {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

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

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition-smooth);
    gap: 12px;
}

.nav-icon {
    width: 20px;
    height: 20px;
    stroke-width: 1.75;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-main);
}

.nav-item.active {
    background: rgba(99, 102, 241, 0.08);
    color: white;
    border: 1px solid rgba(99, 102, 241, 0.15);
}

.nav-item.active .nav-icon {
    color: var(--primary);
}

.badge-count {
    background: var(--red);
    color: white;
    margin-left: auto;
    font-size: 10px;
    padding: 2px 6px;
}

.logout-btn:hover {
    background: rgba(244, 63, 94, 0.08) !important;
    color: var(--red) !important;
}

.logout-btn:hover .nav-icon {
    color: var(--red);
}

/* Main Dashboard Panel */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    gap: 16px;
}

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    flex-shrink: 0;
}

.top-bar h1 {
    font-size: 20px;
    font-weight: 700;
}

.system-status-indicator {
    display: flex;
    gap: 20px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-dim);
}

.status-active {
    background-color: var(--emerald);
    box-shadow: 0 0 10px var(--emerald);
}

.status-inactive {
    background-color: var(--red);
    box-shadow: 0 0 10px var(--red);
}

.status-label {
    font-size: 12px;
    color: var(--text-muted);
}

/* Screens Toggle Control */
.dashboard-screen {
    display: none;
    flex-direction: column;
    gap: 16px;
    animation: fadeIn 0.4s ease;
}

.dashboard-screen.active {
    display: flex;
}

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

.screen-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 8px;
}

.screen-header h2 {
    font-size: 18px;
    font-weight: 600;
}

/* Card Grid Metrics */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.metric-card {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.metric-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.metric-icon svg {
    width: 24px;
    height: 24px;
    stroke-width: 2;
}

.metric-purple { background: rgba(139, 92, 246, 0.1); color: #c084fc; border: 1px solid rgba(139, 92, 246, 0.15); }
.metric-emerald { background: rgba(16, 185, 129, 0.1); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.15); }
.metric-red { background: rgba(244, 63, 94, 0.1); color: #fb7185; border: 1px solid rgba(244, 63, 94, 0.15); }
.metric-blue { background: rgba(59, 130, 246, 0.1); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.15); }

.metric-data h3 {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-data p {
    font-size: 22px;
    font-weight: 700;
    margin-top: 2px;
}

/* Charts Card Row */
.chart-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.chart-card {
    padding: 24px;
}

.chart-header {
    margin-bottom: 20px;
}

.chart-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.chart-header .subtitle {
    font-size: 12px;
    color: var(--text-muted);
}

.chart-body {
    position: relative;
    height: 280px;
    width: 100%;
}

/* Filter Panel Styling */
.filter-panel {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    padding: 16px 20px;
    gap: 16px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-grow: 1;
    min-width: 160px;
}

.filter-group label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}

.filter-group select {
    padding: 8px 12px;
    font-size: 13px;
}

/* Table styling in glass cards */
.table-card {
    overflow: hidden;
}

.table-wrapper {
    overflow-x: auto;
    width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 13px;
}

th, td {
    padding: 14px 20px;
}

th {
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-card);
    background: rgba(255, 255, 255, 0.01);
}

td {
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    color: var(--text-main);
    vertical-align: middle;
}

tbody tr:hover {
    background: rgba(255, 255, 255, 0.015);
}

tbody tr.clickable-row {
    cursor: pointer;
    transition: var(--transition-smooth);
}

tbody tr.clickable-row:hover {
    background: rgba(99, 102, 241, 0.08);
}

.mailbox-register-section {
    border: 1px solid var(--border-card);
    background: rgba(255, 255, 255, 0.02);
}

.text-center { text-align: center; }

/* Status tags badges */
.tag {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.tag-sent { background: rgba(16, 185, 129, 0.1); color: #34d399; }
.tag-received { background: rgba(59, 130, 246, 0.1); color: #60a5fa; }
.tag-forwarded { background: rgba(139, 92, 246, 0.1); color: #c084fc; }
.tag-pending { background: rgba(245, 158, 11, 0.1); color: #fbbf24; }
.tag-failed { background: rgba(244, 63, 94, 0.1); color: #fb7185; }

.status-active-badge { color: #34d399; font-weight: 600; }
.status-suspended-badge { color: #fb7185; font-weight: 600; }

/* Code element format */
code {
    background: rgba(255, 255, 255, 0.07);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
}

.copy-key-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.api-key-text {
    font-family: monospace;
    font-size: 12px;
}

.btn-icon-only {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 4px;
    transition: var(--transition-smooth);
}

.btn-icon-only:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

.btn-icon-only svg {
    width: 14px;
    height: 14px;
}

/* Pagination Control */
.table-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-top: 1px solid var(--border-card);
    font-size: 12px;
    color: var(--text-muted);
}

.pagination-buttons {
    display: flex;
    gap: 8px;
}

/* Modals Overlay */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    width: 100%;
    max-width: 520px;
    padding: 28px;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-large {
    max-width: 800px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.close-modal {
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.close-modal:hover {
    color: white;
}

/* Tabs layout inside modal */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-card);
    margin-bottom: 16px;
}

.tab-btn {
    padding: 8px 16px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: var(--transition-smooth);
}

.tab-btn:hover {
    color: white;
}

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

.tab-content {
    width: 100%;
}

.tab-content.hidden {
    display: none;
}

.email-body-iframe {
    width: 100%;
    height: 380px;
    border: 1px solid var(--border-card);
    background: white;
    border-radius: var(--radius-md);
}

.email-body-text {
    width: 100%;
    height: 380px;
    padding: 16px;
    overflow-y: auto;
    border: 1px solid var(--border-card);
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-md);
    font-family: monospace;
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Toast Notification Styling */
.toast {
    visibility: hidden;
    min-width: 250px;
    background-color: #1e293b;
    color: #fff;
    text-align: center;
    border-radius: 8px;
    padding: 12px 20px;
    position: fixed;
    z-index: 2000;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--border-card);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity 0.3s, visibility 0.3s;
}

.toast.show {
    visibility: visible;
    opacity: 1;
}

.toast-success { border-color: rgba(16, 185, 129, 0.4); background-color: #064e3b; }
.toast-error { border-color: rgba(244, 63, 94, 0.4); background-color: #4c0519; }

/* Admin visibility elements filtering */
.admin-only {
    display: none !important;
}

body.is-admin .admin-only {
    display: flex !important;
}

table tr.admin-only, tbody tr.admin-only {
    display: table-row !important;
}

th.admin-only, td.admin-only {
    display: table-cell !important;
}

button.admin-only {
    display: inline-flex !important;
}

/* Utilities */
.hidden { display: none !important; }

/* Responsive adjustments */
@media (max-width: 768px) {
    .app-layout {
        flex-direction: column;
        overflow-y: auto;
        height: auto;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
    }
    
    .main-content {
        overflow-y: visible;
    }
}
