/* nysr.host — dashboard redesign layer.
   Keeps the production palette, typography and iconography, and rebuilds the
   dashboard surface: header, stats, project cards, settings drawer and modals. */

:root {
    --rd-bg: #050506;
    --rd-surface: #0e0e11;
    --rd-surface-2: #141418;
    --rd-surface-3: #1b1b20;
    --rd-border: rgba(255, 255, 255, 0.08);
    --rd-border-strong: rgba(255, 255, 255, 0.16);
    --rd-text: #e8eaed;
    --rd-muted: #9aa0a6;
    --rd-muted-2: #6b7075;
    --rd-accent: #8ab4f8;
    --rd-accent-soft: rgba(138, 180, 248, 0.12);
    --rd-green: #81c995;
    --rd-green-soft: rgba(129, 201, 149, 0.12);
    --rd-yellow: #fdd663;
    --rd-yellow-soft: rgba(253, 214, 99, 0.12);
    --rd-red: #f28b82;
    --rd-red-soft: rgba(242, 139, 130, 0.12);
    --rd-radius: 16px;
    --rd-radius-sm: 10px;
    --rd-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
}

body {
    background:
        radial-gradient(1100px 520px at 12% -8%, rgba(138, 180, 248, 0.09), transparent 60%),
        radial-gradient(900px 460px at 92% 0%, rgba(129, 201, 149, 0.05), transparent 55%),
        var(--rd-bg) !important;
}

/* ----------------------------- topbar ----------------------------- */

body .topbar {
    padding: 14px 28px !important;
    gap: 26px !important;
    background: rgba(5, 5, 6, 0.78) !important;
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--rd-border) !important;
}
body .topbar-logo {
    font-size: 17px !important;
    font-weight: 700 !important;
    letter-spacing: -0.03em !important;
    color: var(--rd-text) !important;
}
body .topbar-nav a {
    padding: 7px 12px !important;
    border-radius: 9px !important;
    font-size: 14px !important;
    color: var(--rd-muted) !important;
}
body .topbar-nav a:hover {
    color: var(--rd-text) !important;
    background: rgba(255, 255, 255, 0.05) !important;
}
body .topbar-user-btn {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid var(--rd-border) !important;
    border-radius: 999px !important;
    padding: 4px 10px 4px 4px !important;
}
body .profile-dropdown {
    background: var(--rd-surface) !important;
    border: 1px solid var(--rd-border) !important;
    border-radius: 12px !important;
    box-shadow: var(--rd-shadow) !important;
}

/* ----------------------------- page ----------------------------- */

.main-content {
    max-width: 1180px !important;
    margin: 0 auto !important;
    padding: 34px 28px 80px !important;
}

.dashboard-header {
    display: flex !important;
    align-items: flex-end !important;
    justify-content: space-between !important;
    gap: 20px !important;
    flex-wrap: wrap !important;
}
.dashboard-header h1 {
    margin: 0 !important;
    font-size: 31px !important;
    font-weight: 650 !important;
    letter-spacing: -0.035em !important;
    color: var(--rd-text) !important;
}
.rd-sub {
    margin: 6px 0 0;
    color: var(--rd-muted);
    font-size: 13.5px;
}

.dashboard-controls {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
}
/* Search: icon button that expands, like the production dashboard. */
.search-btn {
    display: inline-flex !important;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    background: var(--rd-surface) !important;
    border: 1px solid var(--rd-border) !important;
    border-radius: 10px !important;
    color: var(--rd-muted) !important;
    cursor: pointer;
    flex-shrink: 0;
}
.search-btn:hover { background: rgba(255, 255, 255, .06) !important; color: var(--rd-text) !important; }
.search-btn .material-symbols-outlined { font-size: 20px; }

.search-input {
    height: 40px;
    background: var(--rd-surface);
    border: 1px solid var(--rd-border);
    border-bottom-width: 1px;
    border-radius: 10px;
    color: var(--rd-text);
    font-size: 13.5px;
}
.dashboard-controls.search-open .search-input {
    width: 240px !important;
    padding: 0 12px !important;
    opacity: 1 !important;
    border: 1px solid var(--rd-border) !important;
    background: var(--rd-surface) !important;
}
.dashboard-controls.search-open .search-input:focus {
    border-color: rgba(255, 255, 255, .35) !important;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, .08) !important;
}
.dashboard-controls.search-open .search-btn { color: var(--rd-text) !important; }
.search-input::placeholder { color: var(--rd-muted-2) !important; }
@media (max-width: 640px) {
    .dashboard-controls.search-open .search-input { width: 100% !important; }
}

