/* ===== Fancy UI overhaul =====
   - soft gradient page background
   - subtle glass cards with layered shadows
   - richer header with emblem and accent underline
   - gradient action buttons and pill provider tabs
   - more spacious, tactile list items with hover depth
   - gentle entrance animations
*/

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

:root{
    --bg-start: #f7fbff;
    --bg-end: #eef6ff;
    --accent: #0066ff;
    --accent-2: #00bfa6;
    --muted: #6b7280;
    --card: rgba(255,255,255,0.75);
    --glass-border: rgba(255,255,255,0.6);
    --glass-shadow: 0 8px 30px rgba(11,35,68,0.06);
}

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
    background: linear-gradient(180deg, var(--bg-start), var(--bg-end));
    color: #0f172a;
    min-height: 100vh;
    line-height: 1.5;
    padding: 3vh 0;
}

/* Center container with soft inset */
.container {
    max-width: 980px;
    margin: 0 auto;
    padding: 1.75rem;
    transform: translateZ(0);
}

/* Header: emblem, title and subtitle with accent underline */
.header {
    text-align: center;
    margin-bottom: 2.25rem;
    position: relative;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.5rem 0.75rem;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(255,255,255,0.9), rgba(255,255,255,0.7));
    box-shadow: var(--glass-shadow);
    border: 1px solid var(--glass-border);
    margin: 0 auto 0.6rem;
}

.logo-icon {
    width: 44px;
    height: 44px;
    padding: 8px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(0,102,255,0.12), rgba(0,191,166,0.06));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    stroke: var(--accent);
    box-shadow: 0 6px 20px rgba(3, 102, 255, 0.06);
}

.logo h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.2px;
    color: #071033;
}

.subtitle {
    color: var(--muted);
    font-size: 0.95rem;
    margin-top: 0.4rem;
}

/* Email card: glass effect + gradient accent strip */
.email-container {
    background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(250,250,255,0.85));
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--glass-shadow);
    border: 1px solid var(--glass-border);
    margin-bottom: 1.75rem;
    position: relative;
    overflow: hidden;
}

/* thin accent strip */
.email-container::before{
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    height: 4px;
    width: 40%;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    border-bottom-right-radius: 8px;
}

/* label and box spacing */
.email-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 0.75rem;
}

/* email input like a chip */
.email-box {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    position: relative; /* ensures absolute children (copied notification) are positioned correctly */
}

#emailAddress {
    flex: 1;
    padding: 0.95rem 1.15rem;
    border: 1px solid rgba(10,20,40,0.06);
    border-radius: 12px;
    font-size: 0.98rem;
    font-family: 'SFMono-Regular', ui-monospace, SFMono, "Segoe UI Mono", Menlo, Monaco, monospace;
    background: rgba(255,255,255,0.7);
    color: #071033;
    box-shadow: 0 6px 18px rgba(11,35,68,0.04);
    transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

#emailAddress:focus {
    outline: none;
    transform: translateY(-2px);
    border-color: rgba(0,102,255,0.3);
    box-shadow: 0 10px 30px rgba(3,102,255,0.08);
    background: white;
}

.icon-btn {
    background: linear-gradient(180deg, #ffffff, #f7fbff);
    border: 1px solid rgba(10,20,40,0.06);
    border-radius: 12px;
    width: 48px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--muted);
    transition: transform 180ms ease, box-shadow 180ms ease;
    box-shadow: 0 6px 18px rgba(11,35,68,0.03);
}

.icon-btn:hover {
    transform: translateY(-4px);
    box-shadow: 0 18px 40px rgba(3,102,255,0.07);
    color: var(--accent);
}

.icon-btn svg { width: 18px; height: 18px; stroke-width: 1.6; }

