@media (max-width: 1200px) {
    .table-message-history tr td.from {
        max-width: 150px;
    }

    .with-sidebar .actionbar.actionbar__container {
        margin-left: -20px;
        padding: 10px 23px;
    }
}

@media (max-width: 1024px) {
    /* reduce padding */
    .btn {
        padding-right: 8px;
    }

    /* fit export button */
    .actionbar > .btn-group {
        margin: 0;
    }

    #container .with-sidebar {

        -webkit-border-radius: 0;
        -moz-border-radius: 0;
        border-radius: 0;
    }

    .with-sidebar .actionbar.actionbar__container {
        margin-left: -23px;
    }
}

@media (max-width: 980px) {
    .with-sidebar .actionbar.actionbar__container {
        margin-left: -26px;
    }
}


/*
    Our mobile works within 768px to 0px.
    Standard bootstrap's 'phone' begins at 767px
    but that way we can support ipad portaid
    mode better.
*/
@media (max-width: 768px) {
    #messagesList tr,
    .table.mailbox tr,
    .mailbox tr {
        display: block;
        float: none;
        padding: 8px 88px 8px 48px;
    }


    .actionbar.actionbar__container .dropdown-menu {
        right: 0;
        left: unset;
    }

    /* show mobile menu button */
    #lower-nav #mobileMenuButton {
        display: block !important;
    }

    /* mobile message view action bar */
    .with-sidebar .actionbar {
        margin-left: -15px;
        margin-right: -15px;
    }

    .with-sidebar .actionbar.actionbar__container {
        box-sizing: border-box;
        padding: 0 15px 10px;
        margin-left: -15px;
    }

    /* stretch div container */
    .row-fluid .span9,
    .row-fluid .span10,
    .row-fluid .span11,
    .row-fluid .span12 {
        width: 100%;
        margin-left: 0px;
    }

    /* mobile header menu button */
    #container #lower-nav {
        padding-right: 0px;
    }

    #container #head .row-fluid .right {
        float: right;
        width: auto;
    }

    #container .with-sidebar #sidebar .sidebar-list li {
        margin: auto;
    }

    #container .with-sidebar #sidebar {
        padding-left: 0px;
        padding-right: 0px;
        margin-top: -1px;
        width: 100% !important;
        display: block;
    }

    /* Remove arrow (copied from old zso_app.css) */
    .arrow {
        display: none;
    }

    /* Reduce padding top and bottom (copied from old zso_app.css) */
    #container .with-sidebar #sidebar .sidebar-list {
        padding-top: 0px;
        padding-bottom: 10px;
    }

    /* Removes sidebar (copied from old zso_app.css) */
    .with-sidebar {
        background: none !important;
        background-image: none;
        background-position-x: initial;
        background-position-y: initial;
        background-size: initial;
        background-attachment: initial;
        background-origin: initial;
        background-clip: initial;
        background-color: initial;
    }

    /* Add Padding left and right (copied from old zso_app.css) */
    .containerbox, #footer {
        padding: 0 15px 15px 15px !important;
    }

    /* Add Padding left and right (copied from old zso_app.css) */
    .page-header {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }

    .text-info {
        word-wrap: break-word;
    }

    /* disable button transitions */
    .btn:hover,
    #container #lower-nav ul li:hover,
    #container .with-sidebar #sidebar .sidebar-list li:hover a,
    #container .with-sidebar #sidebar .sidebar-list li.selected:hover a {
        -o-transition: none;
        -moz-transition: none;
        -webkit-transition: none;
        transition: none;
    }

    /* mobile fix for the counter */
    #container #lower-nav ul li span:before,
    #container #lower-nav ul li a:before,
    #container #lower-nav ul li span:after,
    #container #lower-nav ul li a:after {
        content: none;
    }

    /* mobile Action bar */
    .actionbar .btn {
        margin-bottom: 5px;
        padding-top: 5px;
        padding-bottom: 5px;
        margin-left: 2px;
        margin-right: 2px;
    }

    .actionbar.actionbar__container .btn,
    .actionbar.actionbar__container .btn-group .btn-group > .btn {
        padding: 1px;
        width: 44px;
        height: 44px;
        align-items: center;
        box-sizing: content-box;
    }

    .actionbar .btn.info.nav-answer-btn {
        margin-right: 0;
    }

    #content .containerbox .actionbar .btn.dropdown-toggle {
        margin-right: 2px;
    }

    /* mobile variant for the table class */
    .table thead {
        display: none;
    }

    .table td {
        border: none;
        display: block;
        float: none;
        padding: 0px;
        line-height: normal;
        background: none;
    }

    .table tr {
        position: relative; /* anchor for absolute children */
        clear: both;
        background: none;
        width: 100%;
        border-bottom: thin #ddd solid;
        height: auto;
        box-sizing: border-box;
    }

    .table tr.template-row {
        display: none;
    }

    .table tr:hover {
        background-color: #eee;
        -webkit-border-radius: 4px;
        -moz-border-radius: 4px;
        border-radius: 4px;

    }

    .table-striped tbody tr:nth-child(odd) td,
    .table-striped tbody tr:nth-child(odd) th {
        background: none;
    }

    .messagelink {
        width: auto;
        line-height: normal;
        min-height: inherit;
    }

    /* message list table definition */
    #messagesList, .table.mailbox, .mailbox {
        width: 100% !important;
        max-width: 100vw;
        table-layout: fixed;
        margin: 0 auto;
    }

    .mailbox {
        max-width: 100vw;
        overflow-x: hidden;
    }

    .mailbox tr {
        border-bottom: 1px solid #ddd;
    }

    .mailbox tr .action {
        position: absolute;
        left: 0;
        top: 0;
        width: 48px;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
    }

    .mailbox tr td.date {
        position: absolute;
        right: 8px;
        top: 8px;
        width: 80px;
        text-align: right;
        white-space: nowrap;
        font-size: 8pt;
    }

    .table tr td.subject {
        display: block;
        width: 100%;
        padding-top: 6px;
        margin: 0;
        height: auto;
        font-size: 11pt;
    }

    .table tr td.subject .messagelink {
        display: block;
        max-width: 100%;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .table tr td.subject .funclink {
        display: block;
        max-width: 100%;
    }

    .table tr td.subject .funclink .messagelink {
        display: block;
        max-width: 100%;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        font-weight: 400;
    }

    .mailbox tr td.attachment {
        position: static;
        display: block;
        width: 100%;
        margin-top: 0;
        right: auto;
        top: auto;
    }

    .attachments .attachment-icon,
    .mailbox tr td.attachment img,
    .mailbox tr td.attachment .sprite {
        vertical-align: middle;
        margin-right: 6px;
    }

    .mailbox tr td.from {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 9pt;
    }

    .mailbox tr td.from .reply-mini {
        display: inline-flex;
        width: 16px;
        height: 14px;
    }

    .mailbox tr td.state {
        padding-right: 2px;
        padding-left: 2px;
        height: 15px;
        padding-top: 5px;
    }

    .mailbox tr td.comment {
        padding-right: 2px;
        padding-left: 2px;
        padding-top: 5px;
        height: 16px;
        overflow: hidden;
        text-overflow: ellipsis;
        clear: left;
        display: block;
    }

    /* attachment list table definition */
    .attachments tr td.name {
        max-width: 100%;
    }

    .attachments tr td.name img {
        float: left;
        display: inline;
        margin-top: 10px;
        margin-left: 10px;
    }

    .attachments tr td.name span {
        float: left;
        display: inline;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .attachments tr td.size {
        float: left;
        clear: left;
        padding-top: 2px;
    }

    .attachments tr td.action {
        float: right !important;
        padding-top: 6px;
    }

    /* message-history list table definition */
    .table-message-history tr .directionIcon {
        float: left;
        padding: 10px 10px 0px 5px;
    }

    .table-message-history tr td.from,
    table .password-history tr td.from {
        float: left;
        margin-top: 26px;
    }

    .table-message-history tr td.subject {
        overflow: hidden;
        text-overflow: ellipsis;
        float: left;
        width: 50%;
        margin-top: 0px;
        margin-left: 0px;
    }

    .table-message-history tr td.date {
        float: right;
        margin-top: 20px;
        position: absolute;
        right: 18px;
    }

    .table-message-history tr td.deliveryType {
        float: right;
        margin-top: 0px;
        position: absolute;
        right: 22px;

    }

    /* password-history list table definition */
    .password-history td.from {
        float: left;
        margin-left: 5px;
        margin-top: 5px;
    }

    .password-history td.to {
        float: left;
        margin-left: 15px;
        margin-top: 5px;
    }

    .password-history td.password {
        float: left;
        clear: left;
    }

    .password-history td.password pre {
        border: none;
        background-color: transparent;
        padding: 0;
        margin: 0 0 0 5px;
        float: left;
    }

    /* message-tracking list table definition */
    .table.table-message-tracking tr td.date {
        float: right;
        padding-right: 2px;
        font-size: 10px;
        height: 15px;
        padding-top: 5px;
    }

    .table.table-message-tracking tr td.state {
        float: left;
        padding-right: 2px;
        padding-left: 2px;
        height: 15px;
        padding-top: 5px;
    }

    .table.table-message-tracking tr td.comment {
        padding-right: 2px;
        padding-left: 2px;
        padding-top: 5px;
        height: 16px;
        overflow: hidden;
        text-overflow: ellipsis;
        clear: left;
        float: none;
        display: block;
    }

    .table.table-message-tracking .phone-inline {
        display: inline;
    }

    /* relocate reply-mini-button */
    .sprite.reply-mini {
        width: 16px;
        height: 14px;
        margin-right: 0px;
    }

    /* Destroy's look and feel for the footer when using smaller devices */
    #container #powered_by {
        display: none;
    }

    /* hide username at logout button */
    .username {
        display: none !important;
    }

    /* show maildirinfo because we're using mobile view on 768px */
    #content #sidebar .sidebar-list .maildirInfo {
        display: inherit !important;
    }

    #containerbox.kmhtml2 {
        width: 90%;
        padding-left: 25px;
    }

    /* Sidebar labels truncate */
    #container .with-sidebar #sidebar .sidebar-list li a {
        display: block;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        min-width: 0;
    }

    #content .span9, #content .page-header, #content .containerbox {
        max-width: 100vw;
        margin-left: auto;
        margin-right: auto;
    }

    /* integrated mobile grid for message rows */
    #messagesList tr,
    .mailbox tr {
        display: grid;
        grid-template-columns: 1fr 24px;
        grid-template-areas:
            "subject attachment"
            "from    attachment";
        column-gap: 12px;
        row-gap: 2px;
    }

    #messagesList td.subject,
    .mailbox td.subject {
        grid-area: subject;
        display: grid;
        grid-template-columns: 1fr 20px;
        align-items: center;
        min-width: 0;
    }

    #messagesList td.subject .unread,
    .mailbox td.subject .unread {
        display: none !important;
    }

    #messagesList td.subject .messagelink,
    .mailbox td.subject .messagelink {
        grid-column: 1;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #messagesList td.subject .reply-mini,
    .mailbox td.subject .reply-mini {
        grid-column: 2;
        width: 16px;
        height: 14px;
        justify-self: end;
    }

    #messagesList td.attachment,
    .mailbox td.attachment {
        grid-area: attachment;
        width: 24px;
        min-width: 24px;
        display: flex;
        justify-content: center;
        margin-top: 7px;
    }

    #messagesList td.from,
    .mailbox td.from {
        grid-area: from;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    table.attachments {
        table-layout: fixed;
        width: 100%;
    }

    table.attachments > tbody > tr {
        display: grid;
        grid-template-columns: 44px 1fr 44px;
        grid-template-rows: auto auto;
        column-gap: 12px;
        align-items: center;
        padding: 8px 0;
        border-bottom: 1px solid #ddd;
    }

    table.attachments.table-bordered > tbody > tr > td {
        border: 0 !important;
    }

    table.attachments.table-bordered {
        border-left: 1px solid #ddd;
        border-right: 1px solid #ddd;
    }

    table.attachments td.attachments-icon-box {
        grid-column: 1;
        grid-row: 1 / span 2;
        justify-self: center;
        text-align: center;
    }

    table.attachments td.name {
        grid-column: 2;
        grid-row: 1;
        width: 100%;
        padding-right: 6px;
        font-weight: 600;
    }

    table.attachments td.name .attachment-name {
        display: block;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    table.attachments td.size {
        grid-column: 2;
        grid-row: 2;
        padding-top: 2px;
        font-size: 12px;
        color: #666;
        text-align: left;
    }

    table.attachments td.action {
        grid-column: 3;
        grid-row: 1 / span 2;
        justify-self: center;
        text-align: center;
        padding-right: 0;
    }

    table.attachments td.action .sprite.download-mini,
    table.attachments td.action .sprite.remove-mini {
        display: inline-block;
    }

    table.attachments.table-bordered > tbody > tr > td.attachments-icon-box + td.name {
        border-left: 0 !important;
    }

    .attachments-icon-box {
        width: 16px;
        height: 16px;
    }
}

@media (max-width: 480px) {

    .actionbar.actionbar__container .dropdown-menu {
        right: auto;
        left: 50%;
        transform: translateX(-50%);
    }

    /* Relocate Send/Save-Buttons */
    .form-horizontal .form-actions {
        padding-left: 0;
    }

    /* Relocate Send/Save-Buttons on top */
    .form-actions.top {
        margin-top: 0px;
    }

    .table tr td.subject .messagelink {
        width: 100% !important;
    }

    #loading {
        left: 40%;
    }

    #headToggler {
        float: none !important;
    }

    #messagesList tr,
    .table.mailbox tr,
    .mailbox tr {
        padding-right: 66px;
        padding-left: 48px;
    }

    .mailbox tr td.date {
        width: 68px;
        right: 8px;
    }
}

@media (max-width: 370px) {
    .table tr td.subject .messagelink {
        width: 100% !important;
    }

    #loading {
        left: 35%;
    }
}

@media (min-width: 769px) and (max-height: 500px) {

    #decryption-dialogue.modal {
        top: 65%;
    }
}

@media (min-width: 769px) and (max-height: 400px) {

    #decryption-dialogue.modal {
        top: 75%;
    }
}

@media (max-width: 768px) and (max-height: 500px) {

    #decryption-dialogue.modal {
        top: 15%;
    }
}

@media (max-width: 768px) and (max-height: 400px) {

    #decryption-dialogue.modal {
        top: 2%;
    }
}

@media (orientation: landscape) and (max-width: 1024px) {

    #canceling-warning.modal {
        position: fixed;
        top: 20px;
        left: 20px;
        right: 20px;
        width: auto;
        margin: 0;
    }
}

@media (orientation: portrait) and (max-width: 534px) {
    .table-message-history tr td.subject {
        overflow: hidden;
        text-overflow: ellipsis;
        float: left;
        width: 55%;
        margin-top: -41px;
        margin-left: 38px;
    }
}
