/*
 * Ad-Mailer theme
 * Modern look on top of the existing Bootstrap 2 markup. Loaded after
 * application.css; removing this file restores the original styling.
 */

/* Tokens
   -------------------------------------------------------------------------- */
:root {
    --brand: #176fa6;
    --brand-dark: #0f4c75;
    --brand-darker: #0b3a5a;
    --brand-soft: #eaf3fa;
    --text: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --border-strong: #d1d5db;
    --surface: #ffffff;
    --surface-alt: #f8fafc;
    --page: #f1f4f8;
    --success: #15803d;
    --success-dark: #116632;
    --danger: #dc2626;
    --danger-dark: #b91c1c;
    --warning-bg: #fffbeb;
    --warning-border: #fde68a;
    --warning-text: #92400e;
    --radius: 8px;
    --radius-sm: 6px;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.18);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Base
   -------------------------------------------------------------------------- */
body {
    padding-top: 80px;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--page);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6,
input, button, select, textarea {
    font-family: var(--font);
}

h1, h2, h3, h4 {
    color: var(--brand-darker);
    font-weight: 600;
    letter-spacing: -0.01em;
}

a {
    color: var(--brand);
}

a:hover,
a:focus {
    color: var(--brand-dark);
}

#layout-container {
    width: auto;
    max-width: 1320px;
    padding: 0 24px;
}

/* Page loading overlay (shown by application.js during uploads and sends) */
#loading {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    background: rgba(241, 244, 248, 0.75);
}

#loading .progress {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 240px;
    height: 6px;
    margin: -3px 0 0 -120px;
    border-radius: 3px;
    background: var(--border);
    box-shadow: none;
}

#loading .progress .bar {
    background-color: var(--brand);
    background-image: none;
    box-shadow: none;
}

/* Header
   -------------------------------------------------------------------------- */
.navbar-fixed-top .navbar-inner {
    min-height: 56px;
    padding: 0 24px;
    background: var(--brand-dark);
    background-image: none;
    filter: none;
    border: 0;
    border-radius: 0;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08), 0 2px 8px rgba(16, 24, 40, 0.12);
}

.navbar-inner .span2 {
    width: auto;
    margin: 0;
}

.brand-logo {
    display: flex;
    align-items: center;
    height: 56px;
    color: #fff;
    text-decoration: none;
}

.brand-logo:hover,
.brand-logo:focus {
    color: #fff;
    text-decoration: none;
}

.brand-logo img {
    width: auto;
    height: 40px;
}

.brand-logo span {
    margin-left: 4px;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.navbar-inner .pull-right {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 56px;
    margin: 0;
}

.navbar-inner .pull-right .btn {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.navbar-inner .pull-right .btn:hover,
.navbar-inner .pull-right .btn:focus {
    color: #fff;
    background: rgba(255, 255, 255, 0.2);
}

/* Side menu
   -------------------------------------------------------------------------- */
.nav-list.well {
    width: 200px;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.nav-list > li > a {
    margin: 0;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    color: var(--text);
    text-shadow: none;
    font-weight: 500;
}

.nav-list > li > a:hover,
.nav-list > li > a:focus {
    color: var(--brand-dark);
    background: var(--brand-soft);
}

.nav-list > .active > a,
.nav-list > .active > a:hover,
.nav-list > .active > a:focus {
    color: #fff;
    background: var(--brand);
    text-shadow: none;
}

.nav-list .nav-header {
    margin: 4px 0 6px;
    padding: 0 12px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    text-shadow: none;
}

/* Content area
   -------------------------------------------------------------------------- */
#layout-container > .row-fluid > .span3 {
    width: 224px;
}

#layout-container > .row-fluid > .span9 {
    width: calc(100% - 248px);
    margin-left: 24px;
    min-height: 420px;
    padding: 24px 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}

span.legend,
.page-header {
    display: block;
    margin-bottom: 16px;
    padding-bottom: 0;
    border: 0;
    font-size: 22px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--brand-darker);
}

.header_list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.header_list .pull-left,
.header_list .pull-right {
    float: none;
}