.create-btn-icon {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    height: 40px !important;
    padding: 0 16px !important;
    border: 1px solid transparent !important;
    border-radius: 10px !important;
    background: var(--rd-accent) !important;
    color: #04121f !important;
    font-weight: 600 !important;
    font-size: 13.5px !important;
    cursor: pointer;
    white-space: nowrap;
}
.create-btn-icon:hover { background: #a8c7fa !important; }
.create-btn-icon .material-symbols-outlined { font-size: 18px !important; }

.rd-lang {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    background: var(--rd-surface);
    border: 1px solid var(--rd-border);
    border-radius: 9px;
}
.rd-lang a {
    padding: 4px 9px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 600;
    color: var(--rd-muted);
}
.rd-lang a.on {
    background: rgba(255, 255, 255, 0.09);
    color: var(--rd-text);
}

/* ----------------------------- stats ----------------------------- */

.rd-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin: 26px 0 6px;
}
.rd-stat {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent), var(--rd-surface);
    border: 1px solid var(--rd-border);
    border-radius: var(--rd-radius);
    padding: 16px 18px;
}
.rd-stat-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--rd-muted);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 600;
}
.rd-stat-label .material-symbols-outlined { font-size: 16px; opacity: .8; }
.rd-stat-value {
    margin-top: 8px;
    font-size: 24px;
    font-weight: 650;
    letter-spacing: -0.02em;
    color: var(--rd-text);
}
.rd-stat-sub { color: var(--rd-muted-2); font-size: 12px; margin-top: 2px; }

/* ----------------------------- sections ----------------------------- */

.dashboard-section { padding-top: 4px; }
#favorites-section, #shared-section, #all-projects-section { margin-top: 30px; }

.section-title {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    margin: 0 0 14px !important;
    padding: 0 !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    color: var(--rd-text) !important;
    border: 0 !important;
}
.section-title > .material-symbols-outlined:first-child {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    font-size: 17px;
    color: var(--rd-muted);
}
.section-title .rd-count {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--rd-muted);
    background: rgba(255, 255, 255, 0.06);
    border-radius: 999px;
    padding: 1px 8px;
}
.section-title [id$="-toggle-icon"] {
    margin-left: auto !important;
    font-size: 18px !important;
    color: var(--rd-muted-2) !important;
}

/* ----------------------------- cards ----------------------------- */

.siteList {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)) !important;
    gap: 16px !important;
    align-items: stretch;
}

.rd-card {
    display: flex;
    flex-direction: column;
    gap: 13px;
    padding: 18px;
    background: var(--rd-surface);
    border: 1px solid var(--rd-border);
    border-radius: var(--rd-radius);
    transition: border-color .18s, transform .18s, box-shadow .18s;
    min-width: 0;
}
.rd-card:hover {
    border-color: var(--rd-border-strong);
    transform: translateY(-2px);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
}
.rd-card.is-suspended { opacity: .74; }

