/* ===== GLOBALS & VARIABLES ===== */
:root {
    --clr-bg: #FFFFFF;
    --clr-bg-alt: #F8F9FA;
    --clr-text-main: #2D3748;
    --clr-text-light: #718096;
    --clr-primary: #6C8EBF;
    --clr-primary-hover: #5A79A4;
    --clr-secondary: #EADDC9;
    --clr-secondary-hover: #D4C4AE;
    --clr-badge-blue: #EBF4FF;
    --clr-badge-blue-text: #3182CE;
    --clr-badge-orange: #FFFAF0;
    --clr-badge-orange-text: #DD6B20;
    --clr-badge-grey: #EDF2F7;
    --clr-badge-grey-text: #4A5568;
    --font-main: 'Outfit', sans-serif;
    --max-width: 1200px;
    --container-padding: 2rem;
    --section-padding: 4rem 0;
    --shadow-sm: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
    --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.05), 0 4px 6px -2px rgba(0,0,0,0.03);
    --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-bounce: 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; overflow-y: auto; overflow-x: hidden; }
body { font-family: var(--font-main); background-color: var(--clr-bg); color: var(--clr-text-main); line-height: 1.6; overflow-x: hidden; min-height: 100vh; position: relative; }
img { max-width: 100%; height: auto; display: block; }
a { text-decoration: none; color: inherit; transition: color var(--transition-fast); }
.container { width: 100%; max-width: var(--max-width); margin: 0 auto; padding: 0 var(--container-padding); }
.section { padding: var(--section-padding); }
.bg-light { background-color: var(--clr-bg-alt); }

/* Custom Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--clr-bg-alt); }
::-webkit-scrollbar-thumb { background: var(--clr-primary); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--clr-primary-hover); }

/* Typography */
h1, h2, h3 { font-weight: 700; line-height: 1.2; margin-bottom: 1rem; color: var(--clr-text-main); }
h1 { font-size: clamp(2.5rem, 5vw, 4rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(2rem, 4vw, 2.5rem); text-align: center; margin-bottom: 0.5rem; }
.section-header { margin-bottom: 3.5rem; text-align: center; }
.section-header h2 {
    display: inline-block;
    position: relative;
    padding-bottom: 12px;
    font-size: 2.2rem;
    color: var(--clr-text-main);
    text-transform: capitalize;
}
.section-header h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 4px;
    background: var(--clr-primary);
    border-radius: 2px;
}
#dynamic-sections { padding-top: 2rem; }
.category-section:first-child { border-top: 1px solid rgba(0,0,0,0.05); }
body.dark-mode .category-section:first-child { border-top: 1px solid rgba(255,255,255,0.05); }
.section-header p { color: var(--clr-text-light); font-size: 1.1rem; max-width: 600px; margin: 0 auto; }

/* Buttons */
.btn-primary, .btn-secondary, .btn-primary-outline {
    display: inline-block; padding: 0.875rem 1.75rem; border-radius: 50px;
    font-weight: 600; font-size: 1rem; cursor: pointer;
    transition: all var(--transition-bounce); border: none; text-align: center; font-family: var(--font-main);
}
.btn-primary { background-color: var(--clr-primary); color: var(--clr-primary-text, white); box-shadow: 0 4px 14px rgba(0,0,0,0.15); }
.btn-primary:hover { background-color: var(--clr-primary-hover); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.2); }
.btn-secondary { background-color: var(--clr-secondary); color: var(--clr-text-main); }
.btn-secondary:hover { background-color: var(--clr-secondary-hover); transform: translateY(-2px); }
.btn-primary-outline { background-color: transparent; color: var(--clr-primary); border: 2px solid var(--clr-primary); padding: 0.6rem 1.5rem; }
.btn-primary-outline:hover { background-color: var(--clr-primary); color: white; }
.w-100 { width: 100%; }

/* Navbar */
.navbar {
    position: fixed; top: 0; left: 0; width: 100%;
    padding: 1.5rem 0; display: flex;
    justify-content: center; align-items: center;
    background: transparent; z-index: 100;
    transition: padding var(--transition-normal), background var(--transition-normal), box-shadow var(--transition-normal);
}
.navbar.scrolled { 
    padding: 0.75rem 0; 
    background: rgba(255,255,255,0.92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); 
    box-shadow: var(--shadow-sm);
}
/* Real bug found 2026-09-01: a doctor's public portfolio replaces this logo's
   text with "<Full Name>'s Portfolio" (see public.js's nav-logo assignment) -
   a long name wraps to 2 lines here, but .navbar is `position: fixed` and
   .hero's padding-top is a fixed value sized for ONE line, so a wrapped
   2-line navbar visually overlaps the hero heading below it instead of
   pushing it down. Constraining this to one line with an ellipsis (rather
   than reserving more vertical space for a rare long name) keeps the navbar
   height predictable for every doctor, short or long name alike. */
.logo { font-size: 1.6rem; font-weight: 800; color: var(--clr-primary); letter-spacing: -1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 340px; }
.nav-links { list-style: none; display: flex; gap: 2rem; align-items: center; }
/* white-space: nowrap keeps a link label on one line instead of wrapping —
   without it, a category row that's a bit too wide for the available width
   (seen in in-app browsers like LinkedIn's, which give the page less width
   than the phone's own browser does) squeezes each link's text onto two
   cramped lines instead of just sitting a little closer together. */
.nav-links a { font-weight: 500; font-size: 0.95rem; white-space: nowrap; }
.nav-links a:hover:not(.btn-primary-outline) { color: var(--clr-primary); }

.mobile-menu-btn { display: none; flex-direction: column; gap: 5px; background: none; border: none; cursor: pointer; padding: 4px; }
.mobile-menu-btn span { display: block; width: 24px; height: 2px; background-color: var(--clr-text-main); transition: all var(--transition-normal); border-radius: 2px; }
.mobile-menu-btn.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.mobile-menu-btn.active span:nth-child(2) { opacity: 0; }
.mobile-menu-btn.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* Hero */
.hero { min-height: 75vh; display: flex; align-items: center; padding-top: 80px; padding-bottom: 2rem; position: relative; }
.hero-content { display: flex; align-items: center; justify-content: space-between; gap: 4rem; }
.hero-text { flex: 1; z-index: 10; }
.hero-text h1 { margin-bottom: 1.75rem; }
.highlight { color: var(--clr-primary); position: relative; display: inline-block; }
.highlight::after { content: ''; position: absolute; bottom: 4px; left: 0; width: 0; height: 6px; background-color: var(--clr-secondary); z-index: -1; opacity: 0.45; border-radius: 3px; animation: highlightAnim 1s ease-out forwards; animation-delay: 0.3s; }
@keyframes highlightAnim { to { width: 100%; } }
.hero-text h2 { text-align: left; font-size: 1.5rem; font-weight: 500; color: var(--clr-text-light); margin-bottom: 1.5rem; line-height: 1.5; max-width: 520px; text-wrap: balance; }
.hero-text p { font-size: 1.1rem; color: var(--clr-text-light); margin-bottom: 2.5rem; max-width: 500px; }
.hero-actions { display: flex; gap: 1rem; }

