/* JoeMail - Premium Dark Theme (layered depth) */

:root {
    --head-font: 'Inter', ui-sans-serif, system-ui, sans-serif;
    --body-font: 'Inter', ui-sans-serif, system-ui, sans-serif;

    /* 0xbal Tools theme — dark charcoal + orange-red accent */
    --bg: #1a1a1a;
    --bg-page: #1a1a1a;
    --bg-card: #242424;
    --bg-card-hover: #282828;
    --bg-input: #1f1f1f;
    --bg-button: #242424;
    --bg-button-hover: #2e2e2e;
    --bg-elevated: #282828;
    --bg-footer: #1a1a1a;

    /* Borders */
    --border: rgba(71,71,71,0.8);
    --border-hover: rgba(71,71,71,1);
    --border-accent: #474747;

    /* Text */
    --text: #f5f5f5;
    --text-secondary: #d4d4d4;
    --text-muted: #808080;

    /* Accent — orange-red */
    --accent: #ff6b4a;
    --accent-hover: #ff8a6f;
    --accent-dim: rgba(255,107,74,0.12);

    /* Radius */
    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 8px;
}

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

html, body {
    line-height: 1.5;
    font-family: var(--body-font);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: var(--bg) !important;
    color: var(--text) !important;
}

h1, h2, h3, h4, h5, h6 { font-family: var(--head-font); }
a { color: inherit; text-decoration: none; }