.rd-card-top { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.rd-avatar {
    width: 42px; height: 42px; flex-shrink: 0;
    border-radius: 12px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--rd-accent-soft);
    color: var(--rd-accent);
    font-size: 17px; font-weight: 700;
}
.rd-id { min-width: 0; flex: 1; }
.rd-name-row { display: flex; align-items: center; gap: 7px; min-width: 0; }
.rd-name {
    font-size: 16px; font-weight: 600; letter-spacing: -0.01em;
    color: var(--rd-text); text-decoration: none;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rd-name:hover { color: var(--rd-accent); }
.rd-subdomain {
    display: inline-flex; align-items: center; gap: 4px;
    margin-top: 2px; font-size: 12px; color: var(--rd-muted);
    text-decoration: none; max-width: 100%;
}
.rd-subdomain:hover { color: var(--rd-accent); }
.rd-subdomain .material-symbols-outlined { font-size: 13px; opacity: .7; }

.rd-star {
    background: none; border: 0; padding: 4px; border-radius: 7px;
    color: var(--rd-muted-2); cursor: pointer; flex-shrink: 0;
}
.rd-star:hover { background: rgba(255, 255, 255, 0.06); color: var(--rd-yellow); }
.rd-star.on { color: var(--rd-yellow); }

.rd-badge {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 10.5px; font-weight: 600; letter-spacing: .02em;
    padding: 2px 7px; border-radius: 999px;
    background: rgba(255, 255, 255, 0.06); color: var(--rd-muted);
    white-space: nowrap;
}
.rd-badge.red { background: var(--rd-red-soft); color: var(--rd-red); }
.rd-badge.yellow { background: var(--rd-yellow-soft); color: var(--rd-yellow); }
.rd-badge.green { background: var(--rd-green-soft); color: var(--rd-green); }

.rd-shared {
    display: flex; align-items: center; gap: 5px;
    font-size: 11.5px; color: var(--rd-muted);
}
.rd-shared .material-symbols-outlined { font-size: 14px; opacity: .7; }

.rd-domains { display: flex; flex-wrap: wrap; gap: 6px; min-height: 20px; }
.rd-domain {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 8px; border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--rd-border);
    font-size: 11.5px; color: var(--rd-text);
    text-decoration: none; max-width: 100%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rd-domain:hover { border-color: var(--rd-border-strong); }
.rd-domain .material-symbols-outlined { font-size: 13px; color: var(--rd-green); }
.rd-domain.pending, .rd-domain.pending .material-symbols-outlined { color: var(--rd-yellow); }
.rd-domain.none { color: var(--rd-muted-2); background: transparent; border-style: dashed; }
.rd-domain.none .material-symbols-outlined { color: var(--rd-muted-2); }

.rd-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.rd-chip {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 10.5px; font-weight: 600;
    padding: 3px 8px; border-radius: 7px;
    background: rgba(255, 255, 255, 0.045);
    color: var(--rd-muted);
}
.rd-chip .material-symbols-outlined { font-size: 13px; opacity: .8; }
.rd-chip.php { background: var(--rd-accent-soft); color: var(--rd-accent); }
.rd-chip.db { background: var(--rd-green-soft); color: var(--rd-green); }
.rd-chip.off { opacity: .55; }

.rd-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 2px; }
.rd-btn {
    flex: 1;
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    height: 34px; padding: 0 12px;
    border-radius: 9px; border: 1px solid var(--rd-border-strong);
    background: transparent; color: var(--rd-text);
    font-size: 12.5px; font-weight: 600; text-decoration: none; cursor: pointer;
    transition: background .15s, border-color .15s;
}
.rd-btn:hover { background: rgba(255, 255, 255, 0.06); }
.rd-btn.primary { background: var(--rd-accent); border-color: var(--rd-accent); color: #04121f; }
.rd-btn.primary:hover { background: #a8c7fa; }
.rd-btn .material-symbols-outlined { font-size: 16px; }

/* ----------------------------- drawer ----------------------------- */

.rd-drawer-overlay {
    position: fixed; inset: 0; z-index: 900;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
    opacity: 0; pointer-events: none; transition: opacity .2s;
}
.rd-drawer-overlay.open { opacity: 1; pointer-events: auto; }

.rd-drawer {
    position: fixed; top: 0; right: 0; z-index: 901;
    width: min(420px, 94vw); height: 100%;
    display: flex; flex-direction: column;
    background: var(--rd-surface);
    border-left: 1px solid var(--rd-border);
    box-shadow: -24px 0 60px rgba(0, 0, 0, .55);
    transform: translateX(102%);
    transition: transform .22s cubic-bezier(.2, .8, .2, 1);
}
.rd-drawer.open { transform: translateX(0); }

.rd-drawer-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; padding: 18px 18px 16px;
    border-bottom: 1px solid var(--rd-border);
}
.rd-drawer-id { display: flex; align-items: center; gap: 12px; min-width: 0; }
.rd-drawer-id > div > strong { display: block; font-size: 15px; }
.rd-drawer-id > div > span { display: block; font-size: 12px; color: var(--rd-muted); }
.rd-drawer-id > div > span.rd-drawer-server { font-size: 11px; opacity: .85; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.rd-drawer-id .rd-avatar { display: inline-flex !important; align-items: center; justify-content: center; }
.rd-drawer-close {
    background: none; border: 0; color: var(--rd-muted); cursor: pointer;
    width: 32px; height: 32px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
}
.rd-drawer-close:hover { background: rgba(255, 255, 255, .07); color: var(--rd-text); }

.rd-drawer-body { flex: 1; overflow: auto; padding: 14px; }
.rd-drawer-section { margin-bottom: 14px; }
.rd-drawer-section h3 {
    margin: 0 0 5px; padding: 0 8px;
    font-size: 10.5px; font-weight: 600; letter-spacing: .08em;
    text-transform: uppercase; color: var(--rd-muted-2);
}
.rd-item {
    display: flex; align-items: center; gap: 12px;
    width: 100%; padding: 10px;
    background: none; border: 0; border-radius: 10px;
    color: var(--rd-text); text-align: left; text-decoration: none; cursor: pointer;
}
.rd-item:hover { background: rgba(255, 255, 255, .05); }
.rd-item > .material-symbols-outlined { color: var(--rd-muted); font-size: 19px; }
.rd-item-text { flex: 1; min-width: 0; }
.rd-item-text strong { display: block; font-size: 13.5px; font-weight: 500; }
.rd-item-text span { display: block; font-size: 11.5px; color: var(--rd-muted); }
.rd-item > .rd-chev { font-size: 17px !important; color: var(--rd-muted-2); }
.rd-item.danger, .rd-item.danger > .material-symbols-outlined { color: var(--rd-red); }

.rd-drawer-foot { padding: 14px 16px; border-top: 1px solid var(--rd-border); }
.rd-drawer-foot .rd-btn { width: 100%; height: 38px; }
.rd-drawer-foot .rd-btn.danger { color: var(--rd-red); border-color: rgba(242, 139, 130, .35); }
.rd-drawer-foot .rd-btn.danger:hover { background: var(--rd-red-soft); }

/* ----------------------------- modals ----------------------------- */

body .modal-overlay {
    background: rgba(0, 0, 0, 0.72) !important;
    backdrop-filter: blur(6px);
}
body .modal-content {
    background: var(--rd-surface) !important;
    border: 1px solid var(--rd-border) !important;
    border-radius: 16px !important;
    box-shadow: var(--rd-shadow) !important;
    padding: 1.75rem !important;
    max-height: 86vh !important;
}
body .modal-content h2 {
    margin: 0 0 1.1rem !important;
    font-size: 17px !important;
    font-weight: 600 !important;
    letter-spacing: -0.01em !important;
    color: var(--rd-text) !important;
}
body .modal-footer {
    border-top: 1px solid var(--rd-border) !important;
    padding-top: 1rem !important;
    margin-top: 1.25rem !important;
    gap: .6rem !important;
}
body .form-input {
    height: 40px !important;
    padding: 0 12px !important;
    background: var(--rd-bg) !important;
    border: 1px solid var(--rd-border) !important;
    border-radius: 10px !important;
    color: var(--rd-text) !important;
    font-size: 13.5px !important;
}
body .form-input:focus {
    outline: none !important;
    border-color: rgba(138, 180, 248, .55) !important;
    box-shadow: 0 0 0 3px rgba(138, 180, 248, .14) !important;
}
body .form-group label {
    color: var(--rd-muted) !important;
    font-size: 12.5px !important;
    font-weight: 600 !important;
}
body .cta-button {
    height: 38px;
    padding: 0 16px !important;
    border-radius: 9px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
}
body .cancel-btn {
    background: rgba(255, 255, 255, .05) !important;
    border-color: var(--rd-border-strong) !important;
    color: var(--rd-text) !important;
}
body .cancel-btn:hover { background: rgba(255, 255, 255, .09) !important; }

/* Confirmation/dialog content built by the app */
body .modal-content p,
body .modal-content div { color: inherit; }

/* ----------------------------- empty / loading ----------------------------- */

body .empty-list-message {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--rd-muted);
    padding: 2rem 1rem;
    background: var(--rd-surface);
    border: 1px dashed var(--rd-border);
    border-radius: var(--rd-radius);
}

body .skeleton-card {
    background: var(--rd-surface) !important;
    border: 1px solid var(--rd-border) !important;
    border-radius: var(--rd-radius) !important;
}

/* ----------------------------- toasts ----------------------------- */

body .toast {
    background: var(--rd-surface-2) !important;
    border: 1px solid var(--rd-border) !important;
    border-radius: 11px !important;
    box-shadow: var(--rd-shadow) !important;
}

/* ----------------------------- responsive ----------------------------- */

@media (max-width: 900px) {
    .rd-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .main-content { padding: 26px 18px 70px !important; }
}
@media (max-width: 640px) {
    body .topbar { padding: 12px 16px !important; }
    .dashboard-header h1 { font-size: 25px !important; }
    .dashboard-controls { width: 100%; }
    .rd-stats { grid-template-columns: 1fr; }
    .rd-lang { display: none; }
}

/* Header composition */
.rd-head-left { min-width: 0; }
.dashboard-header { align-items: flex-end !important; }
#message { margin: 0 !important; min-height: 0 !important; }
#favorites-section, #shared-section, #all-projects-section { margin-top: 22px !important; }

/* Layout spacing */
.dashboard-section { display: flex !important; flex-direction: column !important; gap: 22px !important; }
#message { display: none !important; }
#favorites-section, #shared-section, #all-projects-section { margin-top: 0 !important; }

/* Keep the settings drawer above the feedback launcher, modals above the drawer */
body .modal-overlay { z-index: 10000 !important; }
body .toast-container { z-index: 10002 !important; }
.rd-drawer-overlay { z-index: 9400; }
.rd-drawer { z-index: 9401; }


/* ---------------- monochrome pass (black & white) ---------------- */

:root {
    --rd-accent: #f4f4f5;
    --rd-accent-soft: rgba(255, 255, 255, 0.10);
}

.create-btn-icon {
    background: #f4f4f5 !important;
    border-color: #f4f4f5 !important;
    color: #0a0a0a !important;
}
.create-btn-icon:hover { background: #ffffff !important; }

.rd-btn.primary {
    background: #f4f4f5 !important;
    border-color: #f4f4f5 !important;
    color: #0a0a0a !important;
}
.rd-btn.primary:hover { background: #ffffff !important; }

.rd-avatar {
    background: var(--rd-avatar-bg, rgba(255, 255, 255, 0.10));
    color: var(--rd-avatar-fg, #f4f4f5);
}
.rd-star:hover, .rd-star.on { color: #f4f4f5 !important; }
.rd-name:hover, .rd-subdomain:hover { color: #ffffff !important; }

.rd-domain .material-symbols-outlined { color: #c9ccd1 !important; }
.rd-domain.pending, .rd-domain.pending .material-symbols-outlined { color: #b9bdc2 !important; }
.rd-chip { background: rgba(255, 255, 255, 0.05); color: #c9ccd1; }
.rd-chip.db { background: rgba(255, 255, 255, 0.07) !important; color: #e8eaed !important; }

.search-input:focus {
    border-color: rgba(255, 255, 255, 0.35) !important;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08) !important;
}
body .form-input:focus {
    border-color: rgba(255, 255, 255, 0.35) !important;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08) !important;
}

.rd-lang a.on { background: rgba(255, 255, 255, 0.14); color: #ffffff; }

/* Red stays only for destructive/suspended semantics. */

/* Topbar avatar and storage bar in monochrome */
body .topbar-pfp { background: #e8eaed !important; color: #0a0a0a !important; }
body .topbar-storage-fill { background: #e8eaed !important; }


/* Language selector inside the settings drawer */
.rd-lang-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 8px; }
.rd-lang-opt {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px; border-radius: 10px;
    border: 1px solid var(--rd-border);
    color: var(--rd-text); text-decoration: none;
    font-size: 13px; font-weight: 500;
}
.rd-lang-opt:hover { background: rgba(255, 255, 255, .05); }
.rd-lang-opt.on { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .3); }
.rd-lang-code {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 20px; border-radius: 5px;
    background: rgba(255, 255, 255, .1);
    font-size: 10px; font-weight: 700; letter-spacing: .04em;
}

/* Leave the footer language switch visible: lift the floating widgets */
body .fb-launcher { bottom: 96px !important; }
.mock-badge { bottom: 96px !important; }

/* Mock badge in the empty strip under the topbar */
.mock-badge {
    top: 74px !important;
    right: 16px !important;
    left: auto !important;
    bottom: auto !important;
}
@media (max-width: 640px) {
    .mock-badge { display: none !important; }
}


/* Clickable card chips (DB / Domain / SFTP) */
button.rd-chip { font-family: inherit; line-height: 1; }
.rd-chip.action {
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, .10);
    background: rgba(255, 255, 255, .04);
    color: #c9ccd1;
    transition: background .15s, border-color .15s, color .15s;
}
.rd-chip.action:hover {
    background: rgba(255, 255, 255, .10);
    border-color: rgba(255, 255, 255, .28);
    color: #ffffff;
}
.rd-chip.action:focus-visible {
    outline: 2px solid rgba(255, 255, 255, .45);
    outline-offset: 1px;
}
.rd-chip.action.db { color: #e8eaed; background: rgba(255, 255, 255, .08); }


/* ============================ MODAL SYSTEM ============================ */

body .modal-overlay {
    background: rgba(0, 0, 0, 0.78) !important;
    backdrop-filter: blur(8px);
    padding: 24px !important;
    align-items: center !important;
}

body .modal-content {
    position: relative;
    background: #0e0e11 !important;
    border: 1px solid rgba(255, 255, 255, 0.10) !important;
    border-radius: 18px !important;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.65) !important;
    padding: 24px !important;
    max-height: min(88vh, 780px) !important;
    overflow-y: auto !important;
    animation: rdModalRise 0.22s cubic-bezier(.2, .8, .2, 1);
}

@keyframes rdModalRise {
    from { opacity: 0; transform: translateY(12px) scale(0.985); }
    to   { opacity: 1; transform: none; }
}

/* Modals with a real header/body/footer: let the sections handle padding */
body .modal-content:has(.modal-header) {
    padding: 0 !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
}
body .modal-content:has(.modal-header) .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: #0e0e11;
    position: sticky;
    top: 0;
    z-index: 2;
}
body .modal-content:has(.modal-header) .modal-header h2 {
    margin: 0 !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    letter-spacing: -0.01em;
}
body .modal-content:has(.modal-header) .modal-body {
    padding: 18px 20px;
    overflow-y: auto;
}
body .modal-content:has(.modal-header) .modal-footer {
    margin: 0 !important;
    padding: 14px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: #0e0e11;
    position: sticky;
    bottom: 0;
    z-index: 2;
}

/* Static modals (rename, share, database, SFTP, prompt) */
body .modal-content > h2 {
    margin: 0 0 20px !important;
    padding-right: 36px;
    font-size: 18px !important;
    font-weight: 600 !important;
    letter-spacing: -0.01em;
}
#renameModal .modal-content,
#shareModal .modal-content,
#dbModal .modal-content,
#sftpModal .modal-content { max-width: 500px !important; }
#backupsModal .modal-content { max-width: 640px !important; }
#confirmModal .modal-content,
#promptModal .modal-content { max-width: 460px !important; }

/* Close X injected into modals that do not have a header */
.rd-modal-x {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 8px;
    background: none;
    color: #9aa0a6;
    cursor: pointer;
    z-index: 3;
}
.rd-modal-x:hover { background: rgba(255, 255, 255, 0.08); color: #e8eaed; }
.rd-modal-x .material-symbols-outlined { font-size: 19px; }

/* Forms inside modals */
body .modal-content .form-group { margin-bottom: 16px !important; }
body .modal-content .form-group label {
    display: block;
    margin-bottom: 7px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    color: #9aa0a6 !important;
}
body .modal-content .form-input {
    height: 42px !important;
    width: 100%;
    box-sizing: border-box;
    padding: 0 12px !important;
    background: #08080a !important;
    border: 1px solid rgba(255, 255, 255, 0.10) !important;
    border-radius: 10px !important;
    color: #e8eaed !important;
    font-size: 13.5px !important;
}
body .modal-content .form-input:focus {
    border-color: rgba(255, 255, 255, 0.38) !important;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08) !important;
}
body .modal-content .form-input[readonly] { color: #c9ccd1 !important; }

/* Footer buttons */
.modal-footer {
    display: flex !important;
    justify-content: flex-end !important;
    gap: 10px !important;
    margin-top: 20px !important;
    padding-top: 0 !important;
    border: 0 !important;
}
.modal-footer .cta-button,
.modal-footer button {
    min-width: 96px;
    justify-content: center;
}
body .cta-button {
    background: #f4f4f5 !important;
    color: #0a0a0a !important;
    border: 1px solid #f4f4f5 !important;
    border-radius: 10px !important;
    font-weight: 600 !important;
    padding: 0 16px !important;
    height: 38px;
}
body .cta-button:hover { background: #ffffff !important; }
body .cancel-btn {
    background: transparent !important;
    color: #c9ccd1 !important;
    border: 1px solid rgba(255, 255, 255, 0.16) !important;
}
body .cancel-btn:hover { background: rgba(255, 255, 255, 0.06) !important; color: #ffffff !important; }

/* Danger buttons declared inline in the app */
body .cta-button[style*="background:#f28b82"],
body .cta-button[style*="background: rgb(242, 139, 130)"] { color: #2a0b09 !important; }

/* Confirm / prompt */
#confirmModal .modal-content,
#promptModal .modal-content { text-align: center; padding: 30px 26px !important; }
#confirmTitle { font-size: 18px !important; margin: 0 0 8px !important; padding: 0 !important; }
#confirmMessage {
    color: #9aa0a6 !important;
    font-size: 13.5px !important;
    line-height: 1.6;
    margin: 0 0 22px !important;
    text-align: center;
}
#confirmIcon {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.10);
    font-size: 26px !important;
    color: #e8eaed !important;
    margin: 0 0 16px !important;
}
#promptTitle { padding: 0 !important; text-align: center; }
#promptInput { margin-bottom: 18px !important; }
#promptModal .modal-content > div { justify-content: center !important; }

/* Collaborator list */
.collaborator-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.collaborator-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    background: #08080a;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    font-size: 13px;
}
.remove-collaborator-btn {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #f28b82;
    cursor: pointer;
}
.remove-collaborator-btn:hover { background: rgba(242, 139, 130, 0.12); }

/* Database rows */
#dbModal .form-group label { text-transform: none; }
#dbModal input[readonly] { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

/* Backups rows keep their inline styles: normalise them */
#backupsList > div > div {
    background: #08080a !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 10px !important;
    margin-bottom: 8px !important;
}
#backupsList .cta-button {
    background: rgba(255, 255, 255, 0.06) !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
    color: #e8eaed !important;
    min-width: 0;
    height: 32px;
}
#backupsList .cta-button:hover { background: rgba(255, 255, 255, 0.12) !important; }

/* Error pages / .htaccess content */
#errorPagesModal .modal-content,
#htaccessModal .modal-content { max-width: 580px !important; }
#htaccessModal code,
#errorPagesModal code {
    background: rgba(255, 255, 255, 0.06);
    padding: 1px 6px;
    border-radius: 5px;
    font-size: 11.5px;
}

/* Danger styling for inline red buttons */
.modal-content [style*="background:#f28b82"],
.modal-content [style*="background: rgba(242, 139, 130"] {
    border-radius: 10px !important;
}

/* Mobile: bottom sheet */
@media (max-width: 640px) {
    body .modal-overlay { padding: 0 !important; align-items: flex-end !important; }
    body .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 92vh !important;
        border-radius: 18px 18px 0 0 !important;
        border-bottom: 0 !important;
        animation: rdModalSheet 0.24s cubic-bezier(.2, .8, .2, 1);
    }
    @keyframes rdModalSheet {
        from { transform: translateY(100%); }
        to   { transform: none; }
    }
    .modal-footer { flex-direction: column-reverse; }
    .modal-footer .cta-button,
    .modal-footer button { width: 100%; }
}


/* Destructive confirm buttons keep the semantic red */
body .cta-button.danger,
body .cta-button[style*="background:#f28b82"],
body .cta-button[style*="background: rgb(242, 139, 130)"] {
    background: #f28b82 !important;
    border-color: #f28b82 !important;
    color: #2a0b09 !important;
}
body .cta-button.danger:hover { background: #f6a39c !important; }


body .modal-content .form-input::placeholder { color: #5f6368 !important; }





/* Static modals: the footer aligns with the fields, like the other buttons */
body .modal-content:not(:has(.modal-header)) .modal-footer {
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-top: 20px !important;
}


/* ----------------------------- routing modal ----------------------------- */

body .rd-route-modal { max-width: 520px !important; }

.rd-route-intro {
    margin: 0 0 16px !important;
    font-size: 13.5px !important;
    line-height: 1.6 !important;
    color: #9aa0a6 !important;
}
.rd-route-intro strong { color: #e8eaed; font-weight: 600; }

.rd-route-options { display: grid; gap: 8px; }

.rd-route-opt {
    display: grid;
    grid-template-columns: 34px 1fr 18px;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px;
    text-align: left;
    background: #0e0e11;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 12px;
    color: #e8eaed;
    cursor: pointer;
    font-family: inherit;
    transition: background .15s, border-color .15s;
}
.rd-route-opt:hover { background: rgba(255, 255, 255, .04); }
.rd-route-opt[aria-checked="true"] {
    background: rgba(255, 255, 255, .07);
    border-color: rgba(255, 255, 255, .55);
}
.rd-route-opt:focus-visible {
    outline: 2px solid rgba(255, 255, 255, .45);
    outline-offset: 1px;
}
.rd-route-opt .rd-route-ic { font-size: 20px; color: #9aa0a6; }
.rd-route-opt[aria-checked="true"] .rd-route-ic { color: #e8eaed; }
.rd-route-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rd-route-text strong { font-size: 13px; font-weight: 600; color: #e8eaed; }
.rd-route-desc { font-size: 11.5px; line-height: 1.45; color: #6b7075; }
.rd-route-check { font-size: 16px !important; opacity: 0; color: #e8eaed; }
.rd-route-opt[aria-checked="true"] .rd-route-check { opacity: 1; }

.rd-route-target { margin-top: 16px; }
.rd-route-target label {
    display: block;
    margin-bottom: 7px;
    font-size: 12.5px;
    font-weight: 600;
    color: #9aa0a6;
}
.rd-route-target .form-input { width: 100%; box-sizing: border-box; }
.rd-route-hint { margin: 7px 0 0 !important; font-size: 11.5px; line-height: 1.45; color: #6b7075; }

.rd-route-error { margin: 12px 0 0 !important; font-size: 12.5px; color: #f28b82; }


/* ------------------------- unified modal polish ------------------------- */

body .modal-content h2 {
    margin: 0 0 14px !important;
    font-size: 18px !important;
    font-weight: 650 !important;
    letter-spacing: -.02em !important;
    padding-right: 34px;
}

body .modal-content .form-group:last-of-type { margin-bottom: 0 !important; }

/* Confirm/prompt dialogs: same breathing room as the rest */
body .modal-content > h2:only-of-type { margin-bottom: 12px !important; }

/* X sits above the content, never under it */
body .modal-content .rd-modal-x { z-index: 5; }

@media (max-width: 640px) {
    body .modal-content { padding: 20px !important; }
}


/* Confirm dialogs: Material-style left alignment, like the rest of the modals */
#confirmModal .modal-content {
    text-align: left !important;
    max-width: 480px !important;
}
#confirmModal #confirmIcon {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    margin: 0 0 12px !important;
    border-radius: 10px;
    background: rgba(255, 255, 255, .06);
    font-size: 21px !important;
}
#confirmModal #confirmTitle {
    margin: 0 0 8px !important;
    font-size: 18px !important;
    font-weight: 650 !important;
    letter-spacing: -.02em !important;
    color: #e8eaed !important;
    padding-right: 34px;
}
#confirmModal #confirmMessage {
    margin: 0 0 22px !important;
    font-size: 13.5px !important;
    line-height: 1.6 !important;
    color: #9aa0a6 !important;
}
#confirmModal #confirmMessage a { color: #e8eaed; }
#confirmModal .modal-content > div:last-child {
    display: flex !important;
    justify-content: flex-end !important;
    gap: .6rem !important;
}


/* Mobile header: title on its own line, controls in a row (the production
   stylesheet stacks them in a column and right-aligns the title). */
@media (max-width: 768px) {
    .dashboard-header {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: flex-end !important;
        justify-content: flex-start !important;
        gap: 14px !important;
    }
    .rd-head-left {
        flex: 1 1 100% !important;
        width: 100% !important;
        min-width: 0;
    }
    .dashboard-controls {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        justify-content: space-between !important;
        width: 100% !important;
        gap: 10px !important;
    }
    .dashboard-controls .search-btn { flex: 0 0 auto; }
    .dashboard-controls .create-btn-icon { flex: 0 0 auto; }
    .dashboard-controls.search-open .search-input {
        flex: 1 1 120px;
        width: auto !important;
        min-width: 0;
        padding: 0 12px !important;
    }
}


/* --------------------- compact modal rhythm --------------------- */

body .modal-content { padding: 20px 22px !important; }

body .modal-content > h2:first-child {
    margin: 0 0 12px !important;
    padding: 0 34px 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    font-size: 17px !important;
}
body .modal-content h2 { font-size: 17px !important; }

body .modal-content .form-group { margin-bottom: 12px !important; }
body .modal-content .form-group label { margin-bottom: 5px !important; }
body .modal-content .form-input { height: 38px !important; }
body .modal-footer { margin-top: 14px !important; padding-top: 12px !important; }
body .modal-content .form-inline { gap: 8px !important; }

/* Dialogs built with customConfirm(..., { html: true }) — custom domains */
#confirmCloseX { display: none !important; }

#confirmModal #confirmIcon {
    margin: 0 0 8px !important;
    font-size: 20px !important;
    width: 36px;
    height: 36px;
}
#confirmModal #confirmTitle { margin: 0 0 6px !important; }
#confirmModal #confirmMessage { margin: 0 0 14px !important; font-size: 13px !important; line-height: 1.55 !important; }
/* customConfirm({ html: true }) keeps white-space: pre-line, which turns the
   template's indentation into blank lines. Normalise it for HTML content. */
#confirmModal #confirmMessage:has(> div) { white-space: normal !important; }
#confirmModal #confirmMessage p { margin: 0 0 10px !important; }
#confirmModal #confirmMessage p:last-child { margin-bottom: 0 !important; }
#confirmModal #confirmMessage > div { line-height: 1.5; }
#confirmModal #confirmMessage .domain-row { padding: 9px 0 !important; }
#confirmModal #confirmMessage div[style*="justify-content:flex-end"] {
    margin-top: 12px !important;
    gap: 8px !important;
}
#confirmModal #confirmMessage .domain-add { height: 36px; }
#confirmModal .modal-content > div:last-child { margin-top: 0 !important; }

/* Backups: compact list rows */
#backupsModal .modal-header { padding-bottom: 10px; margin-bottom: 10px; }
#backupsModal .backup-row { padding: 8px 0 !important; }


/* Icon + label inside modal buttons must share the same centre line */
body .modal-content .cta-button {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    line-height: 1 !important;
}
body .modal-content .cta-button > * {
    vertical-align: middle;
}
body .modal-content .cta-button .material-symbols-outlined {
    font-size: 17px !important;
    line-height: 1 !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
}
#dbDelete-toggle .material-symbols-outlined {
    font-size: 16px !important;
    line-height: 1 !important;
}


/* ----------------------------- backups modal ----------------------------- */

body .modal-header .icon-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0 !important;
    border-radius: 8px;
    color: #9aa0a6 !important;
}
body .modal-header .icon-btn:hover {
    background: rgba(255, 255, 255, .08);
    color: #e8eaed !important;
}

#backupsControls { margin: 0 0 12px !important; }

#manualBackupBtn {
    margin: 0 !important;
    height: 34px !important;
    padding: 0 12px !important;
    font-size: 12.5px !important;
}
#manualBackupBtn .material-symbols-outlined { font-size: 16px !important; }
#backupCountBadge { font-size: 10.5px !important; color: #6b7075 !important; margin-left: 2px !important; }

#backupsFreeHint {
    margin-bottom: 12px !important;
    padding: 8px 12px !important;
    border-radius: 10px !important;
}
#backupsFreeHint p { font-size: 11.5px !important; line-height: 1.5 !important; }

#backupsList { margin-top: 0 !important; }
#backupsList > div > div {
    padding: 10px 12px !important;
    border-radius: 10px !important;
    margin-bottom: 6px !important;
}

/* Icon-only row buttons: square, centred, same size for download and restore */
#backupsList .cta-button {
    width: 32px !important;
    min-width: 32px !important;
    height: 30px !important;
    padding: 0 !important;
    border-radius: 8px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}
#backupsList .cta-button .material-symbols-outlined {
    font-size: 15px !important;
    line-height: 1 !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
}


