/* Halaman Profil (profile.html). Gaya sama dengan halaman Main & Tonton.
   Selector diawali .profile-body supaya tidak bentrok dengan asset/main.css & css/caturid.css. */
body.profile-body {
    background: radial-gradient(ellipse at center, #3a3a3a 0%, #1e1e1e 100%) !important;
    color: #e8e8e8;
    margin: 0;
}

.profile-body .hidden { display: none !important; }
.profile-body .muted { color: #9a9a9a; font-size: 13px; text-decoration: none; }
.profile-body a.muted:hover { color: #e8e8e8; }

.profile-page {
    max-width: 1100px;
    margin: 20px auto;
    padding: 0 16px;
    box-sizing: border-box;
}

.profile-layout {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}
.profile-body .side-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.profile-body .w-card {
    background: #2b2b2b;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 14px;
}
.profile-body .w-card h3 { margin: 0 0 10px; font-size: 15px; }
.profile-body .card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }

/* ---------- Tombol ---------- */
.profile-body .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 4px;
    background: #444; color: #e8e8e8;
    border: 1px solid #555; border-radius: 4px;
    padding: 8px 12px; font-size: 13px;
    cursor: pointer; text-decoration: none;
    flex: 0 0 auto; font-weight: 400; transition: background 0.15s;
}
.profile-body .btn:hover:not(:disabled) { background: #555; }
.profile-body .btn:disabled { opacity: 0.55; cursor: not-allowed; }
.profile-body .btn-primary { background: #2e7d32; border-color: #2e7d32; color: #fff; }
.profile-body .btn-primary:hover:not(:disabled) { background: #388e3c; }
.profile-body .btn-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.profile-body .btn-row:empty { display: none; }

/* ---------- Kartu identitas ---------- */
.profile-body .profile-card { text-align: center; }
.profile-body .avatar {
    position: relative;
    width: 112px; height: 112px;
    margin: 4px auto 12px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid #444;
    background: #1f1d1b;
}
.profile-body .avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-body .avatar-overlay {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 13px; font-weight: 600;
    opacity: 0; transition: opacity 0.2s;
    pointer-events: none;
}
/* Foto hanya bisa diganti di profil sendiri (ProfileUIManager menambah .editable) */
.profile-body .avatar.editable { cursor: pointer; }
.profile-body .avatar.editable:hover .avatar-overlay { opacity: 1; }
.profile-body .avatar:not(.editable) .avatar-overlay { display: none; }

.profile-body .profile-card h1 { margin: 0; font-size: 22px; word-break: break-word; }
.profile-body .p-status { margin: 4px 0 0; color: #9a9a9a; font-size: 13px; }
.profile-body .p-bio { margin: 12px 0 0; color: #ccc; font-style: italic; font-size: 14px; }
.profile-body .p-city { margin: 8px 0 14px; color: #9a9a9a; font-size: 13px; }
.profile-body .p-status:empty, .profile-body .p-bio:empty { display: none; }

.profile-body .friends-action {
    flex-direction: column; align-items: center; gap: 6px; margin-top: 4px;
}

/* ---------- Rating ---------- */
.profile-body .ratings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.profile-body .rating-box {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    background: #1f1d1b; border-radius: 4px; padding: 10px 6px;
    border-bottom: 2px solid #555;
}
.profile-body .rating-box .r-label { font-size: 12px; color: #9a9a9a; }
.profile-body .rating-box strong { font-size: 20px; font-family: monospace; color: #e8e8e8; }
.profile-body .rating-box.bullet { border-bottom-color: #a6382e; }
.profile-body .rating-box.blitz { border-bottom-color: #f5c342; }
.profile-body .rating-box.rapid { border-bottom-color: #629924; }
.profile-body .rating-box.classical { border-bottom-color: #38bdf8; }

/* ---------- Teman ---------- */
.profile-body .req-count { color: #ff6b6b; font-weight: 700; font-size: 13px; margin-left: 4px; }
.profile-body .group-label { color: #888; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; margin: 6px 0 4px; }
.profile-body .friend-row {
    display: grid; grid-template-columns: 32px minmax(0, 1fr) auto auto auto; gap: 8px; align-items: center;
    padding: 6px 8px; background: #1f1d1b; border-radius: 4px; margin-bottom: 4px; font-size: 14px;
}
.profile-body .friend-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; background: #444; }
.profile-body .friend-name { color: #e8e8e8; text-decoration: none; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-body .friend-name:hover { text-decoration: underline; }
.profile-body .friend-rating { color: #38bdf8; font-family: monospace; font-size: 13px; }
.profile-body .online-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }
.profile-body .online-dot.on { background: #22c55e; }
.profile-body .online-dot.off { background: #555; }
.profile-body .btn-mini { padding: 3px 8px; font-size: 12px; border-radius: 3px; border: 1px solid #555; background: #444; color: #e8e8e8; cursor: pointer; }
.profile-body .btn-mini.btn-accept { background: #2e7d32; border-color: #2e7d32; }
.profile-body .btn-mini.btn-reject, .profile-body .btn-mini.btn-cancel { background: #a33; border-color: #a33; }

/* ---------- Riwayat pertandingan ---------- */
.profile-body #list-history { display: flex; flex-direction: column; gap: 4px; }
.profile-body .history-row {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr) 70px 70px 130px;
    gap: 10px; align-items: center;
    padding: 8px 12px;
    background: #1f1d1b;
    border-left: 3px solid #555; border-radius: 4px;
    font-size: 14px;
}
.profile-body .history-row .h-color { font-size: 18px; text-align: center; }
.profile-body .history-row .h-opponent { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-body .history-row .h-result { font-family: monospace; color: #ccc; }
.profile-body .history-row .h-outcome { font-weight: 600; }
.profile-body .history-row .h-date { color: #888; font-size: 12px; text-align: right; }
.profile-body .history-row.outcome-win { border-left-color: #44cc44; }
.profile-body .history-row.outcome-win .h-outcome { color: #44cc44; }
.profile-body .history-row.outcome-loss { border-left-color: #cc4444; }
.profile-body .history-row.outcome-loss .h-outcome { color: #e05a5a; }
.profile-body .history-row.outcome-draw { border-left-color: #c0a033; }
.profile-body .history-row.outcome-draw .h-outcome { color: #e0c060; }
.profile-body .history-row.clickable { cursor: pointer; transition: background 0.15s; }
.profile-body .history-row.clickable:hover,
.profile-body .history-row.clickable:focus-visible { background: #333; outline: none; }
.profile-body .history-empty { color: #888; padding: 24px 12px; text-align: center; }

/* ---------- Responsif ---------- */
@media (max-width: 900px) {
    .profile-layout { grid-template-columns: 1fr; max-width: 600px; margin: 0 auto; }
}
@media (max-width: 480px) {
    .profile-page { margin: 8px auto; padding: 0 8px; }
    .profile-body .history-row { grid-template-columns: 20px minmax(0, 1fr) 56px 60px; gap: 6px; padding: 8px; }
    .profile-body .history-row .h-date { display: none; }
}
