/* =========================================
   FCAPT PORTAL - MODERN DASHBOARD THEME
   ========================================= */
   :root {
    --primary: #0f766e;
    --primary-light: #ccfbf1;
    --primary-dark: #0d5c56;
    --accent: #f59e0b;
    --bg-body: #f3f4f6;
    --bg-card: #ffffff;
    --text-main: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --danger: #ef4444;
    --success: #10b981;
    --sidebar-width: 260px;
    --header-height: 64px;
    --radius: 12px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter', system-ui, sans-serif; background: var(--bg-body); color: var(--text-main); line-height: 1.6; min-height: 100vh; }
a { text-decoration: none; color: inherit; transition: 0.2s; }

/* --- Dashboard Layout --- */
.dashboard-wrapper { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width); background: #1e293b; color: white;
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 100;
    display: flex; flex-direction: column; transition: transform 0.3s ease;
}
.sidebar-brand {
    height: var(--header-height); display: flex; align-items: center; gap: 0.75rem;
    padding: 0 1.5rem; border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand span:first-child { font-size: 1.5rem; }
.sidebar-brand strong { font-size: 1rem; letter-spacing: -0.3px; }

.sidebar-nav { flex: 1; padding: 1rem 0.75rem; overflow-y: auto; }
.nav-item {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.7rem 1rem; border-radius: 8px; color: rgba(255,255,255,0.6);
    font-weight: 500; font-size: 0.9rem; margin-bottom: 0.25rem;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: white; }
.nav-item.active { background: var(--primary); color: white; box-shadow: 0 2px 8px rgba(15,118,110,0.4); }
.nav-item .icon { font-size: 1.1rem; width: 24px; text-align: center; }

.sidebar-footer { padding: 1rem 1.5rem; border-top: 1px solid rgba(255,255,255,0.08); }
.user-mini { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%; background: var(--primary);
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem;
}
.user-info p:first-child { font-size: 0.85rem; font-weight: 600; color: white; }
.user-info p:last-child { font-size: 0.7rem; color: rgba(255,255,255,0.5); }
.logout-btn {
    display: block; width: 100%; padding: 0.5rem; border-radius: 6px;
    background: rgba(239,68,68,0.15); color: #fca5a5; text-align: center;
    font-size: 0.8rem; font-weight: 600; border: none; cursor: pointer;
}
.logout-btn:hover { background: rgba(239,68,68,0.25); }

.main-area { flex: 1; margin-left: var(--sidebar-width); display: flex; flex-direction: column; }
.top-bar {
    height: var(--header-height); background: var(--bg-card); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; padding: 0 2rem;
    position: sticky; top: 0; z-index: 50;
}
.top-bar h1 { font-size: 1.2rem; font-weight: 700; color: var(--text-main); }
.mobile-menu-btn { display: none; background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-main); }

.content-area { padding: 2rem; max-width: 1400px; width: 100%; margin: 0 auto; }

/* --- Cards & Components --- */
.card { background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow-sm); overflow: hidden; }
.card-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; }
.card-header h2 { font-size: 1.05rem; font-weight: 700; }
.card-body { padding: 1.5rem; }

