/**
 * Heart Collection - Styles
 * NetDynamic v1.2.0-beta
 * Mobile-first. Full hearts = red (3D gradient), lone halves = colored.
 */

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    background: #fff5e6;
    color: #4a3520;
    min-height: 100vh;
}

/* ========== APP WRAPPER (list view) ========== */
.app-wrapper {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding: 0 10px 40px;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 2px solid #f0c36d;
    margin-bottom: 15px;
    background: linear-gradient(135deg, #fff8e7, #ffecd2);
    border-radius: 0 0 15px 15px;
    box-shadow: 0 2px 8px rgba(218,165,32,0.15);
}

.top-bar h1 { font-size: 20px; color: #c0392b; }
.top-bar-actions { display: flex; gap: 8px; }

.icon-btn {
    width: 36px; height: 36px;
    border-radius: 50%;
    border: 2px solid #f0c36d;
    background: #fff; color: #d4a017;
    font-size: 18px; font-weight: bold;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.search-bar { margin-bottom: 12px; }
.search-bar input {
    width: 100%; padding: 12px 15px;
    border: 2px solid #f0c36d; border-radius: 15px;
    font-size: 15px; background: #fff; color: #4a3520; outline: none;
}
.search-bar input::placeholder { color: #c4a876; }

/* ========== FANS GRID ========== */
.fans-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center; padding: 60px 20px; color: #b08c5a;
}
.empty-state p { margin-bottom: 5px; font-size: 15px; }

.fan-card {
    background: #fff; border-radius: 18px; padding: 8px;
    text-align: center; cursor: pointer;
    box-shadow: 0 3px 12px rgba(180,140,60,0.18);
    border: 2px solid #f5deb3;
    transition: transform 0.15s;
}
.fan-card:active { transform: scale(1.03); }

.fan-card .fan-name {
    font-size: 12px; font-weight: bold; color: #6b4226;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-bottom: 4px;
}

.fan-card .duck-container {
    position: relative; display: flex; justify-content: center;
}
.fan-card .duck-img { width: 110px; height: 120px; object-fit: contain; }
.fan-card .card-hearts-grid {
    position: absolute; top: 48%; left: 50%;
    transform: translate(-50%, -50%);
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 2px; width: 76px;
}
.fan-card .card-hearts-grid .heart-svg { width: 22px; height: 22px; }

.fan-card .heart-count {
    font-size: 11px; color: #b08c5a; font-weight: 600; margin-top: 2px;
}

/* ========== DISPLAY MODE ========== */
.display-mode {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: transparent;
    z-index: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.display-back-btn {
    position: fixed; top: 10px; left: 10px;
    width: 40px; height: 40px;
    border-radius: 50%; border: 2px solid #f0c36d;
    background: rgba(255,255,255,0.9); color: #6b4226;
    font-size: 20px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    z-index: 510;
}

.display-admin-btn {
    position: fixed; top: 10px; right: 10px;
    width: 40px; height: 40px;
    border-radius: 50%; border: 2px solid #f0c36d;
    background: rgba(255,255,255,0.9); color: #d4a017;
    font-size: 20px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    z-index: 510;
}

.display-fan-name {
    position: absolute;
    top: 6%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 36px;
    font-weight: 900;
    color: #fff;
    text-align: center;
    white-space: nowrap;
    z-index: 5;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, rgba(74, 40, 16, 0.8), rgba(120, 60, 20, 0.75));
    padding: 6px 22px 6px 7px;
    border-radius: 48px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    border: 2px solid rgba(240, 195, 109, 0.5);
    box-shadow: 0 4px 15px rgba(0,0,0,0.25);
    display: flex;
    align-items: center;
    gap: 12px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.display-avatar {
    width: 53px;
    height: 53px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #f0c36d;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.display-duck-wrap {
    position: relative;
    width: 100%;
}

.display-duck-img {
    width: 100%;
    height: auto;
    display: block;
}

/* Hearts grid: overlaid on duck's chest & belly */
.display-hearts-grid {
    position: absolute;
    top: calc(58% + 75px);
    left: 50%;
    transform: translate(-50%, -50%);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    width: calc(100% - 16px);
    max-width: calc(100vw - 16px);
    left: 50%;
}

.display-heart-slot {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: -12px;
}

.display-heart-slot:nth-child(-n+3) {
    margin-top: 0;
}

.display-heart-slot .heart-svg {
    width: 100%;
    height: auto;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.15));
}

/* Label text written ON the heart */
.display-heart-slot .heart-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    line-height: 1.15;
    pointer-events: none;
    width: 85%;
}

.display-heart-slot .heart-label .heart-label-date {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

.display-heart-slot .heart-label .heart-label-reason {
    display: block;
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.display-heart-count {
    font-size: 18px; font-weight: bold; color: #6b4226;
    text-align: center;
    margin-top: 8px; padding-bottom: 8px;
}

.display-spare {
    font-size: 13px; color: #b08c5a;
    text-align: center; font-style: italic;
    padding-bottom: 80px;
}

/* ========== ADMIN DRAWER (bottom sheet) ========== */
.admin-drawer {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    max-height: 55vh;
    background: #fff;
    z-index: 600;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    animation: drawerUp 0.25s ease-out;
}

@keyframes drawerUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.admin-drawer-handle {
    display: flex; align-items: center;
    padding: 10px 16px 8px;
    border-bottom: 2px solid #f5deb3;
    flex-shrink: 0;
}

.handle-bar {
    width: 40px; height: 4px;
    background: #ddd; border-radius: 2px;
    position: absolute; left: 50%; transform: translateX(-50%);
    top: 6px;
}

.admin-title {
    flex: 1;
    font-size: 15px; font-weight: bold; color: #c0392b;
}

.admin-close-btn {
    background: none; border: none;
    font-size: 26px; color: #b08c5a; cursor: pointer;
    padding: 0 4px; line-height: 1;
}

.admin-drawer-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px 16px 20px;
}

.admin-row {
    display: flex; gap: 8px; margin-bottom: 8px;
}

.admin-field {
    flex: 1; display: flex; flex-direction: column;
}

.admin-field label,
.admin-drawer-body > .control-row label,
.admin-drawer-body > .heart-history > label {
    font-size: 12px; font-weight: 600; color: #6b4226;
    margin-bottom: 4px; display: block;
}

.admin-drawer-body input[type="text"],
.admin-drawer-body input[type="date"],
.admin-drawer-body select {
    width: 100%; padding: 10px 12px;
    border: 2px solid #f0c36d; border-radius: 10px;
    font-size: 14px; background: #fffbf0; color: #4a3520;
    outline: none; margin-bottom: 8px;
    -webkit-appearance: none; appearance: none;
}

.admin-drawer-body select { appearance: auto; }

/* ========== ADMIN ACTION BUTTONS ========== */
.admin-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 8px;
}

.admin-actions .btn {
    padding: 12px 8px;
    border-radius: 10px;
    font-size: 14px; font-weight: 600;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 4px;
    min-height: 44px;
}

.btn-add-full {
    border: 2px solid #e63946; background: #fdeef0; color: #9b1b30;
}
.btn-add-half {
    border: 2px solid #ff69b4; background: #fff0f6; color: #c0507a;
}
.btn-remove {
    border: 2px solid #e8c6c6; background: #fff5f5; color: #c0392b;
}

/* ========== REDEEM ========== */
.btn-redeem {
    width: 100%; padding: 12px;
    border-radius: 10px; border: 2px solid #f0c36d;
    background: linear-gradient(135deg, #ffecd2, #fff8e7);
    color: #6b4226; font-size: 14px; font-weight: bold;
    cursor: pointer; margin-bottom: 10px;
    display: flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-redeem:disabled { opacity: 0.35; cursor: not-allowed; }

/* ========== COLOR PICKER ========== */
.control-row { margin-bottom: 10px; }
.color-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.color-dot {
    width: 32px; height: 32px;
    border-radius: 50%; cursor: pointer;
    border: 3px solid transparent;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.color-dot.selected {
    border-color: #4a3520;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #4a3520;
}

/* ========== HEART HISTORY ========== */
.heart-history { margin-bottom: 10px; }
.history-list {
    max-height: 150px; overflow-y: auto;
    background: #fffbf0; border-radius: 10px; border: 1px solid #f5deb3;
}
.history-item {
    display: flex; align-items: center;
    padding: 6px 10px; border-bottom: 1px solid #f5eed8;
    gap: 6px; font-size: 12px;
}
.history-item:last-child { border-bottom: none; }
.history-item .history-heart { font-size: 14px; flex-shrink: 0; }
.history-item .history-info { flex: 1; min-width: 0; }
.history-item .history-reason { font-weight: 600; color: #6b4226; }
.history-item .history-note { font-size: 10px; color: #b08c5a; }
.history-item .history-date { font-size: 10px; color: #b08c5a; flex-shrink: 0; }
.history-item .history-delete {
    background: none; border: none; color: #e74c3c;
    cursor: pointer; font-size: 16px; padding: 0 4px; opacity: 0.5;
}
.history-item .history-delete:active { opacity: 1; }

.no-history {
    text-align: center; padding: 15px; color: #b08c5a; font-style: italic;
}

/* ========== ADMIN NOTES ========== */
.admin-notes {
    margin-bottom: 10px;
}
.admin-notes label {
    font-size: 12px; font-weight: 600; color: #6b4226;
    margin-bottom: 4px; display: block;
}
.admin-notes textarea {
    width: 100%; padding: 10px 12px;
    border: 2px solid #f0c36d; border-radius: 10px;
    font-size: 13px; background: #fffbf0; color: #4a3520;
    outline: none; resize: vertical; font-family: inherit;
    margin-bottom: 6px;
    -webkit-appearance: none; appearance: none;
}
.btn-save-notes {
    padding: 8px 16px; border-radius: 10px;
    border: 2px solid #f0c36d;
    background: linear-gradient(135deg, #ffecd2, #fff8e7);
    color: #6b4226; font-size: 12px; font-weight: bold;
    cursor: pointer; width: 100%;
}

/* ========== HEART TOTAL ========== */
.heart-total {
    text-align: center; padding: 8px;
    background: linear-gradient(135deg, #fff8e7, #ffecd2);
    border-radius: 10px; font-weight: bold; color: #c0392b;
    font-size: 15px; margin-bottom: 10px;
    border: 2px solid #f0c36d;
}
.heart-total.full-board {
    background: linear-gradient(135deg, #ffd700, #ff6b6b);
    color: #fff; border-color: #ffd700;
}

/* ========== MISC ========== */
.danger-zone {
    text-align: center; padding-top: 8px;
    border-top: 1px dashed #f5c6c6;
}

.btn { border: none; border-radius: 10px; cursor: pointer; font-weight: 600; }
.btn:active { transform: scale(0.97); }
.btn-primary {
    padding: 12px 18px;
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: #fff; font-size: 14px;
}
.btn-block { width: 100%; display: block; }
.btn-small { padding: 8px 14px; font-size: 12px; }
.btn-danger { background: #e74c3c; color: #fff; }

/* ========== MODAL (rules, settings) ========== */
.modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1000;
    display: flex; align-items: flex-end; justify-content: center;
}
.modal-overlay {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
}
.modal-content {
    position: relative; background: #fff;
    border-radius: 20px 20px 0 0;
    width: 100%; max-width: 480px; max-height: 90vh;
    overflow-y: auto;
    animation: drawerUp 0.25s ease-out;
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 15px 18px; border-bottom: 2px solid #f5deb3;
    position: sticky; top: 0; background: #fff; z-index: 10;
    border-radius: 20px 20px 0 0;
}
.modal-header h3 { font-size: 17px; color: #c0392b; }
.close-modal {
    background: none; border: none; font-size: 28px;
    color: #b08c5a; cursor: pointer; padding: 0 5px; line-height: 1;
}
.modal-body { padding: 15px 18px 25px; }

.modal-body input[type="text"] {
    width: 100%; padding: 12px 15px;
    border: 2px solid #f0c36d; border-radius: 12px;
    font-size: 15px; background: #fffbf0; color: #4a3520;
    outline: none; margin-bottom: 10px;
}
.form-group { margin-bottom: 15px; }
.form-group label {
    display: block; font-size: 13px; font-weight: 600;
    color: #6b4226; margin-bottom: 5px;
}
.form-group small {
    display: block; font-size: 11px; color: #b08c5a; margin-top: 3px;
}

.lock-toggle {
    cursor: pointer; font-size: 16px; vertical-align: middle;
    user-select: none; -webkit-user-select: none;
}

.form-group input:disabled {
    opacity: 0.6; background: #f0ead8;
}

/* ========== TOAST ========== */
.toast {
    position: fixed; bottom: 30px; left: 50%;
    transform: translateX(-50%);
    background: #4a3520; color: #fff;
    padding: 10px 20px; border-radius: 25px;
    font-size: 14px; z-index: 2000;
    animation: toastIn 0.3s ease-out;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}
@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #f0c36d; border-radius: 4px; }