/* ============================================================ */
/* LAYOUT */
/* ============================================================ */
.min-h-screen { min-height: 100vh; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1; }
.inline { display: inline; }
.grid { display: grid; }
.grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-6 { grid-template-columns: repeat(6, 1fr); }
.hidden { display: none !important; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.items-start { align-items: flex-start; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.text-center { text-align: center; }
.text-start { text-align: start; }
.text-left { text-align: left; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select-none { user-select: none; }
.cursor-pointer { cursor: pointer; }
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.inset-y-0 { top: 0; bottom: 0; }
.top-0 { top: 0; }
.left-0 { left: 0; }
.right-0 { right: 0; }
.bottom-0 { bottom: 0; }
.top-5 { top: 1.25rem; }
.right-5 { right: 1.25rem; }
.bottom-5 { bottom: 1.25rem; }
.z-10 { z-index: 10; }
.z-50 { z-index: 50; }
.block { display: block; }
.appearance-none { appearance: none; }
.w-full { width: 100%; }
.w-screen { width: 100vw; }
.h-full { height: 100%; }
.h-6 { height: 1.5rem; }
.h-80 { height: 20rem; }
.h-screen { height: 100vh; }
.max-w-full { max-width: 100%; }
.max-w-email-dropdown { max-width: 280px; }
.max-w-40 { max-width: 10rem; }
.overflow-hidden { overflow: hidden; }
.overflow-y-auto { overflow-y: auto; }
.pointer-events-none { pointer-events: none; }
.whitespace-nowrap { white-space: nowrap; }

/* Spacing */
.p-2 { padding: 0.5rem; }
.p-4 { padding: 1rem; }
.p-5 { padding: 1.25rem; }
.p-6 { padding: 1.5rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-5 { padding-left: 1.25rem; padding-right: 1.25rem; }
.pr-8 { padding-right: 2rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-5 { padding-top: 1.25rem; padding-bottom: 1.25rem; }
.py-10 { padding-top: 2.5rem; padding-bottom: 2.5rem; }
.pb-5 { padding-bottom: 1.25rem; }
.pb-10 { padding-bottom: 2.5rem; }
.pb-20 { padding-bottom: 5rem; }
.pt-4 { padding-top: 1rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-5 { margin-bottom: 1.25rem; }
.m-2 { margin: 0.5rem; }
.m-3 { margin: 0.75rem; }
.m-4 { margin: 1rem; }
.m-5 { margin: 1.25rem; }
.ml-2 { margin-left: 0.5rem; }
.ml-3 { margin-left: 0.75rem; }
.mr-2 { margin-right: 0.5rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-8 { margin-top: 2rem; }
.mx-5 { margin-left: 1.25rem; margin-right: 1.25rem; }

/* Gap */
.gap-3 { gap: 0.75rem; }
.gap-5 { gap: 1.25rem; }
.space-x-3 > * + * { margin-left: 0.75rem; }
.space-y-2 > * + * { margin-top: 0.5rem; }
.space-y-3 > * + * { margin-top: 0.75rem; }
.space-y-5 > * + * { margin-top: 1.25rem; }

/* Border */
.border-0 { border-width: 0; }
.border { border-width: 1px; border-style: solid; }
.border-2 { border-width: 2px; }
.border-dashed { border-style: dashed; }
.border-white { border-color: var(--border); }
.border-opacity-10 { border-color: var(--border); }
.rounded { border-radius: var(--radius-xs); }
.rounded-md { border-radius: var(--radius-sm); }
.rounded-lg { border-radius: var(--radius); }
.ring-1 { box-shadow: 0 0 0 1px; }
.ring-black { --tw-ring-color: rgba(0,0,0,1); }
.ring-opacity-5 { --tw-ring-opacity: 0.05; }

/* Background overrides */
.bg-primary { background: transparent !important; }
.bg-secondary { background: var(--accent) !important; }
.bg-white { background: var(--bg-input) !important; }
.bg-gray-100 { background: var(--bg-page) !important; }
.bg-gray-800 { background: var(--bg-card) !important; }
.bg-gray-900 { background: var(--bg-page) !important; }
.bg-gray-950 { background: var(--bg-footer) !important; }
.bg-black\/50 { background: rgba(0,0,0,0.6); }
.bg-indigo-600 { background: var(--accent) !important; color: #fff !important; }
.bg-yellow-300 { background: #fde047; }
.bg-green-400 { background: #4ade80; }
.bg-opacity-10 { background-color: var(--bg-button) !important; }
.bg-opacity-25 { background-color: var(--bg-button) !important; }
.bg-opacity-50 { background-color: rgba(255,255,255,0.06); }
.hover\:bg-opacity-10:hover { background-color: var(--bg-button-hover) !important; }
.hover\:bg-opacity-25:hover { background-color: var(--bg-button-hover) !important; }
.hover\:bg-opacity-75:hover { background-color: var(--bg-button-hover) !important; }
.hover\:bg-secondary\/90:hover { background: rgba(255,107,74,0.9) !important; }

/* Text */
.text-white { color: var(--text) !important; }
.text-gray-200 { color: var(--text) !important; }
.text-gray-300 { color: var(--text-secondary) !important; }
.text-gray-400 { color: var(--text-secondary) !important; }
.text-gray-500 { color: var(--text-muted) !important; }
.text-gray-700 { color: var(--text-secondary) !important; }
.text-gray-800 { color: var(--text) !important; }
.text-gray-900 { color: var(--text) !important; }
.text-yellow-500 { color: #eab308; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-lg { font-size: 1.125rem; line-height: 1.75rem; }
.text-3xl { font-size: 1.875rem; line-height: 2.25rem; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.opacity-75 { opacity: 0.75; }
.placeholder-white::placeholder { color: var(--text-muted) !important; }
.placeholder-opacity-50::placeholder { opacity: 0.5; }
.focus\:outline-none:focus { outline: none; }
.transition-colors { transition: color 0.15s, background-color 0.15s, border-color 0.15s; }
.transition-all { transition: all 0.3s ease; }
.backdrop-blur-sm { backdrop-filter: blur(12px); }
.shadow-lg { box-shadow: 0 8px 32px rgba(0,0,0,.4); }
.shadow-xl { box-shadow: 0 16px 48px rgba(0,0,0,.5); }

/* Prose for email body */
.prose { line-height: 1.75; max-width: 65ch; }
.prose-invert { color: var(--text); }
.prose a { color: var(--accent); text-decoration: underline; }
.prose p { margin-top: 0.75em; margin-bottom: 0.75em; }
.prose h1, .prose h2, .prose h3 { font-weight: 700; margin-top: 1.5em; margin-bottom: 0.5em; }
.max-w-none { max-width: none; }

/* ============================================================ */
/* RESPONSIVE */
/* ============================================================ */
@media (min-width: 1024px) {
    .lg\:flex { display: flex !important; }
    .lg\:block { display: block !important; }
    .lg\:hidden { display: none !important; }
    .lg\:flex-row { flex-direction: row; }
    .lg\:order-first { order: -9999; }
    .lg\:grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
    .lg\:grid-cols-6 { grid-template-columns: repeat(6, 1fr); }
    .lg\:items-baseline { align-items: baseline; }
    .lg\:p-10 { padding: 2.5rem; }
    .lg\:px-0 { padding-left: 0; padding-right: 0; }
    .lg\:py-10 { padding-top: 2.5rem; padding-bottom: 2.5rem; }
    .lg\:pb-10 { padding-bottom: 2.5rem; }
    .lg\:mx-0 { margin-left: 0; margin-right: 0; }
    .lg\:my-8 { margin-top: 2rem; margin-bottom: 2rem; }
    .lg\:align-middle { vertical-align: middle; }
    .sm\:inline-block { display: inline-block; }
    .sm\:block { display: block; }
    .sm\:p-0 { padding: 0; }
    .sm\:mt-0 { margin-top: 0; }
    .sm\:text-left { text-align: left; }
    .sm\:align-middle { vertical-align: middle; }
    .sm\:h-screen { height: 100vh; }
    .sm\:my-8 { margin-top: 2rem; margin-bottom: 2rem; }
    .sm\:scale-95 { transform: scale(0.95); }
    .sm\:scale-100 { transform: scale(1); }
}

@media (min-width: 768px) {
    .md\:w-auto { width: auto; }
    .md\:inline { display: inline; }
}

@media (max-width: 640px) {
    .sm\:max-w-full { max-width: 100%; }
    .sm\:inline-block { display: inline-block; }
    .sm\:block { display: block; }
    .sm\:p-0 { padding: 0; }
    .sm\:mt-0 { margin-top: 0; }
    .sm\:text-left { text-align: left; }
    .sm\:align-middle { vertical-align: middle; }
    .sm\:h-screen { height: 100vh; }
    .sm\:my-8 { margin-top: 2rem; margin-bottom: 2rem; }
    .sm\:scale-95 { transform: scale(0.95); }
    .sm\:scale-100 { transform: scale(1); }
}


/* Inbox table styles */
.inbox-table-row:hover {
    background: var(--bg-card-hover) !important;
}
.inbox-table-row td {
    border-bottom: 1px solid var(--border);
}
.inbox-table-row:last-child td {
    border-bottom: none;
}

/* ============================================================ */
/* ANIMATIONS */
/* ============================================================ */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.fa-spin { animation: spin 1s infinite linear; }
.pause-spinner { animation-play-state: paused; }

.translate-y-0 { transform: translateY(0); }
.translate-y-20 { transform: translateY(5rem); }
.opacity-0 { opacity: 0; }
.opacity-100 { opacity: 1; }

/* Dropdown */
.dropdown-anim {
    opacity: 0;
    transform: translateY(-8px) scale(0.97);
    pointer-events: none;
    transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.dropdown-anim.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* View switch */
.view-anim {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.28s cubic-bezier(0.22, 0.61, 0.36, 1),
                transform 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
    will-change: opacity, transform;
}
.view-anim.open {
    opacity: 1;
    transform: translateY(0);
}

/* Modal */
.modal-anim {
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.modal-anim.open {
    opacity: 1;
    transform: scale(1);
}

/* Inbox fade-in */
.inbox-fade-in {
    animation: inboxFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes inboxFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Button press */
.btn-press {
    transition: transform 0.1s ease, background-color 0.15s ease, border-color 0.15s ease;
}
.btn-press:active {
    transform: scale(0.97);
}

/* Toast */
#toast {
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.25s ease;
}

/* ============================================================ */
/* INBOX ITEMS */
/* ============================================================ */
.inbox-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem 1.25rem;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s;
    font-size: 0.875rem;
}
.inbox-item:hover {
    background: var(--bg-card-hover);
    border-color: rgba(255,107,74,0.28);
    box-shadow: 0 0 0 1px rgba(255,107,74,0.08), 0 12px 30px rgba(0,0,0,0.24);
}
.inbox-item .from { font-weight: 600; color: var(--text); }
.inbox-item .subject { opacity: 0.7; margin-top: 0.25rem; color: var(--text-secondary); }
.inbox-item .date { font-size: 0.75rem; opacity: 0.4; color: var(--text-muted); }

/* ============================================================ */
/* DROPDOWN */
/* ============================================================ */
.dropdown-item {
    display: block;
    width: 100%;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background-color 0.15s;
}
.dropdown-item:hover {
    background: var(--bg-button-hover);
    color: var(--text);
}

/* ============================================================ */
/* THEME OVERRIDES */
/* ============================================================ */

/* Grid pattern — via inline style on .groot-theme */
.groot-theme {
    background-color: var(--bg) !important;
}

/* Header - darker elevated bg */
header {
    background: var(--bg-footer) !important;
    border-bottom: 1px solid var(--border);
    position: relative;
    z-index: 100;
}

/* Logo */
.logo span {
    font-family: var(--body-font) !important;
    font-size: 1.35rem !important;
    font-weight: 700 !important;
    letter-spacing: -0.02em !important;
    color: var(--text) !important;
}

/* Email address section card */
#email-view > .border-2,
#new-email-view > .border-2 {
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    border-style: solid !important;
    border-radius: var(--radius) !important;
    box-shadow: 0 0 0 1px rgba(255,107,74,0.045), 0 10px 26px rgba(0,0,0,0.22), 0 0 22px rgba(255,107,74,0.035) !important;
}

/* "Your Email Address" label */
.text-lg.font-bold {
    font-family: var(--body-font) !important;
    font-size: 0.8rem !important;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted) !important;
    font-weight: 600 !important;
}

/* Email display input */
#email-display,
#new-username,
#domain-display {
    background: var(--bg-input) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-xs) !important;
    color: var(--text) !important;
    font-size: 0.95rem;
    font-weight: 500;
}
#email-display:focus,
#new-username:focus {
    border-color: var(--border-accent) !important;
    box-shadow: 0 0 0 2px rgba(255,107,74,0.15) !important;
}

/* Copy / Create / Random buttons */
#btn-copy,
#btn-create-email,
#btn-random {
    background: var(--accent) !important;
    color: #fff !important;
    border: none !important;
    border-radius: var(--radius-xs) !important;
    font-weight: 600;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}
#btn-copy:hover,
#btn-create-email:hover,
#btn-random:hover {
    background: var(--accent-hover) !important;
    box-shadow: 0 4px 16px rgba(255,107,74,0.2) !important;
}

/* Action buttons (Refresh / New / Delete) */
.actions > div {
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    color: var(--text-secondary) !important;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.actions > div:hover {
    background: var(--bg-card-hover) !important;
    border-color: var(--border-hover) !important;
    color: var(--text) !important;
}
.actions .text-sm {
    font-weight: 500;
}

/* Cancel button */
#btn-cancel {
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    color: var(--text-secondary) !important;
}
#btn-cancel:hover {
    background: var(--bg-card-hover) !important;
    color: var(--text) !important;
}

/* Dropdown lists */
.bg-gray-700,
#email-dropdown-list,
#domain-dropdown-list {
    background: var(--bg-elevated) !important;
    border: 1px solid var(--border-accent) !important;
    border-radius: var(--radius-sm) !important;
    box-shadow: 0 16px 48px rgba(0,0,0,.5) !important;
}

/* Inbox empty state */
#inbox-empty {
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
}
#inbox-empty .text-gray-400 {
    color: var(--text-muted) !important;
}

/* ============================================================ */
/* EMAIL DETAIL VIEW */
/* ============================================================ */
#email-detail .bg-gray-800,
#email-detail .rounded-lg {
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    box-shadow: 0 0 0 1px rgba(255,107,74,0.045), 0 10px 26px rgba(0,0,0,0.22), 0 0 22px rgba(255,107,74,0.035) !important;
}

/* Email detail header meta */
.email-meta-label {
    color: var(--text-muted) !important;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.email-meta-value {
    color: var(--text) !important;
    font-size: 0.9rem;
}

/* Back to inbox */
#btn-back-inbox {
    color: var(--accent) !important;
    font-weight: 500;
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-xs);
    transition: color 0.15s, background 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
#btn-back-inbox:hover {
    color: var(--accent-hover) !important;
    background: var(--accent-dim) !important;
}