/* ----------------------------- loading skeletons ----------------------------- */

.rd-skeleton {
    background: #0e0e11;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 176px;
}
.rd-skeleton .sk-top { display: flex; align-items: center; gap: 12px; }
.rd-skeleton .sk-avatar { width: 44px; height: 44px; border-radius: 12px; flex: 0 0 auto; }
.rd-skeleton .sk-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.rd-skeleton .sk-line { height: 10px; border-radius: 6px; width: 70%; }
.rd-skeleton .sk-line.short { width: 45%; }
.rd-skeleton .sk-chips { display: flex; gap: 8px; }
.rd-skeleton .sk-chip { height: 24px; width: 76px; border-radius: 999px; }
.rd-skeleton .sk-actions { display: flex; gap: 8px; margin-top: auto; }
.rd-skeleton .sk-btn { height: 36px; flex: 1; border-radius: 9px; }
.rd-skeleton .sk-avatar,
.rd-skeleton .sk-line,
.rd-skeleton .sk-chip,
.rd-skeleton .sk-btn {
    background: linear-gradient(90deg, rgba(255, 255, 255, .05) 25%, rgba(255, 255, 255, .09) 37%, rgba(255, 255, 255, .05) 63%);
    background-size: 400% 100%;
    animation: rdSk 1.4s ease infinite;
}
@keyframes rdSk {
    0% { background-position: 100% 0; }
    100% { background-position: 0 0; }
}
@media (prefers-reduced-motion: reduce) {
    .rd-skeleton span { animation: none; }
}


/* ----------------------------- project color ----------------------------- */

.rd-colors {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 2px 8px 10px;
}
.rd-color {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    padding: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    transition: transform .12s, border-color .12s, box-shadow .12s;
}
.rd-color:hover { transform: scale(1.08); }
.rd-color.on { border-color: #ffffff; box-shadow: 0 0 0 2px rgba(255, 255, 255, .22); }
.rd-color-auto { background: rgba(255, 255, 255, .10); color: #e8eaed; }
.rd-color-auto .material-symbols-outlined { font-size: 15px; }
.rd-color-custom {
    position: relative;
    overflow: hidden;
    background: conic-gradient(#f28b82, #fdd663, #81c995, #8ab4f8, #c58af9, #ff8bcb, #f28b82);
    color: #0a0a0a;
}
.rd-color-custom input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    opacity: 0;
    cursor: pointer;
}
.rd-color-custom .material-symbols-outlined { font-size: 15px; color: #0a0a0a; pointer-events: none; }
