/* ============================================================================
   Daybreak - Components stylesheet (PR 8 Phase D)
   Modern handbook-spec rules for the customer portal's reusable widgets:
   cards, buttons, forms, tables, modals, badges, labels, dropdowns.

   Loaded LAST in head.php after _tokens.css, variables.css, style.css,
   custom.css, and every page-specific bundle, so its values win the cascade
   on the properties it cares about (radius, shadow, padding, hover/focus
   states). Colors come from the canonical tokens in _tokens.css so the
   active palette (light/dark) flows through automatically.

   Gated on body.theme-new where specificity matters - the legacy theme
   still renders untouched if the kill-switch is flipped.
   ============================================================================ */

/* ---------------------------------------------------------------------------
   Cards (.card, .panel, .card-element, .dashboard-section, .stat-card)
   --------------------------------------------------------------------------- */
body.theme-new .card,
body.theme-new .panel,
body.theme-new .card-element,
body.theme-new .dashboard-section,
body.theme-new .modern-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    transition: box-shadow var(--transition-slow) var(--ease-standard),
                transform   var(--transition-slow) var(--ease-standard);
}

body.theme-new .card:hover,
body.theme-new .panel:hover,
body.theme-new .card-element:hover,
body.theme-new .dashboard-section:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

body.theme-new .panel-heading,
body.theme-new .card-header {
    background-color: var(--bg-elevated);
    border-bottom: 1px solid var(--border-soft);
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
    padding: 1rem 1.5rem;
    color: var(--text-heading);
    font-weight: 600;
}

body.theme-new .panel-body,
body.theme-new .card-body {
    padding: 1.5rem;
    color: var(--text-main);
}

body.theme-new .stat-card {
    background: linear-gradient(135deg,
        var(--bg-card),
        color-mix(in srgb, var(--primary-color) 6%, var(--bg-card)));
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
}

body.theme-new .stat-card::before {
    background: linear-gradient(90deg, var(--primary-color), var(--primary-700));
}

/* ---------------------------------------------------------------------------
   Buttons (.btn, .btn-primary, .btn-default, .btn-danger, .btn-success,
   .btn-info, .btn-warning, .btn-principal)
   --------------------------------------------------------------------------- */
body.theme-new .btn {
    border-radius: var(--radius-md);
    padding: 0.55rem 1.1rem;
    font-weight: 500;
    border: 1px solid transparent;
    transition: background-color var(--transition-speed) var(--ease-standard),
                box-shadow      var(--transition-speed) var(--ease-standard),
                transform       var(--transition-speed) var(--ease-standard),
                color           var(--transition-speed) var(--ease-standard);
}

body.theme-new .btn:focus,
body.theme-new .btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-focus);
}

body.theme-new .btn-primary,
body.theme-new .btn-principal {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--btn-principal-text);
}

body.theme-new .btn-primary:hover:not(:disabled),
body.theme-new .btn-principal:hover:not(:disabled) {
    background-color: var(--primary-700);
    border-color: var(--primary-700);
    color: var(--btn-principal-text);
    transform: translateY(-1px);
    box-shadow: var(--shadow-soft);
}

body.theme-new .btn-default {
    background-color: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-main);
}

body.theme-new .btn-default:hover:not(:disabled) {
    background-color: var(--bg-elevated);
    border-color: var(--border-color);
}

body.theme-new .btn-success {
    background-color: var(--success-color);
    border-color: var(--success-color);
    color: #ffffff;
}

body.theme-new .btn-danger {
    background-color: var(--danger-color);
    border-color: var(--danger-color);
    color: #ffffff;
}

body.theme-new .btn-warning {
    background-color: var(--warning-color);
    border-color: var(--warning-color);
    color: #ffffff;
}

body.theme-new .btn-info {
    background-color: var(--info-color);
    border-color: var(--info-color);
    color: #ffffff;
}

