/* Care application shell. Shared component styles live in corebiq.css. */
*{margin:0;padding:0;box-sizing:border-box;font-family:'Inter',sans-serif;-webkit-tap-highlight-color:transparent}
html,
body{
    display:flex;
    height:100%;
    height:100dvh;
    width:100%;
    overflow:hidden;
    background:#FAFAFB;
    color:var(--text-main);
}
body{margin:0!important;padding:0!important}
#app-container{
    display:flex;
    height:100%;
    height:100dvh;
    width:100%;
    overflow:hidden;
    visibility:hidden;
}
#sidebar-container{
    width:260px;
    flex:0 0 260px;
    height:100%;
    background:var(--surface);
    border-right:1px solid var(--border);
    overflow-y:auto;
    transition:width .25s ease,flex-basis .25s ease,transform .3s ease;
    z-index:1000;
}
#sidebar-container,
#bottomnav-container{display:none!important}
#sidebar-container.is-collapsed{width:84px;flex-basis:84px}
.main-wrapper{
    flex:1;
    min-width:0;
    display:flex;
    flex-direction:column;
    overflow:hidden;
    position:relative;
    height:100%;
}
#header-container{flex-shrink:0}
#bottomnav-container{flex-shrink:0}
#main-content{
    flex:1;
    min-width:0;
    min-height:0;
    display:flex;
    flex-direction:column;
    overflow-y:auto;
    padding:24px;
    background:#FAFAFB;
    -webkit-overflow-scrolling:touch;
}
#main-content.patient-main-active{background:#fff}
#invoice-frame{display:block;width:100%;height:calc(100dvh - 160px);min-height:680px;border:0;background:transparent}
.view-section{display:none;animation:fadeIn .3s ease-in-out}
.view-section.active{display:flex;min-width:0;flex:1 0 auto;flex-direction:column;background:#FAFAFB}
#view-patients.active{background:#fff}
#view-patients.active > #patient-module{background:#fff!important}
.view-section.active > .module-container{display:flex;flex:1 0 auto;flex-direction:column;background:#FAFAFB!important}
@keyframes fadeIn{
    from{opacity:0;transform:translateY(10px)}
    to{opacity:1;transform:translateY(0)}
}
.email-module-container{
    display:flex;
    min-height:420px;
    height:calc(100dvh - 190px);
    flex-direction:column;
    overflow:hidden;
    border:1px solid var(--border);
    border-radius:16px;
    background:#FFFFFF;
}
.email-module-toolbar{
    display:flex;
    min-height:68px;
    align-items:center;
    justify-content:space-between;
    gap:16px;
    padding:12px 18px;
    border-bottom:1px solid var(--border);
}
.email-module-toolbar h1{color:var(--text-main);font-size:17px;font-weight:700}
.email-module-toolbar p{margin-top:4px;color:var(--text-muted);font-size:12px}
.email-module-toolbar a{
    display:inline-flex;
    min-height:38px;
    align-items:center;
    justify-content:center;
    gap:7px;
    padding:0 12px;
    border:1px solid var(--border);
    border-radius:9px;
    background:#FFFFFF;
    color:var(--primary);
    font-size:12px;
    font-weight:600;
    text-decoration:none;
    white-space:nowrap;
}
.email-module-toolbar a:hover{background:var(--primary-soft)}
.email-module-toolbar a .material-symbols-rounded{font-size:18px}
.email-module-container iframe{width:100%;min-height:0;flex:1;border:0;background:#FFFFFF}
.card-title{
    font-size:14px;
    font-weight:700;
    color:var(--text-main);
    margin-bottom:20px;
    display:flex;
    justify-content:space-between;
    align-items:center;
}
.sales-trend-card{margin-bottom:24px}
.sales-trend-heading{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:8px}
.sales-trend-heading .card-title{margin:0}
.sales-trend-total{display:flex;flex-direction:column;align-items:flex-end;gap:2px;text-align:right}
.sales-trend-total-label{color:var(--text-muted);font-size:11px;font-weight:600}
.sales-trend-total-value{color:var(--primary);font-size:21px;font-weight:700;font-variant-numeric:tabular-nums}
.sales-trend-caption{margin:-3px 0 12px;color:var(--text-muted);font-size:12px}
.sales-trend-chart{height:190px;width:100%;position:relative}
.dot{width:8px;height:8px;border-radius:50%}
.calendar-week-card{margin-bottom:24px}
.cal-header-row{
    display:flex;
    justify-content:space-between;
    align-items:center;
    margin-bottom:16px;
}
.cal-nav-btn{
    background:var(--surface-soft);
    border:1px solid var(--border);
    border-radius:9px;
    font-size:20px;
    color:var(--primary);
    cursor:pointer;
    display:flex;
    align-items:center;
    justify-content:center;
    padding:4px;
}
.cal-nav-btn:hover{background:var(--primary-soft);border-color:var(--primary);color:var(--primary)}
.calendar-grid{
    display:grid;
    grid-template-columns:repeat(7,1fr);
    gap:10px;
    text-align:center;
}
.calendar-week-card .cal-header-row{margin-bottom:12px}
.table-responsive{width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}
.saas-table{
    width:100%;
    min-width:800px;
    border-collapse:collapse;
    text-align:left;
}
.saas-table th{
    padding:14px 20px;
    font-size:11px;
    font-weight:700;
    color:var(--text-muted);
    text-transform:uppercase;
    background:var(--surface-soft);
    border-bottom:1px solid var(--border);
    letter-spacing:.5px;
}
.saas-table td{
    padding:16px 20px;
    font-size:13px;
    font-weight:500;
    border-bottom:1px solid var(--border);
    color:var(--text-main);
    vertical-align:middle;
    white-space:nowrap;
}
.saas-table tr:last-child td{border-bottom:none}
.saas-table tbody tr:hover{background:#F7F9FF}
.schedule-table-heading{
    padding:16px 24px;
    border-bottom:1px solid var(--border);
    display:flex;
    justify-content:space-between;
    align-items:center;
    background:var(--surface-soft);
    gap:12px;
}

#calc-popup-container{
    display:none;
    position:fixed;
    bottom:20px;
    right:20px;
    width:320px;
    height:480px;
    background:#fff;
    border-radius:12px;
    box-shadow:0 10px 40px rgba(0,0,0,.25);
    border:1px solid var(--border);
    z-index:10000;
    resize:both;
    overflow:hidden;
    flex-direction:column;
    min-width:250px;
    min-height:350px;
}
#calc-popup-header{
    background:var(--surface);
    color:var(--text-main);
    padding:12px 16px;
    display:flex;
    justify-content:space-between;
    align-items:center;
    cursor:move;
    border-bottom:1px solid var(--border);
    user-select:none;
}

@media(max-width:768px){
    #sidebar-container{
        display:block!important;
        position:fixed;
        z-index:1201;
        top:0;
        left:0;
        transform:translateX(-100%);
        width:min(280px, 100%);
        flex-basis:280px;
        height:100%;
        box-shadow:5px 0 15px rgba(0,0,0,.1);
    }
    #bottomnav-container{display:block!important}
    #bottomnav-container .bottom-nav{display:flex}
    #sidebar-container.is-collapsed{width:84px;flex-basis:84px}
    #sidebar-container.open{transform:translateX(0)}
    #mobile-nav-backdrop{
        position:fixed;
        inset:0;
        z-index:1200;
        display:none;
        background:rgba(32,33,36,.32);
    }
    #mobile-nav-backdrop.visible{display:block}
    #main-content{padding:16px;padding-bottom:calc(82px + env(safe-area-inset-bottom, 0px))}
    #calc-popup-container{
        top:50%;
        left:50%;
        transform:translate(-50%,-50%);
        bottom:auto;
        right:auto;
        resize:none;
        width:min(92vw,360px);
        height:min(76dvh,560px);
    }
    .sales-trend-heading{align-items:flex-start}
    .sales-trend-chart{height:170px}
    .email-module-container{height:calc(100dvh - 230px);min-height:360px}
    .email-module-toolbar{padding:10px 12px;flex-wrap:wrap}
    .email-module-toolbar > *{min-width:0;max-width:100%}
}
@media print {
    #bottomnav-container { display: none !important; }
}

