/*
 * Extended SaaS presentation for administration, messaging, registration,
 * checkout, settings, and legacy static listings. Existing behavior hooks remain.
 */

/* Shared content surfaces and legacy fixed-width cleanup. */
#main-content .right_panel,
#main-content .main_full,
#order_body,
#msg_box_right,
.tabs,
.dashboard-container {
    min-width: 0;
}

#main-content table {
    max-width: 100%;
}

#main-content th,
#main-content td {
    min-width: 0;
    overflow-wrap: anywhere;
}

#main-content .titlehdr {
    float: none;
    width: auto;
    max-width: 100%;
}

#main-content p > .titlehdr {
    display: block;
    margin-bottom: 4px;
}

#main-content p {
    max-width: 100%;
}

#main-content input[type="text"],
#main-content input[type="password"],
#main-content input[type="email"],
#main-content input[type="number"],
#main-content select,
#main-content textarea {
    min-width: 0;
}

#main-content textarea {
    width: 100% !important;
}

#main-content div[style*="width:700px"],
#main-content div[style*="width:600px"],
#main-content div[style*="width: 700px"],
#main-content div[style*="width: 600px"] {
    width: auto !important;
    max-width: 100%;
}

.myaccount,
.forms {
    width: 100% !important;
    padding: 10px;
}

.myaccount td,
.forms td,
.site_td {
    padding: 10px;
    border-bottom: 1px solid var(--slate-100);
    color: var(--slate-700);
    vertical-align: top;
}

.myaccount tr:last-child td,
.forms tr:last-child td {
    border-bottom: 0;
}

.example {
    color: var(--slate-600);
    font-size: 12px;
}

/* Keep the intended two application columns on wide screens. */
@media (min-width: 1101px) {
    #main-content > table > tbody > tr > td.left_panel,
    #main-content > table > tbody > tr > td.right_panel {
        display: table-cell;
        float: none;
    }

    #main-content > table > tbody > tr > td.left_panel {
        width: 218px !important;
        margin-right: 0;
    }

    #main-content > table > tbody > tr > td.right_panel {
        width: auto !important;
        margin: 0;
    }
}

/* Legacy static listings receive the same visual language as DataTables. */
table.responsive-static {
    width: 100% !important;
    max-width: 100%;
    margin: 12px 0;
    border: 1px solid var(--border);
    border-spacing: 0;
    border-radius: var(--radius);
    background: var(--surface);
    table-layout: fixed;
}

table.responsive-static td {
    padding: 11px;
    border-bottom: 1px solid var(--slate-100);
    background: var(--surface);
    color: var(--slate-700);
    font-size: 13px;
    line-height: 1.5;
    text-align: left;
    vertical-align: top;
    white-space: normal !important;
}

table.responsive-static tr.responsive-header-row td {
    border-bottom: 1px solid var(--border);
    background: var(--surface-muted);
    color: var(--slate-700);
    font-size: 12px;
    font-weight: 700;
}

table.responsive-static tbody tr:last-child td {
    border-bottom: 0;
}

table.responsive-static td[colspan] {
    text-align: center;
}

/* Settings tabs and inline editor panels. */
.tabs ul.tabNavigation,
ul.tabNavigation {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 14px;
    padding: 0;
    list-style: none;
}

.tabs ul.tabNavigation li,
ul.tabNavigation li {
    display: block;
    float: none;
    margin: 0;
    padding: 0;
    background: none !important;
}

.tabs ul.tabNavigation li a,
ul.tabNavigation li a {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    padding: 9px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--slate-700);
    font-family: "Lato", sans-serif;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.35;
    text-decoration: none;
}

.tabs ul.tabNavigation li a:hover,
.tabs ul.tabNavigation li a.selected,
ul.tabNavigation li a:hover,
ul.tabNavigation li a.selected {
    border-color: var(--blue-600);
    background: var(--blue-50);
    color: var(--blue-700);
    text-decoration: none;
}

