/* Shared previews and Email R56. */
.onecup-entity-preview .side-option-header{position:relative!important}
.onecup-entity-preview .side-option-header>div{width:95%;max-width:calc(100% - 36px);min-width:0}
#onecup-preview-dialog-title{display:block!important;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100%;margin:0!important}
.onecup-entity-preview .side-option-header>.close{position:absolute!important;right:10px;top:50%;transform:translateY(-50%)}
.onecup-preview-information-panel{background:#fff;min-height:250px}
.onecup-preview-information-frame{display:block;border:0;border-radius:0;width:100%;height:65vh;background:#fff;opacity:0}
.onecup-preview-information-frame.is-ready{opacity:1}
.onecup-inline-spinner{display:inline-block;width:13px;height:13px;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;animation:onecup-mail-spin .7s linear infinite;margin-left:6px;vertical-align:middle}
@keyframes onecup-mail-spin{to{transform:rotate(360deg)}}
#emails-table .email-wrapper{margin-bottom:10px}
#emails-table .onecup-mail-card>.ibox-title{cursor:pointer}
#emails-table .onecup-mail-reader{display:block!important;overflow:hidden}
.onecup-mail-expand-enter-active,.onecup-mail-expand-leave-active{transition:opacity .18s ease,transform .18s ease}
.onecup-mail-expand-enter,.onecup-mail-expand-leave-to{opacity:0;transform:translateY(-8px)}
#emails-table .onecup-mail-reader .email-body{overflow-wrap:anywhere;min-width:0}
#emails-table .onecup-mail-reader .email-body img{max-width:100%;height:auto}
#newemail.footer-email{position:fixed!important;z-index:9990!important;right:15px!important;bottom:0!important;max-width:calc(100vw - 30px)!important;width:560px!important;margin:0!important}
#newemail>.panel{margin:0!important;max-height:calc(100dvh - 75px);display:flex;flex-direction:column}
#newemail #collapseEmail{min-height:0;overflow-y:auto;overscroll-behavior:contain}
#newemail .panel-body,#newemail .email-new-wrapper{width:100%!important;min-width:0!important;box-sizing:border-box}
#newemail .form-group{position:relative}
#newemail .select2-body{max-height:190px;overflow:auto}
#email-text-message-element{width:100%!important;min-width:0!important;max-height:none!important;overflow-wrap:anywhere;box-sizing:border-box}
@media(max-width:1199px){
 .onecup-preview-information-panel{width:calc(100% + 30px);max-width:none;margin-left:-15px;margin-right:-15px}
 .onecup-preview-information-frame{width:100%;max-width:100%}
 .onecup-mobile-nav{z-index:11000!important}
 #newemail.footer-email{right:0!important;left:0!important;width:100%!important;max-width:100%!important;bottom:calc(var(--onecup-mobile-nav-height,64px) + var(--onecup-mobile-safe-bottom,0px))!important}
 #newemail>.panel{max-height:calc(100dvh - 55px - var(--onecup-mobile-nav-height,64px) - var(--onecup-mobile-safe-bottom,0px));border-radius:0!important}
 #newemail:has(#collapseEmail.in),#newemail:has(#collapseEmail.collapsing){top:55px!important}
 #newemail:has(#collapseEmail.in)>.panel,#newemail:has(#collapseEmail.collapsing)>.panel{height:100%}
 #newemail #collapseEmail.in{flex:1;height:auto!important}
 #newemail input{font-size:16px!important}
 #newemail .panel-heading{flex:0 0 auto}
 #nuevocontacto.modal{bottom:auto!important}
}
@media(prefers-reduced-motion:reduce){.onecup-mail-expand-enter-active,.onecup-mail-expand-leave-active{transition:none}.onecup-inline-spinner{animation:none}}

/* R57: remove inherited footer positioning and keep toolbar within the editor. */
#newemail>.panel{position:relative!important;bottom:auto!important;right:auto!important;width:100%!important;max-width:100%!important;min-width:0;box-sizing:border-box}
#newemail .panel-body{height:auto!important;overflow:visible!important;display:block!important}
#newemail #collapseEmail{overflow-x:hidden!important}
#newemail .email-new-wrapper,#newemail .form-group,#newemail .info-group{max-width:100%!important;min-width:0!important;width:100%!important;box-sizing:border-box}
#newemail .btn-wrapper{display:flex!important;flex-wrap:wrap!important;width:100%!important;min-width:0!important;gap:0;justify-content:flex-start!important}
#newemail .btn-wrapper .btn-group{display:flex!important;flex:0 0 auto!important;width:auto!important;max-width:100%!important;flex-wrap:wrap}
#newemail .btn-wrapper .btn{width:auto!important;min-width:28px!important;flex:0 0 auto!important}
#newemail .contacto-xs-wrapper{max-width:100%;flex-wrap:wrap}
#newemail .contacto-xs{max-width:100%;overflow-wrap:anywhere}
#newemail .new-email-text{height:auto!important;min-width:0}
#newemail #email-text-message-element{height:auto!important;overflow:visible!important}
/* Paragraphs inside the editor are mail content, not the former editor <p>. */
#newemail #email-text-message-element p{height:auto;min-height:0;min-width:0;max-width:100%;overflow:visible;padding:0;margin:0 0 10px;border:0!important;font-size:inherit;font-style:inherit;line-height:1.5;color:inherit}
#newemail #email-text-message-element .onecup-mail-quote-body{font-style:normal;line-height:1.5;color:inherit}

.footer:has(#newemail){z-index:9800!important}
#newemail>.panel,#newemail #collapseEmail{background:#fff!important}
#nuevocontacto.modal{z-index:10020!important}

/* R58: Email follows the list action and pagination controls. */
#emails-table .onecup-mail-card>.ibox-title[aria-expanded="true"]{background:#e0eeff!important}
#emails-table .onecup-mail-card>.ibox-title,#emails-table .onecup-mail-card>.ibox-title p{font-size:14px!important}
#emails-table .onecup-mail-reader,#emails-table .onecup-mail-reader .email-content,#emails-table .onecup-mail-reader .email-body{background:#fff!important}
.onecup-email-actions{display:inline-flex!important;gap:0!important}
.onecup-email-actions>.dropdown-toggle{border-radius:3px!important}
.onecup-email-actions.has-binding>.dropdown-toggle{border-radius:3px 0 0 3px!important}
.onecup-email-actions>.onecup-email-bind{border-radius:0 3px 3px 0!important;margin-left:-1px!important}
#emails-table .pagination{margin-top:0;gap:10px}
#emails-table .pagination .rows{display:flex;align-items:center;gap:5px}
#emails-table .pagination ol{display:flex;align-items:center}

/* Email module surfaces share square corners on desktop and mobile. */
html body #emails-table .email-header,
html body #emails-table .email-body,
html body .side-3 .email .dropdown-panel .ibox{border-radius:0!important}

/* R59: reading spacing and viewport-bounded message body. */
.side-3 .email .dropdown-panel .ibox-title .table > tbody > tr > td{padding:5px 15px 5px 0!important}
/* Mail table columns use 5:20:60:10 shares; the sender starts after 5/95 of the row. */
.side-3 .email .dropdown-panel .ibox-content .email-content .email-header{padding:10px 15px 10px calc(100% / 19)!important}
#emails-table .onecup-mail-reader .email-body{padding:0!important;border-radius:0!important;box-sizing:border-box;min-height:0!important;max-height:calc((100dvh - 110px) * .95);overflow-y:auto!important;overflow-x:hidden;overscroll-behavior:contain}
@media(max-width:1199px){#emails-table .onecup-mail-reader .email-body{max-height:calc((100dvh - 110px - var(--onecup-mobile-nav-height,64px) - var(--onecup-mobile-safe-bottom,0px)) * .95)}}

/* Responsive mailbox keeps the module title and uses shared search/dropdown controls. */
html body #emails-table .onecup-mail-folders-group,
html body #emails-table .onecup-list-search-toggle-group,
html body #emails-table #onecup-emails-list-search{display:none!important}
@media(max-width:1199px){
 /* Keep the responsive mailbox list flush with its toolbar. */
 html body #emails-table .tabs-container>.side-0{margin-bottom:0!important}
 html body #emails-table #onecup-mail-folders{display:none!important}
 html body #emails-table .onecup-mail-folders-group,
 html body #emails-table .onecup-list-search-toggle-group{display:flex!important}
 html body #emails-table .side-0>section:last-child{display:flex!important;flex-direction:column!important;align-items:stretch!important}
 html body #emails-table .side-0>section:last-child>nav{order:0}
 html body #emails-table #onecup-emails-list-search{order:1;width:100%!important;max-width:100%!important;flex:none!important;margin:10px 0 0!important}
 html body #emails-table #onecup-emails-list-search.is-open{display:flex!important}
 html body #emails-table .onecup-mail-compose-mobile{display:flex!important;position:fixed!important;right:15px!important;bottom:calc(var(--onecup-mobile-nav-height,64px) + 15px)!important;align-items:center;justify-content:center;gap:8px;padding:14px 18px!important;border-radius:16px!important;background:#1a73e8!important;color:white!important;box-shadow:0 5px 16px #181a5533;z-index:9800;font-size:12px!important}
 html body #emails-table .onecup-mail-card{margin:0!important;border-radius:0!important;border-width:0 0 1px!important;box-shadow:none!important}
 html body #emails-table .onecup-mail-card>.ibox-title{padding:12px 10px!important;min-height:72px!important}
 html body #emails-table .onecup-mail-card>.ibox-title .table-responsive{overflow:visible!important}
 html body #emails-table .onecup-mail-card>.ibox-title table,html body #emails-table .onecup-mail-card>.ibox-title tbody{display:block!important;width:100%!important}
 html body #emails-table .onecup-mail-card>.ibox-title tr{display:grid!important;grid-template-columns:28px minmax(0,1fr) 82px;align-items:center;gap:4px 8px}
 html body #emails-table .onecup-mail-card>.ibox-title tr>td{padding:0!important;min-width:0!important;width:auto!important;display:block!important}
 html body #emails-table .onecup-mail-card>.ibox-title td.check{grid-column:1;grid-row:1 / 3}
 html body #emails-table .onecup-mail-card>.ibox-title td.remitente{grid-column:2;grid-row:1}
 html body #emails-table .onecup-mail-card>.ibox-title td.asunto{grid-column:2 / 4;grid-row:2}
 html body #emails-table .onecup-mail-card>.ibox-title td.date{grid-column:3;grid-row:1}
 html body #emails-table .onecup-mail-card>.ibox-title td p{width:100%!important;margin:0!important;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.4!important;font-size:14px!important}
 html body #emails-table .onecup-mail-card>.ibox-title td.date p{font-size:10px!important;text-align:right}
 html body #emails-table .onecup-mail-card:not(.read)>.ibox-title td.remitente p,html body #emails-table .onecup-mail-card:not(.read)>.ibox-title td.asunto p{font-weight:700!important}
 html body #emails-table .side-3{width:100%!important;margin-left:0!important;padding-top:0!important;padding-bottom:85px!important}
}
@media(prefers-reduced-motion:reduce){#onecup-mail-folders{transition:none!important}}

/* Email formatting expands inline; primary actions stay available at either edge. */
#newemail .btn-wrapper.onecup-email-toolbar{flex-wrap:nowrap!important;align-items:stretch;gap:0!important;}
#newemail .onecup-email-toolbar-left{display:flex;flex:0 1 auto;min-width:0;align-items:stretch;gap:0;}
#newemail .onecup-email-toolbar .btn-group{flex-wrap:nowrap!important;}
#newemail .onecup-email-toolbar-left .btn{border:1px solid #1a73e8!important;border-right-width:0!important;border-radius:0!important;margin:0!important;}
#newemail .onecup-email-toolbar-left>.onecup-email-format-toggle>.btn{border-radius:3px 0 0 3px!important;}
#newemail .onecup-email-toolbar-left>.onecup-email-draft>.btn{border-right-width:1px!important;border-radius:0 3px 3px 0!important;}
#newemail .onecup-email-format-toggle>.btn.active{background:#1a73e8!important;color:#fff!important;}
#newemail .onecup-email-format-options{display:flex;flex:0 1 auto;width:max-content;min-width:0;max-width:0;overflow:hidden;visibility:hidden;transition:max-width .2s ease,visibility 0s linear .2s;}
#newemail .onecup-email-format-options.is-open{max-width:360px;overflow-x:auto;visibility:visible;transition:max-width .2s ease,visibility 0s;scrollbar-width:none;}
#newemail .onecup-email-format-options::-webkit-scrollbar{display:none;}
#newemail .onecup-email-format-buttons{display:flex;flex:0 0 auto;align-items:stretch;gap:0;}
#newemail .onecup-email-font-size{appearance:none;text-align:center;cursor:pointer;background:#fff;color:#1a73e8;padding:5px 10px;min-height:30px;}
#newemail .onecup-email-toolbar>.onecup-email-send{margin-left:auto!important;padding-left:12px;}
#newemail .onecup-email-toolbar>.onecup-email-send>.btn{border:1px solid #1a73e8!important;border-radius:3px!important;white-space:nowrap;margin:0!important;}
@media(prefers-reduced-motion:reduce){#newemail .onecup-email-format-options,#newemail .onecup-email-format-options.is-open{transition:none;}}

/* Recipient fields own their stacking order so later create buttons stay underneath. */
#newemail .onecup-email-recipient{isolation:isolate;z-index:0}
#newemail .onecup-email-recipient.is-open{z-index:2}
#newemail .onecup-email-recipient>div.select2{top:100%;z-index:101;max-height:240px;overflow:auto}
#newemail .onecup-email-recipient .select2-body{max-height:none;overflow:visible}
#newemail .onecup-email-recipient .select2-body li{height:auto;min-height:35px;flex-shrink:0}
#newemail .onecup-email-recipient .onecup-email-recipient-option{display:flex;flex-direction:column;align-items:flex-start;justify-content:center;gap:3px;width:100%;height:auto;min-height:48px;padding:8px 12px}
#newemail .onecup-email-recipient-option strong,#newemail .onecup-email-recipient-option span{display:block;width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#newemail .onecup-email-recipient-option span{font-size:12px}
#newemail .onecup-email-recipient-message{align-items:flex-start;padding:10px 12px;font-size:12px}

/* Format uses the same icon/text spacing as the other composer actions. */
#newemail .onecup-email-format-toggle>.btn{column-gap:7px;white-space:nowrap}
#newemail .onecup-email-format-toggle>.btn>:is(svg,i,.caret){margin:0!important;flex-shrink:0}
#newemail .onecup-email-format-toggle .onecup-email-format-caret{transform:rotate(-90deg);color:inherit!important}

/* Auto-height recipient results must not leave category headings against the top edge. */
#newemail .onecup-email-recipient .select2-body li.select2-title{height:auto;min-height:35px;justify-content:center;padding:8px 12px}
#newemail .onecup-email-recipient .select2-body li.select2-title>h5{height:auto;min-height:0;margin:0;line-height:1.4}
@media(max-width:360px){
 /* Keep the named toggle and every format option reachable on narrow phones. */
 #newemail .onecup-email-format-toggle>.btn{padding-left:5px!important;padding-right:5px!important}
 #newemail .onecup-email-toolbar-left{overflow-x:auto;scrollbar-width:none}
 #newemail .onecup-email-toolbar-left::-webkit-scrollbar{display:none}
 #newemail .onecup-email-format-options.is-open{flex-shrink:0}
}

/* Mail loading uses the same table rows and responsive columns as the inbox. */
html body #emails-table .onecup-mail-list-loading .onecup-mail-card {
 margin:0!important;border-radius:0!important;box-shadow:none!important;
}
#emails-table .onecup-mail-list-loading .dropdown-panel {pointer-events:none}
#emails-table .onecup-mail-list-loading table {table-layout:fixed;width:100%}
#emails-table .onecup-mail-list-loading .onecup-mail-loading-bar {
 display:inline-block;vertical-align:middle;width:80%;height:10px;
 background:linear-gradient(90deg,#edf0f4 25%,#f7f8fa 45%,#edf0f4 65%);
 background-size:300% 100%;border-radius:999px;
 animation:onecup-preview-skeleton 1.1s ease infinite;
}
#emails-table .onecup-mail-list-loading .asunto .onecup-mail-loading-bar {width:88%}
#emails-table .onecup-mail-list-loading .onecup-mail-loading-check {width:14px;height:14px;border-radius:3px}
@media(prefers-reduced-motion:reduce){
 #emails-table .onecup-mail-list-loading .onecup-mail-loading-bar {animation:none}
}

/* Reader actions follow the compact circular actions used by the feed. */
#emails-table .email-header .onecup-mail-reply-actions {
 display:flex;align-items:center;justify-content:flex-end;gap:5px;flex:0 0 auto;
}
html body #emails-table .email-header .onecup-mail-reply-actions>.btn-circle {
 display:inline-flex!important;width:24px!important;height:24px!important;min-width:24px!important;
 flex:0 0 24px!important;align-items:center!important;justify-content:center!important;
 margin:0!important;padding:0!important;border:0!important;border-radius:50%!important;
 color:#90949c!important;background:transparent!important;
}
html body #emails-table .email-header .onecup-mail-reply-actions>.btn-circle:hover,
html body #emails-table .email-header .onecup-mail-reply-actions>.btn-circle:focus-visible {
 color:var(--onecup-primary)!important;background:var(--onecup-primary-soft)!important;
}
html body #emails-table .email-header .onecup-mail-reply-actions>.btn-circle>:is(i,svg) {
 width:14px!important;height:14px!important;margin:0!important;color:inherit!important;
 display:inline-flex;align-items:center;justify-content:center;
}
@media(max-width:1199px){
 .side-3 .email .dropdown-panel .ibox-content .email-content .email-header{padding-left:46px!important}
 #emails-table .email-header>.onecup-mail-reply-actions {width:auto;max-width:100%}
 #emails-table .email-header>div:first-child {flex:1;min-width:0}
}

/* Every shared preview stays within the visible mobile viewport, including the keyboard. */
@media(max-width:1199px){
 html.onecup-preview-open,body.onecup-preview-open{overflow:hidden!important;overscroll-behavior:none}
 .onecup-entity-preview .side-option-body{min-height:0;overscroll-behavior:contain}
}
.onecup-entity-preview .onecup-preview-information-panel .form-group>p{overflow-wrap:anywhere}

/* Keep the existing skeleton in place until the embedded record has rendered. */
.onecup-preview-information-panel{position:relative;}
.onecup-preview-information-frame:not(.is-ready){position:absolute;top:0;left:0;visibility:hidden;pointer-events:none;}