.header_list .pull-right {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.header_list span.legend {
    margin-bottom: 0;
}

.well {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: none;
}

/* Footer */
.footer.pager {
    margin: 24px 0;
    text-align: center;
}

.footer.pager p,
.footer.pager em {
    font-size: 12px;
    font-style: normal;
    color: var(--text-muted);
}

.footer.pager a {
    display: inline;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    color: var(--text-muted);
    text-decoration: underline;
}

/* Buttons
   -------------------------------------------------------------------------- */
.btn {
    padding: 6px 14px;
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
    color: var(--text);
    text-shadow: none;
    background: var(--surface);
    background-image: none;
    filter: none;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:hover,
.btn:focus {
    color: var(--text);
    background: var(--surface-alt);
    background-position: 0 0;
    border-color: var(--border-strong);
}

.btn:focus {
    outline: 0;
    box-shadow: 0 0 0 3px rgba(23, 111, 166, 0.25);
}

.btn.active,
.btn:active {
    background-image: none;
    box-shadow: inset 0 1px 2px rgba(16, 24, 40, 0.1);
}

.btn-small {
    padding: 4px 10px;
    font-size: 13px;
}

.btn-primary,
.btn-success,
.btn-danger,
.btn-info,
.btn-warning,
.btn-inverse {
    color: #fff;
    border-color: transparent;
}

.btn-primary { background: var(--brand); }
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active,
.btn-primary.active { color: #fff; background: var(--brand-dark); }

.btn-success { background: var(--success); }
.btn-success:hover,
.btn-success:focus,
.btn-success:active,
.btn-success.active { color: #fff; background: var(--success-dark); }

.btn-danger { background: var(--danger); }
.btn-danger:hover,
.btn-danger:focus,
.btn-danger:active,
.btn-danger.active { color: #fff; background: var(--danger-dark); }

.btn.disabled,
.btn[disabled] {
    opacity: 0.55;
    box-shadow: none;
}

.btn-group > .btn {
    margin-left: 0;
    border-radius: 0;
}

.btn-group > .btn + .btn {
    margin-left: 4px;
}

.btn-group > .btn,
.btn-group > .btn:first-child,
.btn-group > .btn:last-child,
.btn-group > .btn:last-of-type {
    border-radius: var(--radius-sm);
}

/* Tables
   -------------------------------------------------------------------------- */
.table {
    background: var(--surface);
}

.table th,
.table td {
    padding: 10px 12px;
    vertical-align: middle;
    border-top: 1px solid var(--border);
}

.table-condensed th,
.table-condensed td {
    padding: 8px 10px;
}

.table thead th,
.table > th,
table.table > thead > th {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--text-muted);
    background-color: var(--surface-alt);
    border-bottom: 1px solid var(--border);
}

.table-bordered {
    border: 1px solid var(--border);
    border-collapse: separate;
    border-left: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.table-bordered th,
.table-bordered td {
    border-left: 0;
}

.table-bordered thead:first-child tr:first-child > th:first-child,
.table-bordered tbody:first-child tr:first-child > td:first-child,
.table-bordered thead:last-child tr:last-child > th:first-child,
.table-bordered tbody:last-child tr:last-child > td:first-child,
.table-bordered thead:first-child tr:first-child > th:last-child,
.table-bordered tbody:first-child tr:first-child > td:last-child,
.table-bordered thead:last-child tr:last-child > th:last-child,
.table-bordered tbody:last-child tr:last-child > td:last-child {
    border-radius: 0;
}

.table-hover tbody tr:hover > td,
.table-hover tbody tr:hover > th {
    background-color: var(--brand-soft);
}

.table-striped tbody > tr:nth-child(odd) > td,
.table-striped tbody > tr:nth-child(odd) > th {
    background-color: var(--surface-alt);
}

/* DataTables sort arrows sit on the header background */
table.table thead .sorting,
table.table thead .sorting_asc,
table.table thead .sorting_desc {
    background-color: var(--surface-alt);
    padding-right: 24px;
}

div.dataTables_length,
div.dataTables_filter {
    margin-bottom: 12px;
    color: var(--text-muted);
}

div.dataTables_info {
    color: var(--text-muted);
    font-size: 13px;
}

/* Pagination */
.pagination ul {
    box-shadow: none;
}

.pagination ul > li > a,
.pagination ul > li > span {
    margin-left: 4px;
    padding: 4px 12px;
    line-height: 22px;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.pagination ul > li:first-child > a,
.pagination ul > li:last-child > a,
.pagination ul > li:first-child > span,
.pagination ul > li:last-child > span {
    border-radius: var(--radius-sm);
    border-left-width: 1px;
}

.pagination ul > li > a:hover {
    background: var(--brand-soft);
}

.pagination ul > .active > a,
.pagination ul > .active > span {
    color: #fff;
    background: var(--brand);
    border-color: var(--brand);
}

.pagination ul > .disabled > a,
.pagination ul > .disabled > a:hover {
    color: var(--border-strong);
    background: var(--surface);
}

/* Forms
   -------------------------------------------------------------------------- */
label,
.control-label {
    color: var(--text);
    font-weight: 500;
}

select,
textarea,
input[type="text"],
input[type="password"],
input[type="email"],
input[type="search"],
input[type="number"],
input[type="date"],
.uneditable-input {
    height: 22px;
    padding: 6px 10px;
    font-size: 14px;
    line-height: 22px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

select {
    height: 36px;
    padding: 6px 8px;
}

select[multiple],
select[size] {
    height: auto;
}

textarea {
    height: auto;
}

select:focus,
textarea:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="search"]:focus,
input[type="number"]:focus {
    border-color: var(--brand);
    outline: 0;
    box-shadow: 0 0 0 3px rgba(23, 111, 166, 0.18);
}

.form-actions {
    margin-top: 16px;
    padding: 16px 0 0 180px;
    background: none;
    border-top: 1px solid var(--border);
}

.control-group.error input,
.control-group.error select,
.control-group.error textarea {
    border-color: var(--danger);
}

.help-inline,
.help-block,
.errors {
    font-size: 13px;
}

.required:after {
    color: var(--danger);
}

.messagebox,
.multiboxes {
    border-color: var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: none;
}

.multiboxes label {
    overflow: hidden;
}

.multiboxes-on {
    text-shadow: none;
    background-color: var(--brand);
}

/* Alerts
   -------------------------------------------------------------------------- */
.alert {
    padding: 12px 40px 12px 16px;
    color: var(--warning-text);
    text-shadow: none;
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    border-radius: var(--radius);
}

.alert .close {
    top: 0;
    right: -24px;
    opacity: 0.5;
    text-shadow: none;
}

.alert-success {
    color: #14532d;
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.alert-error {
    color: #7f1d1d;
    background: #fef2f2;
    border-color: #fecaca;
}

.alert-info {
    color: #0c4a6e;
    background: #f0f9ff;
    border-color: #bae6fd;
}

/* Modals, popovers, tooltips
   -------------------------------------------------------------------------- */
.modal {
    border: 0;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 18px;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 14px 20px;
    background: var(--surface-alt);
    border-top: 1px solid var(--border);
    border-radius: 0 0 12px 12px;
    box-shadow: none;
}

.modal-backdrop,
.modal-backdrop.fade.in {
    background: #0b1220;
    opacity: 0.45;
}

.popover {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

.popover-title {
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    font-weight: 600;
}

.tooltip-inner {
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    background: #111827;
}

/* jQuery UI date picker
   -------------------------------------------------------------------------- */
.ui-widget {
    font-family: var(--font);
    font-size: 13px;
}

.ui-datepicker {
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

.ui-datepicker .ui-datepicker-header {
    background: var(--surface-alt);
    border: 0;
    border-radius: var(--radius-sm);
}

/* Small screens
   -------------------------------------------------------------------------- */
@media (max-width: 979px) {
    body {
        padding: 0;
    }

    #layout-container {
        padding: 0 12px;
    }

    .navbar-fixed-top {
        margin: 0 -12px 16px;
    }

    .nav-list.well {
        position: static;
        width: auto;
        margin-bottom: 16px;
    }

    #layout-container > .row-fluid > .span3,
    #layout-container > .row-fluid > .span9 {
        width: 100%;
        margin-left: 0;
    }

    #layout-container > .row-fluid > .span9 {
        padding: 16px;
        overflow-x: auto;
    }

    .form-actions {
        padding-left: 0;
    }
}

/* Create / edit ad
   -------------------------------------------------------------------------- */
.ad-builder {
    max-width: 960px;
}

.ad-section {
    margin-bottom: 20px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.ad-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.ad-section-header h3,
.ad-section-header span.legend {
    margin: 0;
    font-size: 17px;
    line-height: 1.3;
}

.ad-section-header .btn {
    margin-left: auto;
    flex: none;
    white-space: nowrap;
}

.ad-step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 600;
    color: var(--brand);
    background: var(--brand-soft);
}

.ad-optional {
    padding: 1px 8px;
    font-size: 12px;
    color: var(--text-muted);
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 999px;
}

/* Zend renders each sub form as dt/dd pairs inside a fieldset */
.ad-builder #details_form-label,
.ad-builder #message_form-label,
.ad-builder #message_form-message-label,
.ad-builder #details_form-type-label,
.ad-builder #details_form-type-element {
    display: none;
}

.ad-builder #details_form-element,
.ad-builder #message_form-element {
    margin: 0;
}

.ad-builder fieldset,
.ad-builder fieldset dl {
    margin: 0;
    padding: 0;
    border: 0;
}

.ad-builder #fieldset-details_form > dl {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: auto auto;
    grid-auto-flow: column;
    column-gap: 16px;
}

.ad-builder #fieldset-details_form dt {
    margin-bottom: 4px;
}

.ad-builder #fieldset-details_form dd {
    position: relative;
    margin: 0;
}

.ad-builder #fieldset-details_form select {
    width: 100%;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}