/* Care shell palette */
#app-container, #main-content, #view-dashboard.active,
#main-content.dashboard-main-active, #view-dashboard.active > .dashboard-module {
    background: var(--care-canvas) !important;
}
#app-container .dashboard-header {
    background: #fff;
    border: 0;
    box-shadow: none;
}
#app-container .dashboard-header .header-actions { margin-left: auto; }
#app-container .dashboard-header .profile-button {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: #fff;
    color: var(--care-charcoal);
}
@media (max-width: 768px) {
    #app-container .dashboard-header { padding: 9px 16px; }
}

#app-container .dashboard-header .header-actions { gap: 6px; }
#app-container .header-actions .module-search {
    position: static;
    width: 44px;
    flex: 0 0 44px;
    min-height: 44px;
    margin: 0;
}
#app-container .header-actions .module-search-box {
    width: 44px;
    height: 44px;
    padding: 0;
    justify-content: center;
    border: 0;
    border-radius: 14px;
    background: #fff;
}
#app-container .header-actions :is(.module-search-toggle, .notification-button) {
    width: 44px;
    min-height: 44px;
    flex: 0 0 44px;
    border-radius: 14px;
    background: #fff;
    color: var(--care-charcoal);
}
#app-container .header-actions .module-search-input { display: none; }
#app-container .header-actions .module-search.open .module-search-input { display: block; }
#app-container .header-actions .module-search.open .module-search-box {
    position: absolute;
    inset: calc(100% + 6px) 0 auto auto;
    width: min(340px, calc(100vw - 32px));
    padding-right: 8px;
}
#app-container .header-actions .module-search-results {
    inset: calc(100% + 52px) 0 auto auto;
    width: min(340px, calc(100vw - 32px));
}

.care-developer-role #header-container :is(.top-module-nav, .module-search) { display: none !important; }
.care-developer-role #bottomnav-container .bottom-nav-item:not(.bottom-nav-menu-button) { display: none; }

@media (prefers-reduced-motion: reduce) {
    .view-section { animation: none; }
    #sidebar-container { transition: none; }
}
