/* ============================================================
   THAI.CONDOS — Redesign 2026 ACCOUNT layer (phase-05)
   Scope: .rd-account — sidebar shell, dashboard, settings sub-pages.
   Loaded AFTER redesign-tokens + redesign-components.
   ============================================================ */

.rd-account {
    background: var(--color-bg-light);
    font-family: var(--rd-font-body);
    color: var(--color-text-primary-light);
    min-height: 100vh;
    padding: 0 0 64px;
}

/* ── Mobile toggle ───────────────────────────────────────── */
.rd-account__mobile-toggle {
    display: none;
    padding: 14px 16px;
    background: var(--color-accent);
}
.rd-account__toggle {
    color: #fff;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

/* ── Layout grid ─────────────────────────────────────────── */
.rd-account__layout {
    max-width: 1280px;
    margin: 0 auto;
    padding: 32px 24px;
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 28px;
    align-items: start;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.rd-account__sidebar {
    background: #fff;
    border: 1px solid var(--color-border-light);
    border-radius: 14px;
    padding: 24px;
    box-shadow: var(--shadow-card-light);
    position: sticky;
    top: 24px;
}
.rd-account__sidebar-close { display: none; }

.rd-account__profile {
    text-align: center;
    padding-bottom: 20px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--color-border-light);
}
.rd-account__avatar {
    width: 84px; height: 84px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 10px;
    display: block;
    border: 2px solid var(--color-border-light);
}
.rd-account__profile-name {
    font-family: var(--rd-font-display);
    font-size: 17px;
    font-weight: 600;
    color: var(--color-text-primary-light);
    line-height: 1.2;
}
.rd-account__profile-meta {
    font-size: 13px;
    color: var(--color-text-muted-light);
    margin-top: 4px;
}

/* ── Sidebar nav ─────────────────────────────────────────── */
.rd-account__nav ul {
    list-style: none; margin: 0; padding: 0;
}
.rd-account__nav li { margin-bottom: 2px; }
.rd-account__nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--color-text-secondary-light);
    font-size: 14px;
    font-weight: 500;
    transition: background .12s ease, color .12s ease;
}
.rd-account__nav a i { font-size: 17px; }
.rd-account__nav a:hover {
    background: var(--color-bg-cream);
    color: var(--color-text-primary-light);
}
.rd-account__nav li.is-active a {
    background: var(--color-accent);
    color: #fff;
}
.rd-account__nav li.is-active a i { color: #fff; }
.rd-account__nav-badge {
    margin-left: auto;
    background: var(--color-warm);
    color: #fff;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}
.rd-account__nav-logout {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--color-border-light);
}
.rd-account__nav-logout a { color: var(--color-warm); }

/* ── Main content area ──────────────────────────────────── */
.rd-account__main {
    min-width: 0;
}

/* Page header (dashboard + sub-pages) */
.rd-account__page-header {
    margin-bottom: 22px;
}
.rd-account__page-header .rd-eyebrow { margin-bottom: 6px; }
.rd-account__page-header .rd-h2 {
    font-size: clamp(24px, 2.4vw, 32px);
    margin: 0 0 6px;
}
.rd-account__page-sub {
    font-size: 14px;
    color: var(--color-text-secondary-light);
    margin: 0;
}

/* ── Credits strip ───────────────────────────────────────── */
.rd-account__credits-strip {
    background: linear-gradient(135deg, var(--color-warm-soft), #fff);
    border: 1px solid var(--color-border-light);
    border-radius: 14px;
    padding: 18px 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
    gap: 16px;
}
.rd-account__credits-value {
    font-family: var(--rd-font-display);
    font-size: 28px;
    font-weight: 700;
    color: var(--color-warm);
    line-height: 1;
}

/* ── Stat cards ──────────────────────────────────────────── */
.rd-account__stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}
.rd-stat-card {
    position: relative;
    background: #fff;
    border: 1px solid var(--color-border-light);
    border-radius: 14px;
    padding: 22px;
    box-shadow: var(--shadow-card-light);
    transition: transform .12s ease, box-shadow .12s ease;
    overflow: hidden;
    display: block;
}
a.rd-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
    color: inherit;
    text-decoration: none;
}
.rd-stat-card__num {
    font-family: var(--rd-font-display);
    font-size: 36px;
    font-weight: 700;
    color: var(--color-accent);
    line-height: 1;
    margin-bottom: 6px;
}
.rd-stat-card__label {
    font-size: 13px;
    color: var(--color-text-secondary-light);
    line-height: 1.3;
}
.rd-stat-card__icon {
    position: absolute;
    top: 16px; right: 16px;
    font-size: 26px;
    color: var(--color-accent);
    opacity: 0.18;
}
.rd-stat-card--ok .rd-stat-card__num { color: var(--color-success); }
.rd-stat-card--ok .rd-stat-card__icon { color: var(--color-success); }
.rd-stat-card--pending .rd-stat-card__num { color: var(--color-warning); }
.rd-stat-card--pending .rd-stat-card__icon { color: var(--color-warning); }
.rd-stat-card--alert .rd-stat-card__num { color: var(--color-error); }
.rd-stat-card--alert .rd-stat-card__icon { color: var(--color-error); }