.ad-builder #fieldset-details_form .errors {
    margin: 4px 0 0;
    padding: 0;
    list-style: none;
    color: var(--danger);
}

.ad-builder .table {
    margin-bottom: 0 !important;
}

.ad-builder .dataTables_wrapper > .row-fluid:first-child,
.ad-builder .dataTables_length,
.ad-builder .dataTables_filter {
    display: none;
}

/* Hide the entry count and pager while a table is still empty */
.ad-builder .dataTables_wrapper:has(.dataTables_empty) > .row-fluid:last-child {
    display: none;
}

.ad-builder .dataTables_info,
.ad-builder .dataTables_paginate {
    margin-top: 10px;
}

.ad-builder .dataTables_empty {
    padding: 18px 12px;
    text-align: center;
    color: var(--text-muted);
}

/* Message editor */
.ad-builder .wysihtml5-toolbar {
    margin: 0 0 8px;
}

.ad-builder .wysihtml5-toolbar > li {
    margin-right: 6px;
}

.ad-builder .wysihtml5-toolbar .btn {
    padding: 4px 10px;
    font-size: 13px;
}

.ad-builder .messagebox,
.ad-builder iframe.wysihtml5-sandbox {
    width: 100% !important;
    height: 160px !important;
    padding: 10px 12px;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}