.tabs > div {
    width: 100%;
    max-width: 100%;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.tabs > div > div[id] {
    width: auto !important;
    max-width: 100%;
    margin: 12px 0 !important;
    padding: 16px !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    background: var(--surface-muted) !important;
    color: var(--text);
    font: 14px/1.5 "Lato", sans-serif !important;
}

.tabs > div > div[id] > a {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    min-height: 44px;
    clear: both;
}

.tabs > div > div[id] > a > span {
    float: none !important;
}

.tabs > div > div[id] input[type="text"],
.tabs > div > div[id] input[type="password"],
.tabs > div > div[id] input[type="email"],
.tabs > div > div[id] input[type="number"],
.tabs > div > div[id] select {
    max-width: 100%;
}

/* Checkout, order summaries, and collapsible forms. */
.order_created {
    width: 100% !important;
    border: 1px solid var(--border);
    border-collapse: collapse;
    border-radius: var(--radius);
    background: var(--surface);
    table-layout: fixed;
}

.order_created td {
    padding: 11px;
    border-bottom: 1px solid var(--slate-100);
    color: var(--slate-700);
    vertical-align: top;
}

.order_created > tbody > tr > td:first-child {
    width: 24% !important;
}

.order_created > tbody > tr > td:nth-child(2) {
    width: 42% !important;
}

.order_created > tbody > tr > td[rowspan] {
    width: 34% !important;
}

.order_created .popbox {
    width: 100% !important;
    max-width: 100%;
}

.order_created .popbox .box {
    width: 100%;
    max-width: 400px;
}

.order_created .table_compose {
    width: 100% !important;
    max-width: 100%;
    table-layout: fixed;
}

.order_created td div[style*="overflow:scroll"] {
    width: auto !important;
    max-width: 100%;
    height: auto !important;
    max-height: 300px;
    padding: 12px !important;
    overflow: auto !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm);
    background: var(--surface-muted);
    line-height: 1.6;
    text-align: left;
}

.popbox .open,
.popbox .open_link,
.submit_bt_link {
    border-color: var(--border);
    background-color: var(--surface);
    color: var(--blue-700);
    box-shadow: none;
}

.popbox .open_link,
.submit_bt_link {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    padding: 9px 12px 9px 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230064e6' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 11px center;
    background-size: 16px 16px;
}

.popbox .box {
    z-index: 40;
    border-color: var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
}

.popbox .box input[type="file"] {
    width: 100%;
    max-width: 100%;
}

.popbox .box a.close {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    color: var(--blue-700);
}

.col h3 a,
#collapsing h3 a {
    padding: 10px 10px 10px 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230064e6' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 11px center;
    background-size: 16px 16px;
    color: var(--slate-700);
}

.col h3.open,
#collapsing h3.open,
#collapsing {
    border-color: var(--border);
    background: var(--surface-muted);
    color: var(--slate-700);
}

.col h3.open a,
#collapsing h3.open a {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230064e6' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M5 12h14'/%3E%3C/svg%3E");
    color: var(--blue-700);
}

#order_body {
    width: 100%;
    max-width: 100%;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-muted);
}

#order_body h1 {
    margin: 0 0 14px;
    font-size: 22px;
}

#order_body form > table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    table-layout: fixed;
}

#order_body form > table > tbody > tr > td {
    padding: 9px;
    border-bottom: 1px solid var(--slate-100);
    color: var(--slate-700);
    vertical-align: top;
}

#order_body form > table > tbody > tr > td:first-child {
    width: 29%;
    font-weight: 700;
}

#order_body form > table table {
    width: 100% !important;
    max-width: 100%;
    table-layout: fixed;
}

#order_body input[type="text"],
#order_body input[type="number"],
#order_body select {
    max-width: 100%;
}

#order_body #order_details,
#order_body #order_comments {
    width: 100% !important;
}

#order_body .order_now,
.order_now {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
}

/* Messaging uses the same navigation, cards, controls, and responsive tables. */
#main-content > #msg_box_wrapper {
    padding: 0;
    border: 0;
    background: transparent;
}

#msg_box_wrapper .titlehdr {
    margin-bottom: 12px;
}

.msg_refresh {
    display: flex;
    justify-content: flex-end;
    float: none;
    width: 100%;
    margin: 0 0 10px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    text-align: right;
}