body.theme-new .btn-outline,
body.theme-new .btn-primary.outline {
    background-color: transparent;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

body.theme-new .btn-outline:hover:not(:disabled) {
    background-color: var(--primary-tint);
}

body.theme-new .btn-sm { padding: 0.35rem 0.75rem; font-size: 0.825rem; }
body.theme-new .btn-lg { padding: 0.85rem 1.5rem; font-size: 1.05rem; }

body.theme-new .btn:disabled,
body.theme-new .btn.disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ---------------------------------------------------------------------------
   Forms (.form-control, .form-group, .has-error, .has-success)
   --------------------------------------------------------------------------- */
body.theme-new .form-control,
body.theme-new .input-field,
body.theme-new select.form-control,
body.theme-new textarea.form-control {
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-md);
    color: var(--text-main);
    padding: 0.6rem 0.9rem;
    transition: border-color var(--transition-speed) var(--ease-standard),
                box-shadow   var(--transition-speed) var(--ease-standard);
    box-shadow: none;
}

body.theme-new .form-control::placeholder,
body.theme-new .input-field::placeholder {
    color: var(--input-placeholder);
}

body.theme-new .form-control:focus,
body.theme-new .input-field:focus,
body.theme-new select.form-control:focus,
body.theme-new textarea.form-control:focus {
    border-color: var(--input-focus);
    box-shadow: 0 0 0 3px var(--primary-focus);
    outline: none;
}

body.theme-new .form-group label,
body.theme-new .control-label {
    color: var(--text-heading);
    font-weight: 500;
    margin-bottom: 0.4rem;
}

body.theme-new .has-error .form-control {
    border-color: var(--danger-color);
}

body.theme-new .has-error .form-control:focus {
    box-shadow: 0 0 0 3px var(--danger-tint);
}

body.theme-new .has-error .help-block,
body.theme-new .has-error .control-label,
body.theme-new .text-danger,
body.theme-new .form-error {
    color: var(--danger-color);
}

body.theme-new .has-success .form-control {
    border-color: var(--success-color);
}

body.theme-new .help-block,
body.theme-new .form-text {
    color: var(--text-muted);
    font-size: 0.825rem;
    margin-top: 0.35rem;
}

/* Checkbox + radio quick polish */
body.theme-new input[type="checkbox"],
body.theme-new input[type="radio"] {
    accent-color: var(--primary-color);
}

/* ---------------------------------------------------------------------------
   Tables (.table, .dataTable, .table-striped, .modern-table)
   --------------------------------------------------------------------------- */
body.theme-new .table,
body.theme-new .dataTable,
body.theme-new .modern-table {
    background-color: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    border-collapse: separate;
    border-spacing: 0;
    box-shadow: var(--shadow-sm);
    width: 100%;
}

body.theme-new .table > thead > tr > th,
body.theme-new .dataTable > thead > tr > th,
body.theme-new .modern-table thead th {
    background-color: var(--bg-elevated);
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    font-weight: 600;
    border-bottom: 1px solid var(--border-soft);
    padding: 0.85rem 1rem;
}

body.theme-new .table > tbody > tr > td,
body.theme-new .dataTable > tbody > tr > td,
body.theme-new .modern-table tbody td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-soft);
    color: var(--text-main);
    vertical-align: middle;
}

body.theme-new .table > tbody > tr:last-child > td,
body.theme-new .dataTable > tbody > tr:last-child > td,
body.theme-new .modern-table tbody tr:last-child td {
    border-bottom: none;
}

body.theme-new .table > tbody > tr:hover,
body.theme-new .dataTable > tbody > tr:hover,
body.theme-new .modern-table tbody tr:hover {
    background-color: var(--primary-tint);
}

body.theme-new .table-striped > tbody > tr:nth-of-type(odd) {
    background-color: var(--bg-elevated);
}

/* DataTables search / length / info polish */
body.theme-new .dataTables_wrapper .dataTables_filter input,
body.theme-new .dataTables_wrapper .dataTables_length select {
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-md);
    color: var(--text-main);
    padding: 0.4rem 0.7rem;
}

body.theme-new .dataTables_wrapper .dataTables_paginate .paginate_button {
    color: var(--text-main) !important;
    border: 1px solid var(--border-soft) !important;
    border-radius: var(--radius-md) !important;
    background: var(--bg-card) !important;
    margin: 0 2px;
}