.hero-image-wrapper { flex: 1; position: relative; display: flex; justify-content: center; align-items: center; }
.hero-image { width: 380px; height: 380px; border-radius: 50%; overflow: hidden; position: relative; z-index: 2; box-shadow: var(--shadow-lg); background: linear-gradient(135deg, #e0e8f0, #f0ece4); }
.hero-image img { width: 100%; height: 100%; object-fit: cover; object-position: center top; }
.profile-fallback { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, rgba(108,142,191,0.15), rgba(234,221,201,0.3)); }

.blob { position: absolute; border-radius: 50%; filter: blur(40px); z-index: 1; opacity: 0.5; }
.blob-1 { width: 280px; height: 280px; background-color: var(--clr-primary); top: -10%; right: 10%; animation: float 6s ease-in-out infinite; }
.blob-2 { width: 240px; height: 240px; background-color: var(--clr-secondary); bottom: -10%; left: 10%; animation: float 8s ease-in-out infinite reverse; }

@keyframes float { 0% { transform: translateY(0) scale(1); } 50% { transform: translateY(-20px) scale(1.05); } 100% { transform: translateY(0) scale(1); } }
@keyframes morph { 0% { border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%; } 50% { border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%; } 100% { border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%; } }

/* Grid & Cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.5rem; }
.category-section { scroll-margin-top: 85px; }
#contact { scroll-margin-top: 85px; }
.card { background: white; border-radius: 20px; overflow: hidden; box-shadow: var(--shadow-md); transition: transform var(--transition-bounce), box-shadow var(--transition-normal); position: relative; border: 1px solid rgba(0,0,0,0.05); opacity: 0; transform: translateY(30px); display: flex; flex-direction: column; }
.card.visible { opacity: 1; transform: translateY(0); }
.card.visible:hover { transform: translateY(-8px); box-shadow: var(--shadow-lg); }
.card-badge { position: absolute; top: 1rem; right: 1rem; padding: 0.3rem 0.85rem; border-radius: 20px; font-size: 0.75rem; font-weight: 700; z-index: 10; letter-spacing: 0.5px; }
.badge-blue { background: var(--clr-badge-blue); color: var(--clr-badge-blue-text); }
.badge-orange { background: var(--clr-badge-orange); color: var(--clr-badge-orange-text); }
.badge-grey { background: var(--clr-badge-grey); color: var(--clr-badge-grey-text); }

.card-image-placeholder, .card-iframe-wrapper { height: 220px; background: linear-gradient(135deg, #f0f4f8, #e2e8f0); display: flex; align-items: center; justify-content: center; color: var(--clr-text-light); font-weight: 500; }
.card-image { height: 220px; overflow: hidden; background: #f0f4f8; position: relative; }
.card-image img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s ease; }
.card-image img.hidden { display: none; }
.gallery-count { position: absolute; bottom: 0.75rem; right: 0.75rem; background: rgba(0,0,0,0.7); color: white; padding: 0.3rem 0.6rem; border-radius: 6px; font-size: 0.75rem; font-weight: 600; pointer-events: none; z-index: 5; }
.gallery-nav { position: absolute; top: 50%; width: 100%; display: flex; justify-content: space-between; padding: 0 0.5rem; transform: translateY(-50%); z-index: 6; opacity: 0.85; transition: opacity 0.2s ease; }
.card-image:hover .gallery-nav { opacity: 1; }
.nav-arrow { background: rgba(255,255,255,0.9); border: none; width: 30px; height: 30px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 0.9rem; box-shadow: 0 2px 8px rgba(0,0,0,0.25); }
.nav-arrow:hover { background: white; }
.placeholder-icon, .iframe-placeholder { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; font-size: 0.9rem; color: var(--clr-text-light); }
.card-content { padding: 1.5rem; display: flex; flex-direction: column; flex-grow: 1; }
.card-content h3 { font-size: 1.2rem; margin-bottom: 0.5rem; word-break: break-word; }
.card-content p {
    color: var(--clr-text-light); font-size: 0.95rem; margin-bottom: 1rem; word-break: break-word;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
    text-overflow: ellipsis; min-height: 0;
}
.card-content .btn-primary-outline { align-self: flex-start; }
.card-actions { margin-top: auto; padding-top: 1rem; display: flex; flex-wrap: wrap; gap: 0.6rem; }
.card-actions .btn-primary-outline, .card-actions .btn-text-link { margin: 0; }
.btn-text-link {
    background: none; border: none; padding: 0.4rem 0; font-size: 0.85rem; font-weight: 600;
    color: var(--clr-primary); cursor: pointer; align-self: flex-start;
}
.btn-text-link:hover { text-decoration: underline; }

/* Delete button on cards */
.card-delete { position: absolute; top: 0.75rem; left: 0.75rem; width: 28px; height: 28px; border-radius: 50%; background: rgba(255,255,255,0.9); border: 1px solid #e2e8f0; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 1rem; color: #e53e3e; opacity: 0; transition: opacity var(--transition-fast); z-index: 11; }
.card:hover .card-delete { opacity: 1; }
.card-delete:hover { background: #fed7d7; }

/* Placeholder section for Code */
.placeholder-section { display: flex; justify-content: center; }
.placeholder-box { text-align: center; padding: 4rem 2rem; border: 2px dashed #d0d5dd; border-radius: 20px; max-width: 500px; width: 100%; }
.placeholder-box svg { margin-bottom: 1.5rem; opacity: 0.5; }
.placeholder-box h3 { color: var(--clr-text-light); font-size: 1.3rem; }
.placeholder-box p { color: #94a3b8; font-size: 0.95rem; }

/* Add Case Button */
.add-case-btn { font-size: 0.9rem; padding: 0.7rem 1.5rem; }

/* Contact */
.contact-container { display: grid; grid-template-columns: 1fr 1fr; gap: 4rem; align-items: start; }
.contact-info h2 { text-align: left; font-size: clamp(1.8rem, 3vw, 2.2rem); }
.contact-info p { color: var(--clr-text-light); margin-bottom: 2rem; font-size: 1.05rem; line-height: 1.7; }
.contact-email { font-size: 1.1rem; font-weight: 600; }
.contact-email a { color: var(--clr-primary); }
.contact-email a:hover { text-decoration: underline; }
.contact-form { background: white; padding: 2.5rem; border-radius: 24px; box-shadow: var(--shadow-lg); border: 1px solid rgba(0,0,0,0.05); }

/* Portfolio Category Nav */
.portfolio-cat-nav { position: sticky; top: 70px; background: rgba(255,255,255,0.9); backdrop-filter: blur(12px); border-bottom: 1px solid rgba(0,0,0,0.08); z-index: 90; padding: 0; }
.portfolio-cat-nav .container { overflow-x: auto; scrollbar-width: none; }
.portfolio-cat-nav .container::-webkit-scrollbar { display: none; }
.portfolio-cat-nav ul { display: flex; list-style: none; gap: 0; padding: 0; margin: 0; white-space: nowrap; }
.portfolio-cat-nav ul li a { display: inline-block; padding: 1rem 1.5rem; font-size: 0.9rem; font-weight: 500; color: var(--clr-text-light); border-bottom: 2px solid transparent; transition: all var(--transition-fast); }
.portfolio-cat-nav ul li a:hover, .portfolio-cat-nav ul li a.active { color: var(--clr-primary); border-bottom-color: var(--clr-primary); }

/* Dark mode contact nav */
[data-theme="dark"] .portfolio-cat-nav { background: rgba(26,32,44,0.95); border-bottom-color: rgba(255,255,255,0.1); }
[data-theme="dark"] .contact-card { background: var(--clr-bg-alt); }
.form-group { margin-bottom: 1.5rem; }
.form-group label { display: block; margin-bottom: 0.5rem; font-weight: 500; font-size: 0.9rem; }
.form-group input, .form-group textarea { width: 100%; padding: 0.875rem 1.25rem; border: 1px solid #e2e8f0; border-radius: 12px; font-family: var(--font-main); font-size: 1rem; transition: all var(--transition-fast); background-color: #f8fafc; }
.form-group input:focus, .form-group textarea:focus { outline: none; border-color: var(--clr-primary); box-shadow: 0 0 0 3px rgba(108,142,191,0.2); background-color: white; }

/* File input */
.file-input { padding: 0.5rem !important; background: white !important; cursor: pointer; }
.file-preview { margin-top: 0.75rem; }
.file-preview img { max-height: 120px; border-radius: 8px; border: 1px solid #e2e8f0; }

.nav-links .cat-nav-link { color: var(--clr-text-light); font-weight: 500; font-size: 0.92rem; padding: 0.3rem 0; border-bottom: 2px solid transparent; transition: all var(--transition-fast); }
.nav-links .cat-nav-link:hover, .nav-links .cat-nav-link.active { color: var(--clr-primary); border-bottom-color: var(--clr-primary); }

/* Main-category dropdown — keeps the navbar bounded no matter how many
   sub-categories a doctor adds; growth happens inside the menu, not as new
   top-level nav items. */
.cat-dropdown { position: relative; }
.cat-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 0.75rem;
    background: var(--clr-bg);
    border: 1px solid rgba(148,163,184,0.2);
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    padding: 0.5rem;
    min-width: 180px;
    list-style: none;
    z-index: 150;
}
.cat-dropdown-menu li { padding: 0; }
.cat-dropdown-menu .cat-nav-link { display: block; padding: 0.6rem 0.8rem; border-bottom: none; border-radius: 6px; }
.cat-dropdown-menu .cat-nav-link:hover, .cat-dropdown-menu .cat-nav-link.active { background: rgba(108,142,191,0.08); }
.cat-dropdown:hover .cat-dropdown-menu, .cat-dropdown.open .cat-dropdown-menu { display: block; }
.cat-dropdown .dropdown-toggle { cursor: pointer; }

/* Archive brand mark — two fixed colors (light / dark mode), completely
   independent of --clr-primary. --clr-primary is overridden per doctor by
   their chosen portfolio theme (Ocean, Emerald, Sunset... see themes.js), and
   the brand mark must not follow a doctor's personal color choice — only the
   site's own light/dark mode. */
.archive-mark-stroke { stroke: #6C8EBF; }
body.dark-mode .archive-mark-stroke { stroke: #818CF8; }

/* Modal */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 200; justify-content: center; align-items: center; backdrop-filter: blur(4px); }
.modal-overlay.active { display: flex; }
.modal { background: white; padding: 2.5rem; border-radius: 24px; width: 90%; max-width: 500px; position: relative; box-shadow: var(--shadow-lg); animation: modalIn 0.3s ease; max-height: 90vh; overflow-y: auto; }
.modal.preview-modal { max-width: 1000px; width: 95%; height: 85vh; display: flex; flex-direction: column; }
.iframe-container { flex-grow: 1; background: #eee; border-radius: 12px; overflow: hidden; position: relative; }
.iframe-container iframe { width: 100%; height: 100%; }
.modal-close { position: absolute; top: 1rem; right: 1.25rem; background: none; border: none; font-size: 1.8rem; cursor: pointer; color: var(--clr-text-light); line-height: 1; z-index: 10; }
.modal-close:hover { color: var(--clr-text-main); }
.modal h3 { margin-bottom: 1.5rem; text-align: center; }
@keyframes modalIn { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }

/* Monkey */
.monkey-container { position: fixed; right: 0; top: 0; bottom: 0; width: 60px; z-index: 50; pointer-events: none; display: flex; justify-content: center; }
.cable { position: absolute; width: 2px; height: 100%; background: linear-gradient(to bottom, #cbd5e1, #94a3b8); left: 50%; transform: translateX(-50%); }
.monkey { position: absolute; top: 100px; width: 90px; height: 90px; transition: top 0.15s ease-out; left: 50%; transform: translateX(-50%); }
.monkey-avatar { width: 100%; height: 100%; position: absolute; top: 0; left: 0; transition: opacity 0.4s ease, transform 0.4s var(--transition-bounce); opacity: 0; transform: scale(0.7); }
.monkey-avatar:not(.hidden) { opacity: 1; transform: scale(1); }
@keyframes swinging { 0% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } 100% { transform: rotate(-3deg); } }
.monkey-avatar:not(.hidden) svg { animation: swinging 3s ease-in-out infinite; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.15)); }

footer { text-align: center; padding: 0.5rem 0; border-top: 1px solid rgba(148, 163, 184, 0.2); background: transparent; color: var(--clr-text-light); font-size: 0.8rem; margin-top: auto; }
body.dark-mode footer { border-top: 1px solid rgba(255, 255, 255, 0.05); }

/* Responsive */
@media (max-width: 992px) {
    /* Between this width and the 768px cutover where nav-links switches to
       the hamburger dropdown, the category row is still laid out inline —
       an in-app browser (LinkedIn's included) often renders the page at a
       width in this exact range while giving it less real visual space than
       a normal mobile browser tab would, so tighten the gap/font here to
       keep several category links on one line instead of crowding together. */
    .nav-links { gap: 1rem; }
    .nav-links a:not(.btn-primary-outline) { font-size: 0.85rem; }
    /* The "⚡ Powered by Archive" visitor badge is by far the widest single
       item in this row (~190px — more than double any category link), and
       it's a branding/upsell link, not something a visitor needs to read in
       full. Dropping "Powered by" and tightening its padding claws back
       ~90px for the actual category links in exactly the width range where
       an in-app browser (LinkedIn's included) was still reported as too
       tight even after the gap/font shrink above. */
    .nav-powered-badge { padding: 0.4rem 0.7rem !important; }
    .nav-powered-badge .pb-label { display: none; }
    .hero-content { flex-direction: column-reverse; text-align: center; padding-top: 2rem; }
    .hero-text h2 { text-align: center; margin: 0 auto 1.5rem; }
    .hero-text p { margin: 0 auto 2rem; }
    .hero-actions { justify-content: center; }
    .hero-image { width: 300px; height: 300px; }
    .contact-container { grid-template-columns: 1fr; gap: 2rem; }
    .contact-info h2 { text-align: center; }
    .monkey-container { right: 1%; opacity: 0.25; }
}
@media (max-width: 768px) {
    :root {
        --container-padding: 1.25rem;
        --section-padding: 4rem 0;
    }
    .mobile-menu-btn { display: flex; }
    /* A doctor's full name in the title ("Manar Hassan's Portfolio") wraps
       into one word per line at the desktop size on a narrow screen — shrink
       it, and drop the secondary "by Al-Manara" tag, which just crowds an
       already-tight row without adding anything a visitor here needs. */
    .logo { font-size: 1.05rem; line-height: 1.25; }
    #by-al-manara-tag { display: none; }

    /* Dashboard's own brand row: icon + "Archive Dashboard" + plan badge —
       shrink each piece so the row fits next to the theme toggle and
       hamburger button without wrapping onto a second line. */
    .dash-brand { flex-wrap: nowrap; gap: 6px !important; }
    .dash-brand-icon { width: 18px !important; height: 18px !important; }
    .dash-brand-text { white-space: nowrap; }
    .dash-brand-badge { font-size: 0.62rem !important; padding: 2px 6px !important; }
    /* Share/Save buttons were squeezed side by side into roughly-square
       boxes on a phone width, so "Save Changes" wrapped to two lines inside
       a 50px-radius pill and looked like a blob instead of a button. Full
       width, stacked, keeps each one a normal single-line pill shape. */
    .profile-actions-row { flex-direction: column; align-items: stretch !important; }
    .profile-actions-row button { width: 100%; }
    .nav-links { display: none; position: absolute; top: 100%; left: 0; width: 100%; background: var(--clr-bg); backdrop-filter: blur(12px); flex-direction: column; padding: 1.5rem 0; gap: 0; box-shadow: var(--shadow-md); z-index: 1000; }
    .nav-links.active { display: flex; }
    .nav-links li { padding: 0.75rem 2rem; }
    /* Dropdowns become inline accordions on mobile — no hover exists on
       touch, and a floating absolute menu would run off the slide-out panel
       anyway. A tap expands the sub-categories in place. */
    .cat-dropdown-menu { position: static; display: none; box-shadow: none; border: none; background: none; margin-top: 0.5rem; padding: 0 0 0 1rem; }
    .cat-dropdown.open .cat-dropdown-menu { display: block; }
    .cat-dropdown-menu li { padding: 0.5rem 0; }
    h1 { font-size: 2rem; }
    .hero-image { width: 250px; height: 250px; }
    .monkey-container { display: none; }
    .grid { grid-template-columns: 1fr; }
}
@media (max-width: 400px) {
    /* Still tight on very small phones — shrink further instead of hiding;
       the plan badge stays visible at every width. */
    .dash-brand { gap: 4px !important; }
    .dash-brand-text { font-size: 0.85rem; }
    .dash-brand-badge { font-size: 0.55rem !important; padding: 1px 5px !important; }
}

/* ===== ADMIN MODE ===== */
.admin-only { display: none !important; }
body.admin-mode .admin-only { display: inline-block !important; }
body.admin-mode .card .card-delete.admin-only { display: flex !important; }
/* ===== PREMIUM SPLIT LAYOUT (AUTH) ===== */
.auth-body { margin: 0; padding: 0; height: 100vh; overflow: hidden; background-color: var(--clr-bg); }
.split-layout { display: flex; width: 100%; height: 100vh; }
.split-brand {
    flex: 1; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center;
    padding: 4rem; color: white;
    background:
        radial-gradient(circle at 15% 85%, rgba(234,221,201,0.25) 0%, rgba(234,221,201,0) 45%),
        linear-gradient(160deg, #7C9CCB 0%, var(--clr-primary) 45%, #3E5A85 100%);
}
.beacon-rays { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }
.brand-content { position: relative; z-index: 10; max-width: 500px; }
.brand-logo { font-size: 2rem; font-weight: 800; letter-spacing: -1px; margin-bottom: 2rem; display: inline-block; padding-bottom: 1rem; border-bottom: 2px solid rgba(255,255,255,0.25); }
.brand-content h1 { color: white; font-size: 2.5rem; line-height: 1.15; margin-bottom: 1.5rem; text-shadow: 0 2px 24px rgba(0,0,0,0.15); }
.brand-content p { font-size: 1.08rem; opacity: 0.92; margin-bottom: 2.75rem; line-height: 1.7; max-width: 440px; }
.brand-features { display: flex; flex-direction: column; gap: 0.85rem; }
.feature-item { display: flex; align-items: center; gap: 0.9rem; font-size: 1rem; font-weight: 500; }
.feature-icon {
    flex: none; width: 30px; height: 30px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.14); border: 1px solid rgba(255,255,255,0.18);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.feature-icon svg { width: 15px; height: 15px; color: #F5EDE0; }

.split-form-container { flex: 1; display: flex; justify-content: center; align-items: center; background-color: var(--clr-bg); padding: 2rem; overflow-y: auto; position: relative; }
.auth-card-modern { width: 100%; max-width: 440px; }
.mobile-logo { display: none; font-size: 1.8rem; font-weight: 800; color: var(--clr-primary); margin-bottom: 2rem; text-align: center; }
.auth-card-modern h2 { text-align: left; font-size: 2.2rem; margin-bottom: 0.5rem; letter-spacing: -0.01em; }
.auth-subtitle { color: var(--clr-text-light); margin-bottom: 2.5rem; font-size: 1.05rem; }

.auth-tabs-modern { position: relative; display: flex; gap: 0.25rem; margin-bottom: 2.5rem; background: rgba(108,142,191,0.08); padding: 0.35rem; border-radius: 12px; }
.auth-tab {
    position: relative; z-index: 2; flex: 1; background: none; border: none; padding: 0.7rem 0; font-size: 0.98rem;
    font-weight: 600; color: var(--clr-text-light); cursor: pointer; border-radius: 9px; transition: color 0.25s ease;
    font-family: var(--font-main);
}
.auth-tab:hover { color: var(--clr-text-main); }
.auth-tab.active { color: var(--clr-primary-hover); }
/* The active-tab highlight is a real element (.auth-tab-slider) positioned in
   pixels by JS (see positionAuthSlider in auth.js), not a ::before driven by
   the CSS :has() selector — :has() silently fails on older/regional mobile
   browsers (older Android WebViews, some Arabic-market browsers), which left
   the pill frozen under "Login" as a detached white box even once "Create
   Account" was the active tab. left/width below are just the first-paint
   default (Login active) so there's no flash before JS runs. */
.auth-tab-slider {
    content: ''; position: absolute; z-index: 1; top: 0.35rem; bottom: 0.35rem; left: 0.35rem;
    width: calc(50% - 0.35rem); border-radius: 9px; background: white;
    box-shadow: 0 2px 8px rgba(30,45,80,0.12); transition: left 0.3s cubic-bezier(.4,0,.2,1), width 0.3s cubic-bezier(.4,0,.2,1);
}
body.dark-mode .auth-tabs-modern { background: rgba(255,255,255,0.04); }
body.dark-mode .auth-tab-slider { background: rgba(129,140,248,0.16); border: 1px solid rgba(129,140,248,0.3); box-shadow: none; }
body.dark-mode .auth-tab.active { color: #C7D2FE; }

.auth-form { display: none; animation: fadeIn 0.3s ease; }
.auth-form.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.form-group.modern label { color: var(--clr-text-main); font-weight: 600; margin-bottom: 0.75rem; }
.form-group.modern input { background-color: white; border: 1.5px solid #E2E5EA; border-radius: 10px; padding: 1rem 1.25rem; font-size: 1rem; transition: all 0.2s; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
.form-group.modern input:hover { border-color: #CBD3DE; }
.form-group.modern input:focus { border-color: var(--clr-primary); box-shadow: 0 0 0 4px rgba(108,142,191,0.15); }
.auth-card-modern .btn-primary {
    padding: 1rem; font-size: 1.1rem; margin-top: 1rem; border-radius: 10px;
    background: linear-gradient(135deg, var(--clr-primary) 0%, #4a6fa5 100%);
    box-shadow: 0 8px 20px -6px rgba(74,111,165,0.5); transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.auth-card-modern .btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 24px -6px rgba(74,111,165,0.6); }
.terms-text { text-align: center; font-size: 0.85rem; color: var(--clr-text-light); margin-top: 1.5rem; line-height: 1.5; }
.error-message { color: #e53e3e; font-size: 0.9rem; margin-top: 1.5rem; text-align: center; font-weight: 500; background: #fff5f5; padding: 0.75rem; border-radius: 6px; display: none; }
.error-message:not(:empty) { display: block; }
body.dark-mode .error-message { color: #fca5a5; background: rgba(229,62,62,0.12); }

/* Dashboard Professional Layout */
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2rem; max-width: 1100px; margin: 0 auto; min-width: 0; }
.dashboard-card { background: var(--card-bg, white); border-radius: 16px; padding: 2rem; box-shadow: var(--shadow-sm); border: 1px solid rgba(0,0,0,0.05); min-width: 0; overflow-x: auto; }
#dynamic-sections, .featured-carousel-container { min-width: 0; }
.dashboard-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; border-bottom: 1px solid rgba(0,0,0,0.05); padding-bottom: 1rem; }
.dashboard-card-header h3 { margin: 0; font-size: 1.25rem; }
.dashboard-card-header p { margin: 0; font-size: 0.9rem; color: var(--clr-text-light); }

/* Compact Forms */
.compact-form .form-group { margin-bottom: 1rem; }
.compact-form .form-group label { font-size: 0.85rem; margin-bottom: 0.4rem; color: var(--clr-text-light); }
.compact-form .form-group input, .compact-form .form-group textarea { padding: 0.75rem 1rem; font-size: 0.95rem; border-radius: 8px; }
.compact-form .form-group textarea { resize: vertical; min-height: 80px; }
.char-counter { display: block; text-align: right; font-size: 0.72rem; color: var(--clr-text-light); margin-top: 3px; }
.char-counter.char-counter-near-limit { color: #DAA520; }
.char-counter.char-counter-at-limit { color: #e53e3e; font-weight: 600; }
.compact-form .btn-primary { padding: 0.75rem 1.5rem; font-size: 1rem; margin-top: 0.5rem; }

@media (max-width: 900px) {
    .split-layout { flex-direction: column; height: auto; min-height: 100vh; overflow-y: auto; }
    .split-brand { display: none; } /* Hide brand side on mobile for pure form focus */
    .mobile-logo { display: block; }
    .auth-body { overflow-y: auto; }
    .split-form-container { padding: 3rem 1.5rem; align-items: flex-start; }
}

/* Landing Page (Empty State) Styles */
.landing-hero { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 2rem; background: radial-gradient(circle at 50% -20%, rgba(108,142,191,0.1) 0%, rgba(255,255,255,0) 70%); }
.landing-badge { display: inline-block; padding: 0.5rem 1rem; background: var(--clr-badge-blue); color: var(--clr-badge-blue-text); border-radius: 20px; font-weight: 600; font-size: 0.9rem; margin-bottom: 1.5rem; letter-spacing: 0.5px; }
.landing-hero h1 { font-size: clamp(2.5rem, 6vw, 4.5rem); max-width: 800px; margin-bottom: 1.5rem; line-height: 1.1; }
.landing-hero p { font-size: clamp(1.1rem, 2vw, 1.3rem); color: var(--clr-text-light); max-width: 600px; margin: 0 auto 3rem; line-height: 1.6; }
.landing-hero .btn-primary { font-size: 1.2rem; padding: 1.2rem 2.5rem; border-radius: 12px; }

/* Dynamic Category Styling */
.category-section { padding: var(--section-padding); border-bottom: 1px solid rgba(0,0,0,0.05); }
.category-section:nth-child(even) { background-color: var(--clr-bg-alt); }
/* Password Toggle CSS */
.password-wrapper { position: relative; display: flex; align-items: center; }
.password-wrapper input { width: 100%; padding-right: 2.5rem !important; }
.password-toggle { position: absolute; right: 10px; background: none; border: none; cursor: pointer; color: var(--clr-text-light); display: flex; align-items: center; justify-content: center; padding: 5px; transition: color 0.2s; }
.password-toggle:hover { color: var(--clr-text-main); }
.eye-icon { width: 20px; height: 20px; }

/* ===== Upgrade to Premium Wizard ===== */
.wizard-steps-dots { display: flex; justify-content: center; gap: 8px; margin-bottom: 1.5rem; }
.step-dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(108,142,191,0.2); transition: all 0.25s ease; }
.step-dot.active { background: var(--clr-primary); width: 22px; border-radius: 4px; }
.wizard-sub { color: var(--clr-text-light); font-size: 0.9rem; text-align: center; margin-bottom: 1.25rem; line-height: 1.5; }
.wizard-back { background: none; border: none; color: var(--clr-text-light); font-size: 0.85rem; cursor: pointer; padding: 0; margin-bottom: 0.75rem; }
.wizard-back:hover { color: var(--clr-primary); }

.plan-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 1.25rem; }
.plan-card { position: relative; cursor: pointer; }
.plan-card input { position: absolute; opacity: 0; }
.plan-card-body { border: 1.5px solid #E2E5EA; border-radius: 12px; padding: 1rem 0.75rem; text-align: center; transition: all 0.15s ease; }
.plan-card:has(input:checked) .plan-card-body { border-color: var(--clr-primary); background: rgba(108,142,191,0.06); box-shadow: 0 0 0 3px rgba(108,142,191,0.1); }
.plan-name { font-size: 0.9rem; font-weight: 600; margin-bottom: 6px; }
.plan-badge { display: inline-block; font-size: 0.65rem; font-weight: 700; color: #DAA520; background: rgba(218,165,32,0.12); padding: 1px 6px; border-radius: 6px; margin-left: 4px; vertical-align: middle; }
.plan-price { font-size: 1.3rem; font-weight: 700; color: var(--clr-primary); }
.plan-price small { font-size: 0.75rem; font-weight: 500; color: var(--clr-text-light); }

.wizard-instructions { margin: 0 0 1rem; padding-left: 1.2rem; font-size: 0.88rem; color: var(--clr-text-light); }
.wizard-instructions li { margin-bottom: 4px; }
.cliq-alias-box {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    background: rgba(108,142,191,0.07); border: 1.5px dashed var(--clr-primary); border-radius: 10px;
    padding: 0.85rem 1rem; margin-bottom: 1rem;
}
#wizard-cliq-alias { font-weight: 700; font-size: 1rem; color: var(--clr-text-main); word-break: break-all; }
#wizard-copy-alias { flex: none; background: var(--clr-primary); color: white; border: none; border-radius: 8px; padding: 6px 12px; font-size: 0.8rem; cursor: pointer; }
#wizard-copy-alias:hover { background: var(--clr-primary-hover); }
.wizard-note { font-size: 0.78rem; color: var(--clr-text-light); background: rgba(218,165,32,0.08); border-radius: 8px; padding: 0.6rem 0.75rem; margin-bottom: 1.25rem; line-height: 1.5; }
.wizard-done-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }

body.dark-mode .plan-card-body { border-color: rgba(255,255,255,0.1); }
body.dark-mode .plan-card:has(input:checked) .plan-card-body { background: rgba(129,140,248,0.1); box-shadow: 0 0 0 3px rgba(129,140,248,0.15); }
body.dark-mode .cliq-alias-box { background: rgba(129,140,248,0.08); }

/* Dark Mode Global Overrides */
body.dark-mode {
    --clr-bg: #111827; /* Softer dark gray-blue */
    --clr-bg-alt: #1f2937;
    --clr-text-main: #f9fafb;
    --clr-text-light: #9ca3af;
    --clr-card-bg: rgba(31, 41, 55, 0.7);
    --clr-border: rgba(255, 255, 255, 0.1);
    --clr-primary: #818cf8;
    --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
    background-color: var(--clr-bg);
    color: var(--clr-text-main);
}
body.dark-mode .card, body.dark-mode .contact-form, body.dark-mode .modal, body.dark-mode .dashboard-card { 
    background-color: var(--clr-card-bg); 
    border-color: var(--clr-border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
body.dark-mode .dashboard-card-header { border-bottom-color: var(--clr-border); }
body.dark-mode .form-group input, body.dark-mode .form-group textarea, body.dark-mode .file-input { 
    background-color: rgba(255, 255, 255, 0.03); 
    border: 1px solid rgba(255, 255, 255, 0.1); 
    color: var(--clr-text-main); 
    box-shadow: none;
    border-radius: 8px;
}
body.dark-mode .form-group input:focus, body.dark-mode .form-group textarea:focus {
    border-color: var(--clr-primary);
    box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.2);
    background-color: rgba(255, 255, 255, 0.08);
}
body.dark-mode .navbar.scrolled { 
    background: rgba(15, 23, 42, 0.85); 
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
body.dark-mode .split-form-container {
    background-color: var(--clr-bg);
}
/* Login Page Premium Dark Mode — the beacon glows warm against a night sky
   instead of the daytime cream wash, echoing an actual lighthouse at night */
body.dark-mode .split-brand {
    background:
        radial-gradient(circle at 15% 85%, rgba(129,140,248,0.18) 0%, rgba(129,140,248,0) 45%),
        linear-gradient(160deg, #1e2a4a 0%, #111827 55%, #0a0e1a 100%);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}
body.dark-mode .beacon-rays circle,
body.dark-mode .beacon-rays g { stroke: #FBD38D; }
body.dark-mode .beacon-rays circle { fill: #FBD38D; }
body.dark-mode .beacon-rays #beaconGlow stop:first-child { stop-color: #FBD38D; stop-opacity: 0.28; }
body.dark-mode .auth-tab {
    color: var(--clr-text-light);
}
body.dark-mode .auth-tab.active {
    color: var(--clr-text-main);
}
body.dark-mode .btn-primary {
    background-color: var(--clr-primary);
    color: var(--clr-primary-text, white);
    border: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}
body.dark-mode .btn-primary:hover {
    transform: translateY(-2px);
    background-color: var(--clr-primary-hover);
    box-shadow: 0 8px 25px rgba(0,0,0,0.4);
}
/* Landing Page Premium Dark Mode */
body.dark-mode .landing-hero {
    background: radial-gradient(circle at 50% -10%, rgba(99, 102, 241, 0.15) 0%, rgba(9, 9, 11, 0) 60%);
}
body.dark-mode .landing-badge {
    background: rgba(129, 140, 248, 0.1);
    color: #a5b4fc;
    border: 1px solid rgba(129, 140, 248, 0.2);
}

/* Dark Mode Toggle Button */
.theme-toggle-btn { background: none; border: none; color: var(--clr-text-main); cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 8px; border-radius: 50%; transition: background 0.2s; }
.theme-toggle-btn:hover { background: rgba(0,0,0,0.05); }
body.dark-mode .theme-toggle-btn:hover { background: rgba(255,255,255,0.1); }
.theme-toggle-btn svg { width: 20px; height: 20px; }
input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear,
input[type="password"]::-webkit-reveal {
    display: none !important;
}

/* =========================================
   PREMIUM INBOX SPLIT-PANE UI
   ========================================= */
.premium-shadow { box-shadow: 0 10px 40px -10px rgba(0,0,0,0.08); }
body.dark-mode .premium-shadow { box-shadow: 0 10px 40px -10px rgba(0,0,0,0.5); }

.inbox-layout { 
    display: flex; height: 75vh; border-radius: 16px; overflow: hidden; 
    background: var(--clr-bg); box-shadow: 0 4px 20px rgba(0,0,0,0.04); border: 1px solid rgba(148, 163, 184, 0.1); 
}
body.dark-mode .inbox-layout { border: 1px solid rgba(255, 255, 255, 0.05); box-shadow: 0 10px 40px -10px rgba(0,0,0,0.5); }

.inbox-sidebar { 
    width: 320px; border-right: 1px solid rgba(148, 163, 184, 0.1); 
    background: #fdfdfd; display: flex; flex-direction: column; 
    box-shadow: 2px 0 10px rgba(0,0,0,0.01); z-index: 5;
}
body.dark-mode .inbox-sidebar { background: #0f172a; border-color: rgba(255, 255, 255, 0.05); }

.inbox-sidebar-header { 
    padding: 1.2rem; border-bottom: 1px solid rgba(148, 163, 184, 0.1); 
    background: var(--clr-bg); display: flex; justify-content: space-between; align-items: center; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.01); z-index: 2;
}
body.dark-mode .inbox-sidebar-header { border-color: rgba(255, 255, 255, 0.05); }

.icon-btn {
    background: transparent; border: none; color: var(--clr-text-light); 
    display: flex; align-items: center; justify-content: center; 
    width: 36px; height: 36px; border-radius: 50%; cursor: pointer; transition: all 0.2s;
}
.icon-btn:hover { background: rgba(148, 163, 184, 0.15); color: var(--clr-text-main); }
body.dark-mode .icon-btn:hover { background: rgba(255, 255, 255, 0.1); }

.inbox-contacts { flex: 1; overflow-y: auto; padding-bottom: 1rem; }
/* Custom Scrollbar for Contacts & Messages */
.inbox-contacts::-webkit-scrollbar, .inbox-messages::-webkit-scrollbar { width: 6px; }
.inbox-contacts::-webkit-scrollbar-track, .inbox-messages::-webkit-scrollbar-track { background: transparent; }
.inbox-contacts::-webkit-scrollbar-thumb, .inbox-messages::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.3); border-radius: 10px; }
body.dark-mode .inbox-contacts::-webkit-scrollbar-thumb, body.dark-mode .inbox-messages::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); }

.contact-item { 
    padding: 1rem 1.2rem; border-bottom: 1px solid rgba(148, 163, 184, 0.1); 
    cursor: pointer; transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); display: flex; align-items: center; gap: 12px;
}
body.dark-mode .contact-item { border-color: rgba(255, 255, 255, 0.03); }
.contact-item:hover { background: rgba(148, 163, 184, 0.05); transform: translateX(4px); }
.contact-item.active { background: rgba(108, 142, 191, 0.08); position: relative; transform: translateX(0); }
.contact-item.active::before {
    content: ''; position: absolute; left: 0; top: 10%; height: 80%; width: 4px;
    background: var(--clr-primary); border-radius: 0 4px 4px 0;
    box-shadow: 0 0 10px var(--clr-primary);
}

.chat-avatar {
    width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg, var(--clr-primary), #818cf8);
    display: flex; align-items: center; justify-content: center; color: white; font-weight: 600; font-size: 1.1rem;
    flex-shrink: 0; box-shadow: 0 4px 10px rgba(108, 142, 191, 0.3);
}
.chat-avatar.large { width: 48px; height: 48px; font-size: 1.3rem; }

.contact-info { flex: 1; overflow: hidden; }
.contact-name { font-weight: 600; color: var(--clr-text-main); font-size: 0.95rem; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-email { font-size: 0.8rem; color: var(--clr-text-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.inbox-main { flex: 1; display: flex; flex-direction: column; background: var(--clr-bg); min-width: 0; overflow: hidden; }
.inbox-main-header { 
    padding: 1rem 1.5rem; border-bottom: 1px solid rgba(148, 163, 184, 0.2); 
    display: flex; justify-content: space-between; align-items: center; background: var(--clr-bg);
}
body.dark-mode .inbox-main-header { border-color: rgba(255, 255, 255, 0.05); }

.inbox-messages { flex: 1; overflow-y: auto; padding: 1.5rem; padding-bottom: 3rem; display: flex; flex-direction: column; gap: 1rem; 
background-color: #f8fafc; background-image: radial-gradient(rgba(148, 163, 184, 0.15) 1px, transparent 1px); background-size: 24px 24px; box-shadow: inset 0 4px 15px rgba(0,0,0,0.02); }
body.dark-mode .inbox-messages { background-color: #0f172a; background-image: radial-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px); box-shadow: inset 0 4px 20px rgba(0,0,0,0.1); }

@keyframes slideInUpMsg {
    from { opacity: 0; transform: translateY(15px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.chat-bubble { 
    background: #ffffff; padding: 1rem 1.2rem; border-radius: 20px 20px 20px 4px; 
    max-width: 75%; box-shadow: 0 4px 15px rgba(0,0,0,0.05), 0 1px 3px rgba(0,0,0,0.02); color: #334155; 
    position: relative; align-self: flex-start;
    animation: slideInUpMsg 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.1) forwards;
    transform-origin: bottom left;
}
.chat-bubble.outgoing {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--clr-primary), #6366f1);
    color: white;
    border-radius: 20px 20px 4px 20px;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
    transform-origin: bottom right;
}
.chat-bubble.outgoing .chat-meta { color: rgba(255, 255, 255, 0.8); }
.chat-bubble.outgoing .chat-meta button { color: rgba(255, 255, 255, 0.9) !important; }
.chat-bubble.outgoing .chat-meta button:hover { color: #fff !important; }

body.dark-mode .chat-bubble { background: #1e293b; color: #f8fafc; box-shadow: 0 4px 15px rgba(0,0,0,0.2); }
body.dark-mode .chat-bubble.outgoing { background-color: var(--clr-primary); color: var(--clr-primary-text, white); }
.chat-meta { font-size: 0.75rem; color: var(--clr-text-light); margin-bottom: 0.5rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.chat-text { font-size: 0.95rem; line-height: 1.6; margin: 0; white-space: pre-wrap; }

.inbox-reply-box { 
    padding: 1rem 1.5rem; width: 100%; box-sizing: border-box; max-width: 100%; border-top: 1px solid rgba(148, 163, 184, 0.2); 
    background: var(--clr-bg); display: flex; gap: 12px; align-items: center; 
}
body.dark-mode .inbox-reply-box { border-color: rgba(255, 255, 255, 0.05); }

.reply-input { 
    flex: 1; background: #f1f5f9; border: 1px solid transparent; border-radius: 50px; 
    padding: 0.8rem 1.5rem; font-family: var(--font-main); font-size: 0.95rem; 
    color: var(--clr-text-main); outline: none; transition: all 0.2s;
}
body.dark-mode .reply-input { background: #334155; color: #f8fafc; }
.reply-input:focus { background: var(--clr-bg); border-color: var(--clr-primary); box-shadow: 0 0 0 4px rgba(108, 142, 191, 0.15); }

.send-btn {
    flex-shrink: 0; background: var(--clr-primary); color: white; border: none; width: 44px; height: 44px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.2s; box-shadow: 0 4px 12px rgba(108, 142, 191, 0.4);
}
.send-btn:hover { background: var(--clr-primary-hover); transform: scale(1.05); }
.send-btn svg { transform: translateX(-1px) translateY(1px); } /* optical alignment */

.empty-state-content { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--clr-text-light); }
.empty-icon-wrapper { 
    width: 80px; height: 80px; border-radius: 50%; background: rgba(148, 163, 184, 0.1);
    display: flex; align-items: center; justify-content: center; margin-bottom: 1.5rem; color: var(--clr-text-light);
}
.empty-state-content h3 { font-size: 1.4rem; color: var(--clr-text-main); margin-bottom: 0.5rem; }
.empty-state-content p { font-size: 0.95rem; max-width: 250px; }



/* WhatsApp Mobile Inbox */
@media (max-width: 768px) { 
    .inbox-layout { height: calc(100vh - 180px); min-height: 0; overflow: hidden; display: flex; flex-direction: column; } 
    
    /* Default state (Contact list) */
    .inbox-sidebar { width: 100%; max-height: none; height: 100%; display: flex; border-right: none; } 
    .inbox-main { display: none !important; } 
    #inbox-empty-state { display: none !important; } 
    
    /* Active Chat state */
    .inbox-layout.mobile-chat-active .inbox-sidebar { display: none !important; } 
    .inbox-layout.mobile-chat-active .inbox-main { display: flex !important; height: 100%; flex-direction: column; } 
    .inbox-messages { flex: 1; overflow-y: auto; padding: 1rem; padding-bottom: 2.5rem; }
    .inbox-reply-box { flex-shrink: 0; padding: 0.8rem 1rem 1.5rem 1rem; width: 100%; box-sizing: border-box; max-width: 100%; }
    .chat-bubble { max-width: 90%; }
    
    /* Back Button */
    .close-chat-btn svg { display: none; } 
    .close-chat-btn::before { content: "\2190"; font-size: 1.5rem; font-weight: bold; } 
    
    /* Hero adjustments */
    .hero-text h1 { font-size: 2.2rem !important; } 
}

/* Chat Attachments UI */
.attach-btn { flex-shrink: 0; background: none; border: none; cursor: pointer; padding: 10px; color: var(--clr-text-light); transition: all 0.2s; } .attach-btn:hover { color: var(--clr-primary); } .upload-preview { display: none; padding: 8px 12px; background: rgba(108, 142, 191, 0.1); border-radius: 8px; margin-bottom: 8px; align-items: center; justify-content: space-between; font-size: 0.85rem; color: var(--clr-primary); font-weight: 500; } .upload-preview.active { display: flex; } .remove-upload-btn { background: none; border: none; color: #ef4444; cursor: pointer; } .chat-attachment { margin-top: 8px; padding: 12px; border-radius: 12px; background: rgba(0,0,0,0.04); display: flex; align-items: center; gap: 12px; text-decoration: none !important; color: inherit; transition: background 0.2s; } .chat-attachment:hover { background: rgba(0,0,0,0.08); } body.dark-mode .chat-attachment { background: rgba(255,255,255,0.05); } body.dark-mode .chat-attachment:hover { background: rgba(255,255,255,0.1); } .chat-bubble.outgoing .chat-attachment { background: rgba(255,255,255,0.15); } .chat-bubble.outgoing .chat-attachment:hover { background: rgba(255,255,255,0.25); } .attach-icon { background: white; width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--clr-primary); flex-shrink: 0; box-shadow: 0 2px 5px rgba(0,0,0,0.1); } .attach-info { flex: 1; overflow: hidden; } .attach-name { font-weight: 600; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .attach-expiry { font-size: 0.7rem; color: #f59e0b; margin-top: 2px; } .chat-bubble.outgoing .attach-icon { color: #6366f1; } .chat-bubble.outgoing .attach-expiry { color: #fde68a; } .image-attachment { border-radius: 12px; max-width: 100%; max-height: 200px; object-fit: cover; margin-top: 8px; cursor: pointer; border: 1px solid rgba(0,0,0,0.1); }


/* Skeleton Loading */
.skeleton-card { background: var(--clr-bg); border-radius: 20px; overflow: hidden; box-shadow: 0 4px 15px rgba(0,0,0,0.03); display: flex; flex-direction: column; gap: 1rem; padding: 1.5rem; }
.skeleton-img { width: 100%; height: 250px; background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%); background-size: 200% 100%; animation: skeleton-loading 1.5s infinite; border-radius: 12px; }
.skeleton-text { height: 20px; background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%); background-size: 200% 100%; animation: skeleton-loading 1.5s infinite; border-radius: 4px; width: 80%; }
.skeleton-text.short { width: 50%; }
body.dark-mode .skeleton-img, body.dark-mode .skeleton-text { background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%); background-size: 200% 100%; }
@keyframes skeleton-loading { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* FORCED MOBILE FIXES */
@media (max-width: 768px) {
    .dashboard-tabs { flex-wrap: wrap; }
    .inbox-layout {
        width: 100vw !important;
        max-width: 100vw !important;
        margin-left: -1.25rem !important; /* Counteract container padding */
        margin-right: -1.25rem !important;
        border-radius: 0 !important; /* Edge-to-edge on mobile */
        border-left: none !important;
        border-right: none !important;
    }
    .inbox-main {
        min-width: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow: hidden !important;
    }
    .inbox-reply-box {
        width: 100% !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
        min-width: 0 !important;
        overflow: hidden !important;
        padding-right: 1.25rem !important; /* Restore safe area padding */
        padding-left: 1.25rem !important;
    }
    .reply-input {
        min-width: 0 !important;
        width: 100% !important;
    }
    .chat-bubble {
        word-break: break-word !important;
        overflow-wrap: break-word !important;
        max-width: 85% !important;
    }
    .inbox-main-header > div:first-child {
        min-width: 0 !important;
    }
    #chat-header-email {
        word-break: break-all !important;
        white-space: normal !important;
    }
    #chat-header-name {
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
}

/* SAFE OVERFLOW FIXES */
.inbox-layout { max-width: 100%; width: 100%; overflow: hidden; }
.inbox-main { min-width: 0; max-width: 100%; overflow: hidden; }
.inbox-reply-box { min-width: 0; max-width: 100%; width: 100%; }
.reply-input { min-width: 0; }
.chat-bubble { word-break: break-word; overflow-wrap: break-word; }
.inbox-main-header > div { min-width: 0; }
#chat-header-email { word-break: break-all; overflow-wrap: break-word; display: block; }
#chat-header-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

/* DARK MODE CHAT AESTHETICS */
body.dark-mode #inbox-search-input {
    background: rgba(255,255,255,0.05) !important;
    color: #e2e8f0 !important;
    border-color: rgba(255,255,255,0.1) !important;
}
body.dark-mode #inbox-search-input::placeholder {
    color: #94a3b8 !important;
}
body.dark-mode .inbox-messages {
    background-color: #0b1120 !important; /* Slightly darker depth */
    background-image: radial-gradient(rgba(255,255,255,0.04) 1px, transparent 1px) !important;
    background-size: 24px 24px !important;
}
body.dark-mode .inbox-sidebar,
body.dark-mode .inbox-reply-box,
body.dark-mode .inbox-main-header {
    background-color: #111827 !important;
}
body.dark-mode .inbox-reply-box {
    border-top: 1px solid rgba(255,255,255,0.05) !important;
}
body.dark-mode .inbox-main-header {
    border-bottom: 1px solid rgba(255,255,255,0.05) !important;
}

/* PORTFOLIO FILTER STRATEGY */
.portfolio-filter-bar {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 1rem 0;
    margin-bottom: 2rem;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}
.portfolio-filter-bar::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}
.filter-tab {
    padding: 0.5rem 1.2rem;
    border-radius: 30px;
    background: var(--clr-bg-alt);
    border: 1px solid rgba(148, 163, 184, 0.3);
    color: var(--clr-text-light);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.3s ease;
}
.filter-tab:hover {
    background: rgba(148, 163, 184, 0.1);
    color: var(--clr-text-main);
}
.filter-tab.active {
    background: var(--clr-primary);
    color: var(--clr-primary-text, white);
    border-color: var(--clr-primary);
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
}
body.dark-mode .filter-tab {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.1);
}
body.dark-mode .filter-tab.active {
    background: var(--clr-primary);
    border-color: var(--clr-primary);
}

/* Sub-category tabs grouped under their main category — mirrors the
   dropdown grouping on the public portfolio page, so what the doctor sees
   while managing cases matches what a visitor sees. */
.portfolio-filter-groups {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    margin-top: -1rem;
    margin-bottom: 2rem;
}
.filter-main-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.filter-main-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--clr-text-light);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
    min-width: 90px;
}
.filter-main-tabs {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.portfolio-item {
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.hidden-item {
    display: none !important;
}
.category-badge {
    position: absolute;
    top: -12px;
    right: 12px;
    background: var(--clr-badge-blue);
    color: var(--clr-badge-blue-text);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* --- BEFORE & AFTER SLIDER --- */
.before-after-container {
    position: relative;
    width: 100%;
    height: 250px;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 1rem;
}
.image-before, .image-after {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}
.image-after {
    width: 100%;
}
.image-before {
    width: 50%; /* Initial split */
    border-right: 2px solid white;
    z-index: 2;
}
.ba-slider {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: ew-resize;
    z-index: 4;
}
.slider-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    z-index: 3;
    pointer-events: none; /* Let range input handle events */
}
.slider-button::before, .slider-button::after {
    content: '';
    position: absolute;
    border: solid var(--clr-primary);
    border-width: 0 2px 2px 0;
    display: inline-block;
    padding: 3px;
}
.slider-button::before {
    transform: rotate(135deg);
    left: 10px;
}
.slider-button::after {
    transform: rotate(-45deg);
    right: 10px;
}

/* --- FEATURED CAROUSEL --- */
.featured-carousel-container {
    background: var(--clr-bg-alt);
    padding: 1.5rem;
    border-radius: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}
body.dark-mode .featured-carousel-container {
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.05);
}
.featured-carousel {
    display: flex;
    gap: 1.5rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
    scrollbar-width: none;
}
.featured-carousel::-webkit-scrollbar {
    display: none;
}
.featured-strip-card { min-width: 280px; max-width: 350px; flex-shrink: 0; }
@media (max-width: 768px) {
    /* Size each featured card off the viewport itself so it always sits
       fully inside the screen with a small peek of the next card, instead
       of a fixed px width that can be wider than narrow phones. */
    .featured-strip-card { min-width: min(78vw, 300px); max-width: min(78vw, 300px); }
    .featured-carousel-container { padding: 1rem; }
    .featured-carousel { gap: 1rem; }
    .gallery-nav { padding: 0 0.35rem; }
    .nav-arrow { width: 26px; height: 26px; font-size: 0.8rem; }
}
.featured-card {
    min-width: 320px;
    border-radius: 16px;
    overflow: hidden;
    background: var(--clr-bg);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    flex-shrink: 0;
}
.featured-image {
    width: 100%;
    height: 180px;
    background-size: cover;
    background-position: center;
}
.featured-content {
    padding: 1.2rem;
}
.featured-content h4 {
    margin: 0.5rem 0;
    font-size: 1.1rem;
    color: var(--clr-text-main);
}