.msg_refresh a {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 7px 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--blue-700);
    font-weight: 700;
}

#msg_menu {
    float: none;
    width: 100%;
}

#msg_menu ul {
    float: none;
    margin: 0;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-muted);
    font-family: "Lato", sans-serif;
    list-style: none;
}

#msg_menu ul li {
    margin: 2px 0;
    padding: 0;
    color: var(--slate-600);
    font-family: "Lato", sans-serif;
    font-size: 13px;
}

#msg_menu ul li a {
    display: inline-block;
    min-height: 40px;
    margin: 0;
    padding: 9px 10px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--slate-700);
    font-weight: 700;
    line-height: 1.4;
}

#msg_menu ul li a:hover,
#msg_menu ul li a.current {
    border-color: var(--border);
    background: var(--surface);
    color: var(--blue-700);
    text-decoration: none;
}

#msg_box_right {
    float: none;
    width: 100%;
    max-width: 100%;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

#msg-body,
#msg_body_i {
    width: 100%;
    max-width: 100%;
    table-layout: fixed;
}

.inbox_headers {
    margin-bottom: 12px;
    color: var(--slate-900);
    font-size: 20px;
    font-weight: 700;
}

.left_inbox,
.right_inbox {
    float: none;
    width: auto;
    max-width: 100%;
}

.inner_msgs,
.inner_msgs_replies {
    width: 100%;
    max-width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    table-layout: fixed;
}

.inner_msgs_replies {
    margin-top: 8px;
    background: var(--surface-muted);
}

.inner_msgs td,
.inner_msgs_replies td {
    padding: 8px;
    border-bottom: 1px solid var(--slate-100);
    color: var(--slate-700);
}

#msg_box_right form table,
#msg_box_right .table_compose {
    width: 100% !important;
    max-width: 100%;
    table-layout: fixed;
}

#msg_box_right form table td,
#msg_box_right .table_compose td {
    padding: 7px;
    vertical-align: top;
}

#msg_box_right form table td:first-child {
    width: 30%;
    font-weight: 700;
}

#Msg_On_Order,
#Msg_No_Order,
#Msg_To_Department,
#Msg_To_Writer,
#Msg_To_Client {
    width: 100%;
    max-width: 100%;
    margin-top: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-muted);
}

#msg_box_right form input[type="text"],
#msg_box_right form input[type="password"],
#msg_box_right form input[type="email"],
#msg_box_right form select {
    width: 100%;
    max-width: 100%;
    margin-right: 0;
}

#msg_box_right textarea {
    width: 100% !important;
    min-height: 140px;
}

#msg_box_right form input[type="file"] {
    width: 100%;
    margin-right: 0;
}

#msg_box_right label {
    color: var(--slate-700);
}

/* Registration is outside #main-content and needs its own surface. */
body > table[style*="max-width:960px"] {
    width: calc(100% - 32px) !important;
    max-width: 1080px !important;
    margin: 24px auto !important;
    padding: 28px !important;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    table-layout: fixed;
}

body > table[style*="max-width:960px"] h1 {
    margin: 0 0 12px;
    color: var(--slate-900);
    font-size: 30px;
    line-height: 1.25;
}

body > table[style*="max-width:960px"] h3 {
    color: var(--slate-700);
}

#academic_writing {
    width: 100%;
    max-width: 100%;
    margin-top: 22px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-muted);
}

.signup_headings {
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
    color: var(--slate-900);
    font-size: 23px;
    line-height: 1.35;
    text-align: left;
}

.section_headings_academic,
.section_headings {
    float: none;
    margin: 8px 0;
    padding: 0;
    color: var(--slate-900);
    font-size: 19px;
    font-style: normal;
    font-weight: 700;
}

#register {
    width: 100% !important;
    max-width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    table-layout: fixed;
}

#register > tbody > tr > th,
#register > tbody > tr > td {
    min-width: 0;
    padding: 10px;
    border-bottom: 1px solid var(--slate-100);
    color: var(--slate-700);
    text-align: left;
    vertical-align: top;
    overflow-wrap: anywhere;
}