body.theme-new .dataTables_wrapper .dataTables_paginate .paginate_button.current,
body.theme-new .dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--primary-color) !important;
    color: var(--btn-principal-text) !important;
    border-color: var(--primary-color) !important;
}

body.theme-new .dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--primary-tint) !important;
    color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}

/* ---------------------------------------------------------------------------
   Modals (.modal-content, .modal-header, .modal-footer)
   --------------------------------------------------------------------------- */
body.theme-new .modal-content {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-elev);
    color: var(--text-main);
}

body.theme-new .modal-header {
    background-color: var(--bg-elevated);
    border-bottom: 1px solid var(--border-soft);
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
    padding: 1.1rem 1.5rem;
}

body.theme-new .modal-header .modal-title {
    color: var(--text-heading);
    font-weight: 600;
    margin: 0;
}

body.theme-new .modal-header .close {
    color: var(--text-muted);
    opacity: 0.7;
    text-shadow: none;
    font-size: 1.4rem;
}

body.theme-new .modal-header .close:hover { opacity: 1; color: var(--text-main); }

body.theme-new .modal-body   { padding: 1.5rem; color: var(--text-main); }

body.theme-new .modal-footer {
    background-color: var(--bg-elevated);
    border-top: 1px solid var(--border-soft);
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
    padding: 1rem 1.5rem;
}

body.theme-new .modal-backdrop.in {
    opacity: 0.55;
    background: #000;
}

/* ---------------------------------------------------------------------------
   Badges + Labels (.badge, .badge-*, .label, .label-*)
   --------------------------------------------------------------------------- */
body.theme-new .badge,
body.theme-new .label {
    border-radius: var(--radius-full);
    padding: 0.32rem 0.7rem;
    font-weight: 500;
    font-size: 0.72rem;
    letter-spacing: 0.02em;
    display: inline-flex;
    align-items: center;
    line-height: 1;
}

body.theme-new .badge-primary,
body.theme-new .label-primary {
    background-color: var(--primary-tint);
    color: var(--primary-color);
}

body.theme-new .badge-default,
body.theme-new .label-default {
    background-color: var(--bg-elevated);
    color: var(--text-muted);
}

body.theme-new .badge-success,
body.theme-new .label-success {
    background-color: var(--success-tint);
    color: var(--success-color);
}

body.theme-new .badge-danger,
body.theme-new .label-danger,
body.theme-new .badge-error,
body.theme-new .label-error {
    background-color: var(--danger-tint);
    color: var(--danger-color);
}

body.theme-new .badge-warning,
body.theme-new .label-warning {
    background-color: var(--warning-tint);
    color: var(--warning-color);
}

body.theme-new .badge-info,
body.theme-new .label-info {
    background-color: var(--info-tint);
    color: var(--info-color);
}

/* ---------------------------------------------------------------------------
   Dropdowns + notifications
   --------------------------------------------------------------------------- */
body.theme-new .dropdown-menu,
body.theme-new .notifications-dropdown {
    background-color: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-elev);
    padding: 0.4rem;
}

body.theme-new .dropdown-menu > li > a {
    color: var(--text-main);
    border-radius: var(--radius-md);
    padding: 0.55rem 0.85rem;
    transition: background-color var(--transition-speed) var(--ease-standard);
}

body.theme-new .dropdown-menu > li > a:hover,
body.theme-new .dropdown-menu > li > a:focus {
    background-color: var(--primary-tint);
    color: var(--primary-color);
}

body.theme-new .dropdown-divider,
body.theme-new .dropdown-menu .divider {
    background-color: var(--border-soft);
    height: 1px;
    margin: 0.4rem 0;
}

/* ---------------------------------------------------------------------------
   Alerts polish - already in chrome.css but tighten the tint use
   --------------------------------------------------------------------------- */
body.theme-new .alert {
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    padding: 0.85rem 1.15rem;
}