/* ── Activity feed ───────────────────────────────────────── */
.rd-account__activity {
    background: #fff;
    border: 1px solid var(--color-border-light);
    border-radius: 14px;
    padding: 22px;
    box-shadow: var(--shadow-card-light);
}

/* ── Settings cards (wraps each sub-page's content) ─────── */
.rd-account .dashboard-wraper,
.rd-account .form-submit {
    background: #fff;
    border: 1px solid var(--color-border-light);
    border-radius: 14px;
    padding: 24px;
    box-shadow: var(--shadow-card-light);
    margin: 0 0 18px;
}
.rd-account .dashboard-wraper h4,
.rd-account .form-submit h4 {
    font-family: var(--rd-font-display);
    font-size: 20px;
    color: var(--color-accent);
    margin: 0 0 18px;
    letter-spacing: -0.01em;
}
.rd-account .form-control {
    border-radius: 10px;
    border-color: var(--color-border-line);
}
.rd-account .form-control:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-dim);
}
.rd-account .btn-theme-light-2,
.rd-account .btn-theme,
.rd-account .btn-primary,
.rd-account button[type="submit"]:not(.btn-warning):not(.btn-danger):not(.btn-success):not(.btn-secondary) {
    border-radius: 10px !important;
    background: var(--color-accent) !important;
    color: #fff !important;
    border: 1px solid var(--color-accent) !important;
    font-weight: 600;
    padding: 10px 20px;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.rd-account .btn-theme-light-2:hover,
.rd-account .btn-theme:hover,
.rd-account .btn-primary:hover,
.rd-account button[type="submit"]:not(.btn-warning):not(.btn-danger):not(.btn-success):not(.btn-secondary):hover {
    background: var(--color-accent-hover) !important;
    border-color: var(--color-accent-hover) !important;
    color: #fff !important;
}
/* Secondary / Close button — use warm-cream outline rather than Bootstrap yellow. */
.rd-account .btn-warning,
.rd-account .btn-secondary {
    border-radius: 10px !important;
    background: transparent !important;
    color: var(--color-fg2) !important;
    border: 1px solid var(--color-border-line) !important;
    font-weight: 600;
    padding: 10px 20px;
}
.rd-account .btn-warning:hover,
.rd-account .btn-secondary:hover {
    background: var(--color-bg-cream) !important;
    color: var(--color-fg1) !important;
    border-color: var(--color-border-light) !important;
}
/* Destructive — warm-red accent */
.rd-account .btn-danger {
    border-radius: 10px !important;
    background: var(--color-warm) !important;
    border: 1px solid var(--color-warm) !important;
    color: #fff !important;
    font-weight: 600;
    padding: 10px 20px;
}
.rd-account .btn-danger:hover {
    background: var(--color-warm-hover) !important;
    border-color: var(--color-warm-hover) !important;
}
/* Success — keep semantic green but tone down to redesign palette */
.rd-account .btn-success {
    border-radius: 10px !important;
    background: var(--color-success) !important;
    border: 1px solid var(--color-success) !important;
    color: #fff !important;
    font-weight: 600;
    padding: 10px 20px;
}

/* ── Datatables in settings pages — minimal restyle ─────── */
.rd-account .dataTables_wrapper .table {
    border: 1px solid var(--color-border-light);
    border-radius: 12px;
    overflow: hidden;
}
.rd-account .dataTables_wrapper thead th {
    background: var(--color-bg-cream);
    color: var(--color-text-primary-light);
    border-bottom: 1px solid var(--color-border-light);
    font-weight: 600;
    font-size: 13px;
    padding: 12px;
}
.rd-account .dataTables_wrapper td {
    padding: 12px;
    vertical-align: middle;
}
.rd-account .table-actions {
    display: inline-flex;
    gap: 4px;
}
.rd-account .table-actions .btn {
    border-radius: 8px;
}

/* ── DataTables-Buttons (.dt-buttons) — reload/reset/etc. ──
   Legacy core/table/css/table.css pins these to teal cyan with
   `color:#fff !important` at high specificity
   (.page-content .dataTables_wrapper .dt-buttons .btn).
   Our .rd-account .btn-secondary override forces a transparent
   background, but the legacy white-text rule wins → invisible
   text + icons on cream surface. Match specificity here. */
.rd-account .page-content .dataTables_wrapper .dt-buttons .btn,
.rd-account .page-content .dataTables_wrapper .dt-buttons .btn-secondary,
.rd-account .dataTables_wrapper .dt-buttons .btn {
    background: #fff !important;
    color: var(--color-text-primary-light) !important;
    border: 1px solid var(--color-border-line) !important;
    border-radius: 10px !important;
    padding: 8px 14px !important;
    font-size: 13px !important;
    font-weight: 600;
    line-height: 1.4 !important;
    box-shadow: none !important;
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.rd-account .page-content .dataTables_wrapper .dt-buttons .btn:hover,
.rd-account .page-content .dataTables_wrapper .dt-buttons .btn:focus,
.rd-account .dataTables_wrapper .dt-buttons .btn:hover {
    background: var(--color-accent) !important;
    border-color: var(--color-accent) !important;
    color: #fff !important;
}
.rd-account .page-content .dataTables_wrapper .dt-buttons .btn i {
    font-size: 13px;
    margin-right: 2px;
}
/* The "+Create" action-item inline button placed by base.blade.php has a
   nested <span data-action="create"> that legacy .table-wrapper .action-item a
   stains `color:#fff !important`. The selector targets <a>, not span — but
   if Bootstrap ever renders the inline button as <a> the rule activates and
   hides the label. Defensive override. */
.rd-account .table-wrapper .action-item,
.rd-account .table-wrapper .action-item a,
.rd-account .table-wrapper .action-item span {
    color: var(--color-text-primary-light) !important;
}
.rd-account .table-wrapper .action-item:hover,
.rd-account .table-wrapper .action-item:hover a,
.rd-account .table-wrapper .action-item:hover span {
    color: var(--color-accent) !important;
}

/* ── Account properties listing — layout polish ──────────────
   The inline +Create button (paid-customisation in base.blade.php
   line 44) sits outside the DataTable and bypasses the canPost gate
   that the DataTables-rendered +Create checks. We can't drop it
   without breaking the agent flow. The DataTables-generated +Create
   uses class .action-item with inner <span data-action="create">
   (NOT .buttons-create — that class is for non-extend buttons).
   Use :has() to target precisely. */
.rd-account .dt-buttons .btn.action-item:has(span[data-action="create"]) {
    display: none !important;
}
/* Promote the inline action-item +Create (direct child of
   .table-responsive) to primary CTA, accent-navy filled. */
.rd-account .table-responsive > button.btn.btn-secondary.action-item {
    background: var(--color-accent) !important;
    border-color: var(--color-accent) !important;
    color: #fff !important;
    border-radius: 10px !important;
    padding: 10px 18px !important;
    font-weight: 600 !important;
    font-size: 13px !important;
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    margin: 0 0 12px !important;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.rd-account .table-responsive > button.btn.btn-secondary.action-item span,
.rd-account .table-responsive > button.btn.btn-secondary.action-item i {
    color: #fff !important;
}
.rd-account .table-responsive > button.btn.btn-secondary.action-item:hover {
    background: var(--color-accent-hover) !important;
    border-color: var(--color-accent-hover) !important;
}
/* Caption paragraph after the inline button — base.blade.php applies
   Bootstrap .pt-5 (padding-top: 3rem ≈ 48px) AND an inline
   style="margin-bottom: 70px". Together that creates ~118px of dead
   space. Crush both with !important. Use .table-responsive descendant
   (not direct child >) since base.blade.php nests p after the button
   inside the same .table-responsive div. */
.rd-account .table-responsive p.pt-5,
.rd-account .table-responsive p.pt-5[style] {
    margin: 0 0 8px !important;
    padding: 0 !important;
    font-size: 12px;
    color: var(--color-text-muted-light);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* Legacy core/table/css/table.css absolutely positions the search input
   and dt-buttons 50px / 46px ABOVE the .dataTables_wrapper top edge.
   That positioning requires a buffer of unused space ABOVE the wrapper
   to fit the floating toolbar — the legacy layout got that buffer from
   the `pt-5 mb-70px` caption above. Now that the caption is tight, the
   abs-positioned toolbar collides with my inline +Create button.
   Restore the buffer by giving the wrapper its own margin-top. */
.rd-account .page-content .dataTables_wrapper {
    margin-top: 56px !important;
}

/* Empty .portlet-title bar
   base.blade.php emits <div class="portlet-title"><div class="caption">
   <div class="wrapper-action"></div></div></div> as a header strip for
   Bulk-Actions + Filters buttons. The agent property table doesn't
   register either, so the wrapper-action is empty — but legacy core
   table.css forces `min-height: 55px` on the title, leaving a 55px
   blue rectangle above the +Create button. Hide when truly empty. */
.rd-account .portlet.portlet-no-padding .portlet-title:has(.wrapper-action:empty) {
    display: none !important;
}
/* Defensive fallback if a future Bootstrap/Botble release breaks :has()
   support — collapse min-height so it doesn't add visual weight. */
.rd-account .portlet.portlet-no-padding .portlet-title {
    min-height: 0 !important;
    padding-left: 0 !important;
}

/* ── Table header refinement ─────────────────────────────────
   DataTables ships sort arrows as background-image on `<th>` with
   built-in padding-right that pushes the title text awkwardly into
   wrapping. Centre the title + arrow, tighten padding, prevent
   wrap on narrow columns. */
.rd-account .dataTables_wrapper thead th {
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 12px !important;
    padding: 14px 10px !important;
    white-space: nowrap;
    text-align: center !important;
}
.rd-account .dataTables_wrapper thead th.text-start {
    text-align: left !important;
}
.rd-account .dataTables_wrapper thead th.sorting,
.rd-account .dataTables_wrapper thead th.sorting_asc,
.rd-account .dataTables_wrapper thead th.sorting_desc {
    padding-right: 24px !important;
}

/* ── Empty-state row polish ──────────────────────────────────
   Legacy renders the "No data to display" row with the default
   .dataTables_empty background (grey strip). Soften it. */
.rd-account .dataTables_wrapper td.dataTables_empty {
    background: #fff !important;
    color: var(--color-text-muted-light) !important;
    padding: 36px 16px !important;
    font-size: 14px;
    font-style: italic;
    text-align: center !important;
    border-bottom: 0;
}

/* ── Search input cleanup ────────────────────────────────────
   The legacy filter input is 250px with a magnifying-glass content
   pseudo glued to the right. Tighten and round it. */
.rd-account .dataTables_wrapper .dataTables_filter input[type="search"] {
    border-radius: 10px;
    border: 1px solid var(--color-border-line);
    padding: 8px 36px 8px 14px;
    font-size: 13px;
    background: #fff;
    height: auto;
    box-shadow: none;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.rd-account .dataTables_wrapper .dataTables_filter input[type="search"]:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-dim);
}

/* ── Avatar modal restyle ────────────────────────────────── */
.rd-account .modal-content {
    border-radius: 14px;
    border: 0;
    box-shadow: var(--shadow-lg);
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 991px) {
    .rd-account__layout { grid-template-columns: 1fr; gap: 18px; padding: 20px 16px; }
    .rd-account__sidebar { position: static; }
    .rd-account__stat-grid { grid-template-columns: repeat(3, 1fr); gap: 12px; }
    .rd-stat-card { padding: 18px; }
    .rd-stat-card__num { font-size: 28px; }
}
@media (max-width: 720px) {
    .rd-account__mobile-toggle { display: block; }
    /* Hide sidebar on mobile until JS toggles simple-sidebar — Resido handles
       the .open_search_menu / .close_search_menu show/hide cycle via app.js. */
    .rd-account__sidebar { display: none; }
    .rd-account__stat-grid { grid-template-columns: 1fr; }
    .rd-account__credits-strip { flex-direction: column; align-items: flex-start; }
}

/* Saved-search filters map (#mapx). The leaflet tile layer overflowed the
   viewport on mobile (~+179px at 360) because the map container and its
   Bootstrap .row/.col wrapper weren't clipped/zeroed. Clip the map and
   neutralise the row's negative gutters inside the account area. */
.rd-account #map_c,
.rd-account #mapx {
    max-width: 100%;
    overflow: hidden;
}
@media (max-width: 720px) {
    .rd-account .submit-section .row { margin-left: 0; margin-right: 0; }
    .rd-account .submit-section .row > [class*="col-"] { padding-left: 0; padding-right: 0; }
    /* The shared account DataTable template (account/table/base.blade.php) sets
       inline overflow-x:inherit so desktop row-action dropdowns can escape the
       container; on a phone that lets a wide table push the page sideways.
       Force horizontal scroll inside the wrapper on mobile (overrides inline). */
    .rd-account .table-responsive { overflow-x: auto !important; }
}

/* Hide the DataTables "Reload" button on the agent property table - Richard
   2026-05-30: the table auto-refreshes on filter, the button is noise. The
   programmatic click in account/table/base.blade.php still works.
   Selector mirrors the .dt-buttons .btn `display: inline-flex !important`
   rule at line 350 so specificity wins (otherwise the 5-class hide loses to
   the 5-class show on the same !important tier). */
.rd-account .page-content .dataTables_wrapper .dt-buttons .btn.buttons-reload {
    display: none !important;
}

/* Move the right Publish column to the bottom of the form as a full-width
   action bar - Save/Publish sits below the form, no side column (Richard
   2026-05-30 regression restore). The right-sidebar's parent is a Bootstrap
   .row inside the form; reorder it to the end + widen both columns. */
.rd-account .row > .col-md-3.right-sidebar {
    flex: 0 0 100%;
    max-width: 100%;
    order: 99;
    margin-top: 24px;
}
.rd-account .row:has(> .col-md-3.right-sidebar) > .col-md-9 {
    flex: 0 0 100%;
    max-width: 100%;
}