#register > tbody > tr > th {
    width: 220px !important;
    font-weight: 700;
}

#register > tbody > tr > th[colspan] {
    width: 100% !important;
    background: var(--surface-muted);
}

#register table {
    max-width: 100%;
}

#register input[type="text"],
#register input[type="password"],
#register input[type="email"],
#register select {
    max-width: 100%;
}

#register textarea {
    width: 100% !important;
}

#confirmMessage {
    display: block;
    max-width: 100%;
    margin-top: 6px;
    overflow-wrap: anywhere;
}

#register .checkboxes,
.checkboxes {
    display: inline-flex;
    align-items: center;
    float: none;
    gap: 6px;
    width: auto;
    min-width: 150px;
    height: auto;
    min-height: 34px;
    margin: 0 12px 4px 0;
    color: var(--slate-700);
}

#register .avbutton,
.avbutton {
    float: none;
}

/* Payment preferences retain their existing controls with the shared palette. */
.preferences-page,
.dashboard-container {
    color: var(--text);
}

.dashboard-container .btn-save {
    border: 1px solid var(--blue-600);
    background: var(--blue-600);
    font-family: "Lato", sans-serif;
}

.dashboard-container .btn-save:hover {
    border-color: var(--blue-700);
    background: var(--blue-700);
}

.dashboard-container .alert {
    width: 100%;
    min-width: 0;
    max-width: 100%;
}

/* Standalone success/error and missing-page messages. */
body > p:only-of-type,
body > p:last-child {
    max-width: 720px;
}

@media (max-width: 1100px) {
    table.responsive-static.responsive-ready,
    table.responsive-static.responsive-ready tbody {
        display: block;
        width: 100% !important;
        border: 0;
        background: transparent;
    }

    table.responsive-static.responsive-ready tr.responsive-header-row {
        display: none;
    }

    table.responsive-static.responsive-ready tbody tr {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0 12px;
        width: 100%;
        margin-bottom: 10px;
        padding: 8px 12px;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        background: var(--surface);
        box-shadow: var(--shadow-xs);
    }

    table.responsive-static.responsive-ready tbody td {
        display: block;
        width: auto !important;
        padding: 8px 0;
        border: 0;
        border-bottom: 1px solid var(--slate-100);
        background: transparent;
    }

    table.responsive-static.responsive-ready tbody td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 2px;
        color: var(--slate-600);
        font-size: 10px;
        font-weight: 700;
        letter-spacing: 0.06em;
        text-transform: uppercase;
    }

    table.responsive-static.responsive-ready tbody tr.responsive-span,
    table.responsive-static.responsive-ready tbody td[colspan] {
        grid-column: 1 / -1;
    }

    table.responsive-static.responsive-ready tbody tr.responsive-empty-row {
        display: none;
    }

    #msg_menu ul {
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
    }

    #msg_menu ul li {
        margin: 0;
    }

    .order_created,
    .order_created > tbody,
    .order_created > tbody > tr,
    .order_created > tbody > tr > td {
        display: block;
        width: 100% !important;
    }

    .order_created > tbody > tr > td:first-child,
    .order_created > tbody > tr > td:nth-child(2),
    .order_created > tbody > tr > td[rowspan] {
        width: 100% !important;
    }

    .order_created > tbody > tr > td[rowspan] {
        border-bottom: 2px solid var(--border);
        background: var(--surface-muted);
    }

    .tabs > div > div[id] table,
    .tabs > div > div[id] tbody,
    .tabs > div > div[id] tr,
    .tabs > div > div[id] td,
    .myaccount table,
    .myaccount tbody,
    .myaccount tr,
    .myaccount td,
    .forms,
    .forms tbody,
    .forms tr,
    .forms td {
        display: block;
        width: 100% !important;
        max-width: 100%;
    }

    .tabs > div > div[id] input[type="text"],
    .tabs > div > div[id] input[type="password"],
    .tabs > div > div[id] input[type="email"],
    .tabs > div > div[id] input[type="number"],
    .tabs > div > div[id] select {
        width: 100% !important;
        max-width: 100%;
        margin-right: 0;
    }

    .myaccount input[type="text"],
    .myaccount input[type="password"],
    .myaccount input[type="email"],
    .myaccount input[type="file"],
    .myaccount select,
    .forms input[type="text"],
    .forms input[type="password"],
    .forms input[type="email"],
    .forms input[type="file"],
    .forms select {
        margin-right: 0;
    }

    .myaccount td,
    .forms td {
        padding: 5px 0;
        border: 0;
    }
}