body.theme-new .alert-info    { background: var(--info-tint);    color: var(--info-color);    border-color: color-mix(in srgb, var(--info-color)    20%, transparent); }
body.theme-new .alert-success { background: var(--success-tint); color: var(--success-color); border-color: color-mix(in srgb, var(--success-color) 20%, transparent); }
body.theme-new .alert-warning { background: var(--warning-tint); color: var(--warning-color); border-color: color-mix(in srgb, var(--warning-color) 20%, transparent); }
body.theme-new .alert-danger  { background: var(--danger-tint);  color: var(--danger-color);  border-color: color-mix(in srgb, var(--danger-color)  20%, transparent); }

/* ---------------------------------------------------------------------------
   Inputs - bootstrap-select drop-in (used heavily across forms)
   --------------------------------------------------------------------------- */
body.theme-new .bootstrap-select > .dropdown-toggle {
    background-color: var(--input-bg) !important;
    border: 1px solid var(--input-border) !important;
    border-radius: var(--radius-md) !important;
    color: var(--text-main) !important;
    padding: 0.55rem 0.9rem !important;
}

body.theme-new .bootstrap-select > .dropdown-toggle:focus {
    box-shadow: 0 0 0 3px var(--primary-focus) !important;
    outline: none !important;
}

body.theme-new .bootstrap-select .dropdown-menu li a:hover {
    background-color: var(--primary-tint);
    color: var(--primary-color);
}

/* ---------------------------------------------------------------------------
   Links - subtle hover lift
   --------------------------------------------------------------------------- */
body.theme-new a {
    color: var(--primary-color);
    transition: color var(--transition-speed) var(--ease-standard);
}

body.theme-new a:hover {
    color: var(--primary-700);
}

body.theme-new a.text-muted,
body.theme-new a.text-secondary {
    color: var(--text-muted);
}

body.theme-new a.text-muted:hover,
body.theme-new a.text-secondary:hover {
    color: var(--text-main);
}

/* ---------------------------------------------------------------------------
   Misc surfaces - tighten the .template-content / .content-area card so the
   page hierarchy reads better
   --------------------------------------------------------------------------- */
body.theme-new .template-content {
    background-color: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    padding: 1.75rem;
}

body.theme-new .submenu {
    background-color: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
}

body.theme-new .submenu-link {
    color: var(--text-main);
    border-radius: var(--radius-md);
}

body.theme-new .submenu-link:hover {
    background-color: var(--primary-tint);
    color: var(--primary-color);
    transform: translateY(-1px);
}

/* ---------------------------------------------------------------------------
   PR 8 Phase F.3 - Mobile polish
   Tables overflow horizontally instead of breaking the layout; modals
   become near-full-screen with safe margins; .template-content tightens
   its padding. All gated on body.theme-new.
   --------------------------------------------------------------------------- */
@media (max-width: 991.98px) {
    /* Tables: wrap in scroll container so wide invoices/projects lists
       slide horizontally rather than busting the viewport */
    body.theme-new .table-responsive,
    body.theme-new .dataTables_wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    body.theme-new .table,
    body.theme-new .dataTable,
    body.theme-new .modern-table {
        min-width: 600px;
    }

    /* Cards + dashboard sections: tighten padding */
    body.theme-new .card,
    body.theme-new .panel,
    body.theme-new .card-element,
    body.theme-new .dashboard-section {
        border-radius: var(--radius-md);
    }

    /* Modals: near-full width, sane max */
    body.theme-new .modal-dialog {
        width: calc(100vw - 2rem);
        margin: 1rem auto;
        max-width: 500px;
    }

    /* Template content padding */
    body.theme-new .template-content {
        padding: 1rem;
        border-radius: var(--radius-md);
    }

    /* Form rows: stack labels above fields */
    body.theme-new .form-group .col-md-6 + .col-md-6,
    body.theme-new .form-group .col-md-4 + .col-md-4 {
        margin-top: 0.5rem;
    }
}

/* Pinch-screen polish */
@media (max-width: 576px) {
    body.theme-new .btn {
        padding: 0.5rem 0.85rem;
        font-size: 0.875rem;
    }
    body.theme-new .btn-lg {
        padding: 0.65rem 1.1rem;
        font-size: 0.95rem;
    }
    body.theme-new .page-title h1 {
        font-size: 1.5rem;
    }
}