/* Email body area */
#detail-body {
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
    margin-top: 1rem;
    border: 1px solid var(--border);
    min-height: 80px;
}

/* Separator */
.border-dashed.border-white {
    border-color: var(--border) !important;
}

/* Horizontal rule */
hr.border-gray-700 {
    border: none !important;
    height: 1px;
    background: var(--border) !important;
    margin: 1rem 0 !important;
}

/* Footer */
footer,
.bg-gray-950 {
    background: var(--bg-footer) !important;
    border-top: 1px solid var(--border);
}

/* Toast */
#toast {
    background: var(--accent) !important;
    color: #fff !important;
    border-radius: var(--radius-sm) !important;
    font-weight: 600;
    box-shadow: 0 8px 32px rgba(0,0,0,.4);
}

/* Nav buttons */
.nav-blog {
    color: var(--text-secondary) !important;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-xs);
    transition: color 0.15s, background 0.15s;
}
.nav-blog:hover {
    color: var(--text) !important;
    background: var(--bg-button);
}

.nav-login {
    background: var(--accent) !important;
    color: #fff !important;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-xs);
    font-size: 0.875rem;
    font-weight: 600;
    transition: background 0.15s;
}
.nav-login:hover {
    background: var(--accent-hover) !important;
}

/* Dark mode toggle */
.darkmode-toggle {
    color: var(--text-muted) !important;
    transition: color 0.15s;
}
.darkmode-toggle:hover {
    color: var(--text) !important;
}