@media (max-width: 760px) {
    #order_body {
        padding: 12px;
    }

    #order_body form > table,
    #order_body form > table > tbody,
    #order_body form > table > tbody > tr,
    #order_body form > table > tbody > tr > td {
        display: block;
        width: 100% !important;
    }

    #order_body form > table > tbody > tr > td {
        padding: 5px 8px;
        border: 0;
    }

    #order_body form > table table,
    #order_body form > table table tbody,
    #order_body form > table table tr,
    #order_body form > table table td {
        display: block;
        width: 100% !important;
        max-width: 100%;
        padding: 3px 0;
        border: 0;
    }

    #order_body input[type="text"],
    #order_body input[type="number"],
    #order_body select {
        width: 100% !important;
        max-width: 100%;
        margin-right: 0;
    }

    #msg_box_right {
        padding: 10px;
    }

    #msg_box_right form table,
    #msg_box_right form table > tbody,
    #msg_box_right form table > tbody > tr,
    #msg_box_right form table > tbody > tr > td,
    #msg_box_right .table_compose,
    #msg_box_right .table_compose > tbody,
    #msg_box_right .table_compose > tbody > tr,
    #msg_box_right .table_compose > tbody > tr > td,
    .order_created .table_compose,
    .order_created .table_compose > tbody,
    .order_created .table_compose > tbody > tr,
    .order_created .table_compose > tbody > tr > td {
        display: block;
        width: 100% !important;
    }

    #msg_box_right form table td,
    #msg_box_right .table_compose td,
    .order_created .table_compose td {
        padding: 5px 0;
    }

    #msg_box_right form table td:first-child,
    .order_created .table_compose td:first-child {
        width: 100% !important;
    }

    .order_created .table_compose input[type="submit"] {
        margin: 6px 0;
    }

    .inner_msgs_replies {
        padding-left: 12px;
    }

    body > table[style*="max-width:960px"] {
        width: calc(100% - 16px) !important;
        margin: 8px auto !important;
        padding: 16px !important;
    }

    body > table[style*="max-width:960px"] h1 {
        font-size: 25px;
    }

    #academic_writing {
        padding: 12px;
    }

    #register,
    #register > tbody,
    #register > tbody > tr,
    #register > tbody > tr > th,
    #register > tbody > tr > td {
        display: block;
        width: 100% !important;
    }

    #register > tbody > tr > th,
    #register > tbody > tr > td {
        padding: 6px 8px;
        border: 0;
    }

    #register > tbody > tr > th[colspan] {
        margin-top: 8px;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
    }

    #register table,
    #register table > tbody,
    #register table > tbody > tr,
    #register table > tbody > tr > td {
        display: block;
        width: 100% !important;
        max-width: 100%;
        padding: 0;
        border: 0;
    }

    #register input[type="text"],
    #register input[type="password"],
    #register input[type="email"],
    #register input[type="file"],
    #register select {
        width: 100% !important;
        max-width: 100%;
        margin-right: 0;
    }

    #register .checkboxes,
    .checkboxes {
        display: flex;
        min-width: 0;
        margin-right: 0;
    }
}

@media (max-width: 520px) {
    .popbox .box {
        position: fixed;
        top: 24px !important;
        left: 16px !important;
        width: calc(100vw - 32px);
        max-width: calc(100vw - 32px);
        margin: 0;
    }

    table.responsive-static.responsive-ready tbody tr {
        grid-template-columns: 1fr;
    }

    .tabs ul.tabNavigation li,
    .tabs ul.tabNavigation li a {
        width: 100%;
    }

    #msg_menu ul {
        display: block;
    }

    #msg_menu ul li a {
        display: block;
    }
}