/* copy notification becomes a pill near the copy button */
.copied-notification {
    position: absolute;
    top: -42px; /* bring closer and avoid pushing outside small screens */
    right: 8px;
    z-index: 60; /* ensure it's above surrounding elements */
    background: linear-gradient(90deg, #10b981, #06b6d4);
    color: white;
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    opacity: 0;
    pointer-events: none;
    transform-origin: right center;
    transition: opacity 220ms ease, transform 220ms ease;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(7,89,82,0.12);
}

.copied-notification.show {
    opacity: 1;
    transform: translateY(4px);
    pointer-events: auto; /* allow interaction while visible */
}

/* stats - floating badges */
.stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.85rem;
    margin-top: 1.4rem;
    padding-top: 1.4rem;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--muted);
    background: linear-gradient(180deg, rgba(255,255,255,0.6), rgba(250,250,255,0.55));
    border-radius: 12px;
    padding: 0.7rem 0.9rem;
    box-shadow: 0 10px 30px rgba(9,30,60,0.03);
    border: 1px solid rgba(255,255,255,0.6);
}

.stat-item svg { color: var(--accent); width: 18px; height: 18px; }

.stat-item span:first-of-type { font-size: 1.1rem; font-weight: 700; color: #071033; }

.stat-label { font-size: 0.82rem; color: #94a3b8; margin-left: auto; }

/* Inbox card: elevated glass */
.inbox-container {
    background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(250,251,255,0.9));
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 12px 40px rgba(7,22,62,0.06);
    border: 1px solid rgba(255,255,255,0.6);
    min-height: 420px;
}

/* header layout */
.inbox-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.inbox-header h2 { font-size: 1.2rem; font-weight: 700; color: #071033; }

/* Auto-refresh toggle */
.toggle-btn {
    background: transparent;
    border: 1px solid rgba(10,20,40,0.06);
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--muted);
    transition: all 160ms ease;
}

.toggle-btn.active {
    background: linear-gradient(90deg, rgba(0,102,255,0.12), rgba(0,191,166,0.06));
    color: var(--accent);
    border-color: rgba(0,102,255,0.14);
    box-shadow: 0 8px 30px rgba(3,102,255,0.06);
}

.toggle-btn svg { width: 16px; height: 16px; }

/* loading */
.loading-spinner { padding: 3rem; color: #9aa4b2; text-align: center; }
.spinner {
    width: 44px; height: 44px;
    border: 4px solid rgba(8,20,40,0.06);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    margin: 0 auto 0.9rem;
}

/* Empty state with softened icon */
.empty-state { padding: 3rem 1rem; color: #9aa4b2; text-align: center; }
.empty-state svg { opacity: 0.6; width: 68px; height: 68px; }

/* Email list items more tactile */
.email-list { display: flex; flex-direction: column; gap: 0.85rem; }

.email-item {
    background: rgba(255,255,255,0.86);
    border-radius: 14px;
    padding: 1rem 1.15rem;
    cursor: pointer;
    transition: transform 160ms ease, box-shadow 160ms ease;
    border: 1px solid rgba(10,20,40,0.04);
    box-shadow: 0 8px 30px rgba(8,18,50,0.04);
}

.email-item:hover {
    transform: translateY(-6px);
    box-shadow: 0 24px 60px rgba(6,30,80,0.08);
}

.email-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.35rem; }
.email-from { font-weight: 700; color: #071033; font-size: 0.98rem; }
.email-date { font-size: 0.78rem; color: #94a3b8; }

.email-subject { font-size: 0.9rem; color: #374151; margin-bottom: 0.2rem; }
.email-preview { font-size: 0.82rem; color: #6b7280; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Modal refinement */
.modal { display: none; position: fixed; inset: 0; background: rgba(6,18,45,0.45); z-index: 1000; padding: 2rem; }
.modal.show { display: flex; align-items: center; justify-content: center; }
.modal-content {
    background: linear-gradient(180deg, white, #fbfdff);
    border-radius: 14px;
    max-width: 760px;
    width: 100%;
    max-height: 84vh;
    overflow: hidden;
    box-shadow: 0 30px 90px rgba(6,24,70,0.18);
    border: 1px solid rgba(255,255,255,0.6);
    z-index: 1001; /* ensure modal content sits above dim overlay and other UI */
}

/* smoother touch scrolling inside modal on mobile */
.modal-body {
    -webkit-overflow-scrolling: touch;
}

.modal-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid rgba(10,20,40,0.04); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { font-size: 1.05rem; font-weight: 700; color: #071033; }

.modal-body { padding: 1.25rem 1.5rem; overflow-y: auto; }

/* message meta and content */
.message-meta { display: flex; flex-direction: column; gap: 0.55rem; padding-bottom: 1rem; border-bottom: 1px solid rgba(10,20,40,0.04); margin-bottom: 1rem; }
.message-meta-label { font-weight: 700; color: #374151; min-width: 80px; }
.message-meta-value { color: #0b1220; }

.message-content { line-height: 1.7; color: #0b1220; }
.text-content { white-space: pre-wrap; word-wrap: break-word; font-size: 0.95rem; }

/* links & buttons in emails */
.email-link { color: var(--accent); text-decoration: none; border-bottom: 1px solid rgba(0,102,255,0.12); padding-bottom: 1px; transition: all 140ms ease; }
.email-link:hover { color: #004db3; background: rgba(0,102,255,0.04); border-bottom-color: rgba(0,77,179,0.12); }

.message-content .email-button,
.message-content button,
.message-content input[type="button"],
.message-content input[type="submit"] {
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    color: white;
    border: none;
    padding: 0.7rem 1.15rem;
    border-radius: 10px;
    font-size: 0.9rem;
    cursor: pointer;
    box-shadow: 0 12px 30px rgba(3,102,255,0.12);
}

/* Provider tabs pill style */
#providerTabs { display:flex; gap:0.5rem; align-items:center; }

.provider-btn {
    flex: 0 0 auto;
    padding: 0.45rem 0.85rem;
    border: none;
    background: rgba(255,255,255,0.8);
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 700;
    color: #465168;
    transition: transform 140ms ease, box-shadow 140ms ease;
    min-width: 84px;
    text-align: center;
    box-shadow: 0 8px 20px rgba(6,18,50,0.03), inset 0 -2px 0 rgba(0,0,0,0.01);
}

.provider-btn:hover { transform: translateY(-6px); box-shadow: 0 20px 50px rgba(6,18,50,0.06); color: var(--accent); }

.provider-btn.active {
    background: linear-gradient(90deg, rgba(0,102,255,0.12), rgba(0,191,166,0.06));
    color: var(--accent);
    box-shadow: 0 18px 50px rgba(3,102,255,0.06);
}

/* touch-friendly icons */
.icon-btn { min-width:44px; min-height:44px; padding:0.45rem; }

/* responsive tweaks */
@media (max-width: 820px) {
    .container { padding: 1rem; }
    .email-container, .inbox-container { padding: 1rem; }
    .stats { grid-template-columns: 1fr; gap: 0.7rem; }
    #emailAddress { font-size: 0.92rem; }
    .provider-btn { min-width: 68px; padding: 0.45rem 0.6rem; }
}

@media (max-width: 420px) {
    .modal { padding: 0.6rem; }
    .modal-content { max-width: 100%; border-radius: 12px; }
}

/* animations */
@keyframes fadeInDown { from { opacity:0; transform: translateY(-14px); } to { opacity:1; transform: translateY(0); } }
@keyframes fadeInUp { from { opacity:0; transform: translateY(14px); } to { opacity:1; transform: translateY(0); } }
@keyframes slideDown { from { transform: translateY(-8px); opacity:0 } to { transform: translateY(0); opacity:1 } }
@keyframes fadeIn { from { opacity:0 } to { opacity:1 } }
@keyframes slideUp { from { transform: translateY(20px); opacity:0 } to { transform: translateY(0); opacity:1 } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slideIn { from { opacity:0; transform: translateX(-12px); } to { opacity:1; transform: translateX(0); } }