/* Send buttons */
.ad-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 0 4px;
    border-top: 1px solid var(--border);
}

.ad-actions .btn {
    padding: 8px 18px;
}

@media (max-width: 767px) {
    .ad-builder #fieldset-details_form > dl {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: none;
        grid-auto-flow: row;
    }

    .ad-builder #fieldset-details_form dd {
        margin-bottom: 12px;
    }

    .ad-section {
        padding: 14px;
    }

    .ad-section-header {
        flex-wrap: wrap;
    }
}

/* DataTables keeps its "Processing" box in the flow even when hidden */
.dataTables_wrapper {
    position: relative;
}

.dataTables_processing {
    position: absolute;
    top: 40px;
    left: 50%;
    margin-left: -60px;
    width: 120px;
    padding: 4px 8px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

/* Upload dialogs on the create / edit ad page: labels beside their inputs */
#modal_media .modal-body > dt,
#modal_additional .modal-body > dt {
    display: none;
}

#modal_media .modal-body > dd,
#modal_additional .modal-body > dd {
    margin: 0;
}

#modal_media fieldset,
#modal_additional fieldset {
    margin: 0;
    padding: 0;
    border: 0;
}

#modal_media fieldset dl,
#modal_additional fieldset dl {
    display: grid;
    grid-template-columns: 170px minmax(0, 1fr);
    align-items: center;
    column-gap: 16px;
    row-gap: 10px;
    margin: 0;
}

#modal_media fieldset dl > dt,
#modal_additional fieldset dl > dt {
    text-align: right;
}

#modal_media fieldset dl > dd,
#modal_additional fieldset dl > dd {
    margin: 0;
}

#modal_media fieldset dl input[type="text"],
#modal_media fieldset dl textarea,
#modal_additional fieldset dl input[type="text"],
#modal_additional fieldset dl textarea {
    width: calc(100% - 22px);
    max-width: 380px;
    margin: 0;
}

#modal_media .errors,
#modal_additional .errors {
    margin: 4px 0 0;
    padding: 0;
    list-style: none;
    font-size: 13px;
    color: var(--danger);
}

@media (max-width: 767px) {
    #modal_media fieldset dl,
    #modal_additional fieldset dl {
        grid-template-columns: minmax(0, 1fr);
        row-gap: 4px;
    }

    #modal_media fieldset dl > dt,
    #modal_additional fieldset dl > dt {
        margin-top: 8px;
        text-align: left;
    }
}

#fieldset-media_form .row-fluid > .span6 {
    float: none;
    width: 100%;
    margin-left: 0;
}