.btn {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.55rem 1.2rem; border-radius: 8px; font-weight: 600;
    font-size: 0.85rem; border: none; cursor: pointer; transition: all 0.2s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-accent { background: var(--accent); color: #1e293b; }
.btn-accent:hover { background: #d97706; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text-main); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.78rem; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text-main); margin-bottom: 0.3rem; }
.form-control {
    width: 100%; padding: 0.6rem 0.9rem; border: 1.5px solid var(--border); border-radius: 8px;
    font-size: 0.9rem; font-family: inherit; transition: 0.2s; background: white; color: var(--text-main);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,118,110,0.1); }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.9rem center; padding-right: 2.5rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.alert { padding: 0.8rem 1.2rem; border-radius: 8px; font-size: 0.88rem; font-weight: 500; margin-bottom: 1.5rem; display: flex; align-items: center; gap: 0.5rem; }
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th { text-align: left; padding: 0.75rem 1rem; background: #f9fafb; font-weight: 700; color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); }
td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); color: var(--text-main); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f9fafb; }

/* =========================================
   CHAT INTERFACE
   ========================================= */
.chat-container { display: flex; flex-direction: column; height: calc(100vh - var(--header-height) - 4rem); min-height: 500px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; background: #f9fafb; }

.msg-row { display: flex; gap: 0.75rem; max-width: 75%; animation: msgIn 0.3s ease-out; }
.msg-row.received { align-self: flex-start; }
.msg-row.sent { align-self: flex-end; flex-direction: row-reverse; }
.msg-row.broadcast { align-self: center; max-width: 85%; }

.msg-avatar {
    width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 700; color: white;
}
.msg-row.received .msg-avatar { background: var(--primary); }
.msg-row.sent .msg-avatar { background: var(--accent); color: #1e293b; }
.msg-row.broadcast .msg-avatar { background: #6366f1; width: 40px; height: 40px; font-size: 1rem; }

.msg-bubble {
    padding: 0.8rem 1rem; border-radius: 16px; font-size: 0.9rem; line-height: 1.5;
    position: relative; word-break: break-word;
}
.msg-row.received .msg-bubble { background: white; border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg-row.sent .msg-bubble { background: var(--primary); color: white; border-bottom-right-radius: 4px; }
.msg-row.broadcast .msg-bubble {
    background: linear-gradient(135deg, #eef2ff, #e0e7ff); border: 1px solid #c7d2fe;
    border-radius: 12px; text-align: center;
}

.msg-meta { font-size: 0.7rem; margin-top: 0.3rem; opacity: 0.7; }
.msg-row.sent .msg-meta { text-align: right; color: rgba(255,255,255,0.7); }
.msg-row.received .msg-meta { color: var(--text-muted); }
.msg-row.broadcast .msg-meta { text-align: center; color: #4338ca; font-weight: 600; }

.broadcast-badge {
    display: inline-block; background: #6366f1; color: white; font-size: 0.65rem;
    padding: 0.15rem 0.5rem; border-radius: 50px; margin-bottom: 0.4rem; font-weight: 700; letter-spacing: 0.5px;
}

.msg-file {
    display: inline-flex; align-items: center; gap: 0.5rem; margin-top: 0.5rem;
    padding: 0.4rem 0.8rem; border-radius: 8px; font-size: 0.8rem; font-weight: 600;
    text-decoration: none; transition: 0.2s;
}
.msg-row.received .msg-file { background: var(--primary-light); color: var(--primary-dark); }
.msg-row.received .msg-file:hover { background: var(--primary); color: white; }
.msg-row.sent .msg-file { background: rgba(255,255,255,0.2); color: white; }
.msg-row.sent .msg-file:hover { background: rgba(255,255,255,0.35); }
.msg-row.broadcast .msg-file { background: white; color: #4338ca; border: 1px solid #c7d2fe; }

.chat-input-area {
    padding: 1rem 1.5rem; background: white; border-top: 1px solid var(--border);
    display: flex; gap: 0.75rem; align-items: flex-end; flex-wrap: wrap;
}
.chat-input-area .form-control { margin-bottom: 0; }
.chat-input-area textarea { min-height: 44px; max-height: 120px; resize: none; }
.file-input-wrapper { position: relative; }
.file-input-wrapper input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-input-label {
    display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.55rem 1rem;
    border: 1.5px dashed var(--border); border-radius: 8px; font-size: 0.82rem;
    color: var(--text-muted); cursor: pointer; transition: 0.2s; white-space: nowrap;
}
.file-input-label:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.file-name-display { font-size: 0.75rem; color: var(--primary); font-weight: 600; margin-top: 0.2rem; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.reply-form { margin-top: 0.5rem; padding-top: 0.5rem; border-top: 1px dashed var(--border); display: none; }
.reply-form.active { display: block; }
.reply-form .form-control { font-size: 0.82rem; padding: 0.5rem 0.7rem; }

@keyframes msgIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Homepage Specific Overrides */
.home-page { background: #ffffff; }
.main-nav { position: fixed; top: 0; left: 0; right: 0; z-index: 1000; background: rgba(255,255,255,0.95); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.nav-container { max-width: 1200px; margin: 0 auto; padding: 0 2rem; display: flex; justify-content: space-between; align-items: center; height: 72px; }
.brand { display: flex; align-items: center; gap: 0.75rem; text-decoration: none; color: var(--text-main); }
.brand-icon { font-size: 1.8rem; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-weight: 800; font-size: 1.1rem; color: var(--primary); }
.brand-sub { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.main-nav .nav-links { display: flex; align-items: center; gap: 0.5rem; list-style: none; }
.main-nav .nav-links a:not(.nav-btn) { padding: 0.5rem 0.9rem; border-radius: 8px; font-weight: 500; font-size: 0.9rem; color: var(--text-main); }
.main-nav .nav-links a:not(.nav-btn):hover { background: rgba(15,118,110,0.08); color: var(--primary); }
.nav-btn { padding: 0.5rem 1.2rem !important; border-radius: 50px !important; font-weight: 600 !important; font-size: 0.85rem !important; margin-left: 0.3rem; }
.nav-btn-outline { border: 1.5px solid var(--primary) !important; color: var(--primary) !important; background: transparent !important; }
.nav-btn-outline:hover { background: var(--primary) !important; color: white !important; }
.nav-btn-accent { background: var(--accent) !important; color: #1e293b !important; }
.nav-btn-accent:hover { background: #d97706 !important; }

.hero { position: relative; min-height: 92vh; display: flex; align-items: center; justify-content: center; background: url('https://images.unsplash.com/photo-1625246333195-78d9c38ad449?q=80&w=1740&auto=format&fit=crop') center/cover no-repeat; margin-top: 72px; }
.hero-overlay { position: absolute; inset: 0; background: linear-gradient(135deg, rgba(6,77,40,0.92), rgba(15,118,110,0.85)); }
.hero-content { position: relative; z-index: 2; text-align: center; color: white; max-width: 800px; padding: 2rem; animation: fadeInUp 0.8s ease-out; }
.hero-badge { display: inline-block; padding: 0.4rem 1rem; border-radius: 50px; background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.25); font-size: 0.8rem; font-weight: 600; margin-bottom: 1.5rem; }
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.5rem); font-weight: 800; line-height: 1.15; margin-bottom: 1.5rem; }
.hero h1 .highlight { color: var(--accent); }
.hero p { font-size: clamp(1rem, 2vw, 1.2rem); opacity: 0.9; margin-bottom: 2.5rem; max-width: 650px; margin-inline: auto; }
.hero-actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; margin-bottom: 3rem; }
.btn-hero-primary { background: var(--accent); color: #1e293b; padding: 1rem 2.2rem; border-radius: 50px; font-weight: 700; text-decoration: none; box-shadow: 0 4px 20px rgba(245,158,11,0.4); }
.btn-hero-primary:hover { background: #d97706; transform: translateY(-3px); }
.btn-hero-outline { border: 2px solid rgba(255,255,255,0.6); color: white; padding: 1rem 2.2rem; border-radius: 50px; font-weight: 600; text-decoration: none; }
.btn-hero-outline:hover { background: white; color: var(--primary); border-color: white; }
.hero-stats { display: flex; align-items: center; justify-content: center; gap: 2rem; flex-wrap: wrap; padding-top: 2rem; border-top: 1px solid rgba(255,255,255,0.15); }
.stat strong { display: block; font-size: 1.3rem; font-weight: 800; color: var(--accent); }
.stat span { font-size: 0.75rem; opacity: 0.8; text-transform: uppercase; }
.stat-divider { width: 1px; height: 40px; background: rgba(255,255,255,0.2); }

.section { padding: 5rem 0; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 2rem; }
.section-header { text-align: center; max-width: 650px; margin: 0 auto 3.5rem; }
.section-tag { display: inline-block; font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: var(--primary); margin-bottom: 0.75rem; }
.section-header h2 { font-size: clamp(1.8rem, 3vw, 2.5rem); font-weight: 800; margin-bottom: 1rem; }
.features-section { background: var(--bg-body); }
.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.5rem; }
.feature-card { background: white; padding: 2rem; border-radius: var(--radius); border: 1px solid var(--border); transition: 0.3s; }
.feature-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-md); border-color: var(--primary); }
.feature-icon { font-size: 2rem; margin-bottom: 1rem; display: inline-block; padding: 0.8rem; background: rgba(15,118,110,0.08); border-radius: 12px; }
.about-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 4rem; align-items: center; }
.about-img-placeholder { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); border-radius: 20px; aspect-ratio: 4/3; display: flex; flex-direction: column; align-items: center; justify-content: center; color: white; font-size: 4rem; }
.cta-box { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); border-radius: 20px; padding: 4rem 3rem; text-align: center; color: white; }
footer { background: #0f172a; color: rgba(255,255,255,0.8); padding-top: 4rem; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 3rem; padding-bottom: 3rem; border-bottom: 1px solid rgba(255,255,255,0.1); }
.footer-bottom { padding: 1.5rem 0; text-align: center; font-size: 0.8rem; color: rgba(255,255,255,0.4); }

@keyframes fadeInUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-area { margin-left: 0; }
    .mobile-menu-btn { display: block; }
    .about-layout, .footer-grid { grid-template-columns: 1fr; gap: 2rem; }
    .chat-input-area { flex-direction: column; align-items: stretch; }
    .msg-row { max-width: 90%; }
}
@media (max-width: 768px) {
    .nav-container { padding: 0 1.2rem; }
    .main-nav .nav-links { display: none; position: absolute; top: 72px; left: 0; right: 0; background: white; flex-direction: column; padding: 1rem; border-bottom: 1px solid var(--border); }
    .main-nav .nav-links.active { display: flex; }
    .hero { min-height: 80vh; }
    .stat-divider { display: none; }
}

/* ===== Read / Unread styling ===== */
.msg-row.unread .msg-bubble { font-weight: 600; box-shadow: 0 0 0 2px rgba(245,158,11,0.5); }
.msg-row.unread.received .msg-bubble { border-left: 4px solid var(--accent); }
.unread-dot {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%;
    background: var(--accent); margin-right: 5px; vertical-align: middle;
}
.read-receipt { font-size: 0.7rem; margin-left: 0.4rem; opacity: 0.8; font-weight: 600; }
.msg-row.sent .read-receipt { color: rgba(255,255,255,0.85); }
.msg-row.sent .read-receipt.read { color: #a7f3d0; }

/* Company display for admin */
.msg-from { margin-bottom: 0.3rem; }
.msg-from .from-company { display:block; font-size: 0.78rem; font-weight: 800; color: var(--primary); }
.msg-from .from-person { display:block; font-size: 0.68rem; font-weight: 500; color: var(--text-muted); }
.reply-btn-inline { background:none; border:none; color:inherit; text-decoration:underline; cursor:pointer; font-size:inherit; padding:0; }

/* Sidebar unread badge */
.nav-badge {
    margin-left: auto; background: var(--accent); color: #1e293b;
    font-size: 0.65rem; font-weight: 700; padding: 0.1rem 0.5rem; border-radius: 50px;
}