/* Language selector */
.lang-select {
    background: var(--bg-card) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-xs);
    padding: 0.35rem 0.6rem;
    font-size: 0.8rem;
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s;
}
.lang-select:hover {
    border-color: var(--border-hover) !important;
}

/* ============================================================ */
/* MOBILE */
/* ============================================================ */
@media (max-width: 640px) {
    header { overflow-x: clip; overflow-y: visible; }

    .logo { min-width: 0; height: 23px; }
    .logo img { max-height: 23px; width: auto; }

    #email-section {
        padding-left: 1.25rem;
        padding-right: 1.25rem;
    }

    #email-view, #new-email-view {
        max-width: 100%;
        width: 100%;
    }

    .actions { gap: 0.5rem !important; }
    .actions .text-sm { display: none; }
}

/* ============================================================ */
/* PRECISION FIXES */
/* ============================================================ */
#email-section { align-items: stretch !important; }
#email-view, #new-email-view {
    width: 100% !important;
    max-width: 100% !important;
    /* opacity and transform controlled by view-anim class */
}
/* view-anim transforms handled by JS */

#btn-new, #btn-refresh, #btn-delete, #btn-cancel,
#btn-copy, #btn-create-email, #btn-random {
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease !important;
}
#btn-new:active, #btn-refresh:active, #btn-delete:active,
.btn-press:active { transform: none !important; }