/* ===== EARTHGRID - Design System ===== */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap');

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

:root {
    --bg: #FAFBFF;
    --white: #FFFFFF;
    --black: #1a1a2e;
    --gray-1: #F4F4FB;
    --gray-2: #E8E8F4;
    --gray-3: #A0A3BD;
    --gray-4: #6E7191;
    --purple: #7C5CFC;
    --purple-light: #EDE9FF;
    --purple-dark: #5B3FD9;
    --coral: #FF6B6B;
    --coral-light: #FFE5E5;
    --mint: #36D6AD;
    --mint-light: #E0FFF6;
    --yellow: #FFD93D;
    --yellow-light: #FFF9E0;
}

html, body {
    height: 100%;
    font-family: 'Nunito', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--black);
    line-height: 1.5;
}

/* ===== UTILITIES ===== */
.hidden { display: none !important; }

/* ===== BUTTONS ===== */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.95em;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--purple) 0%, var(--purple-dark) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(124, 92, 252, 0.3);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(124, 92, 252, 0.4);
}
.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--gray-1);
    color: var(--gray-4);
    border: 2px solid var(--gray-2);
}
.btn-secondary:hover {
    background: var(--purple-light);
    color: var(--purple);
    border-color: var(--purple);
}

.btn-mint {
    background: linear-gradient(135deg, var(--mint) 0%, #2BC299 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(54, 214, 173, 0.3);
}

.btn-coral {
    background: var(--coral-light);
    color: var(--coral);
}
.btn-coral:hover {
    background: var(--coral);
    color: white;
}

.btn-sm { padding: 8px 16px; font-size: 0.85em; border-radius: 10px; }
.btn-block { width: 100%; }

/* ===== INPUTS ===== */
.input, .textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--gray-1);
    border: 2px solid var(--gray-2);
    border-radius: 12px;
    font-size: 0.95em;
    font-family: inherit;
    color: var(--black);
    outline: none;
    transition: all 0.2s;
}
.input:focus, .textarea:focus {
    border-color: var(--purple);
    background: var(--white);
}
.input::placeholder, .textarea::placeholder { color: var(--gray-3); }

.input-group { margin-bottom: 16px; }
.input-label {
    display: block;
    font-weight: 700;
    font-size: 0.85em;
    color: var(--gray-4);
    margin-bottom: 6px;
}
.input-hint {
    font-size: 0.8em;
    color: var(--gray-3);
    margin-top: 4px;
}

/* ===== HEADER ===== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--white);
    border-bottom: 1px solid var(--gray-2);
    padding: 12px 20px;
    z-index: 100;
}

.header-inner {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--black);
}
.logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--purple) 0%, #9D7BFF 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 10px;
    color: white;
    box-shadow: 0 4px 12px rgba(124, 92, 252, 0.3);
}
.logo-text {
    font-weight: 800;
    font-size: 1.3em;
    background: linear-gradient(135deg, var(--purple) 0%, var(--coral) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-center {
    display: flex;
    align-items: center;
    gap: 20px;
}
.header-stat {
    text-align: center;
}
.header-stat-value {
    font-weight: 800;
    font-size: 1.1em;
    color: var(--purple);
}
.header-stat-label {
    font-size: 0.7em;
    color: var(--gray-3);
    text-transform: uppercase;
    font-weight: 600;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-balance {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--mint-light);
    border-radius: 10px;
    font-weight: 700;
    color: #059669;
    font-size: 0.95em;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 6px;
    background: var(--gray-1);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s;
    border: none;
    font-family: inherit;
}
.user-menu:hover { background: var(--purple-light); }
.user-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--purple) 0%, #9D7BFF 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 11px;
    color: white;
}
.user-name {
    font-weight: 700;
    font-size: 0.9em;
    color: var(--black);
}

/* ===== MAP ===== */
.map-container {
    position: fixed;
    top: 61px;
    left: 0;
    right: 0;
    bottom: 0;
}
#map { width: 100%; height: 100%; }

/* ===== ZOOM HINT ===== */
.zoom-hint {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--black);
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    z-index: 50;
}
.zoom-hint.visible { opacity: 1; visibility: visible; }

/* ===== PANELS ===== */
.panel {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 360px;
    max-width: calc(100vw - 40px);
    background: var(--white);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(26, 26, 46, 0.15);
    border: 2px solid var(--gray-2);
    z-index: 80;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.panel.visible { opacity: 1; visibility: visible; transform: translateY(0); }

.panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-2);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.panel-title { font-weight: 800; font-size: 1.1em; }
.panel-close {
    width: 32px;
    height: 32px;
    background: var(--gray-1);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-4);
    font-size: 1.1em;
    transition: all 0.15s;
}
.panel-close:hover { background: var(--coral-light); color: var(--coral); }

.panel-body { padding: 20px; }

/* Selection Panel */
.selection-count {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--purple-light);
    border-radius: 14px;
    margin-bottom: 16px;
}
.selection-number { font-size: 2em; font-weight: 800; color: var(--purple); }
.selection-label { font-weight: 600; color: var(--gray-4); }
.selection-price { margin-left: auto; font-size: 1.5em; font-weight: 800; color: var(--mint); }

/* Info Panel */
.info-owner {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}
.info-avatar {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 16px;
    color: white;
}
.info-name { font-weight: 800; font-size: 1.1em; }
.info-date { font-size: 0.85em; color: var(--gray-3); }

.info-message {
    background: var(--gray-1);
    padding: 16px;
    border-radius: 14px;
    margin-bottom: 16px;
    font-style: italic;
    color: var(--gray-4);
    border-left: 3px solid var(--purple);
}
.info-message.empty {
    font-style: normal;
    color: var(--gray-3);
    border-left-color: var(--gray-2);
}

.info-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}
.info-detail {
    background: var(--gray-1);
    padding: 12px;
    border-radius: 12px;
    text-align: center;
}
.info-detail-value { font-weight: 800; font-size: 1.1em; }
.info-detail-label {
    font-size: 0.75em;
    color: var(--gray-3);
    text-transform: uppercase;
    font-weight: 600;
}

/* ===== MODALS ===== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(26, 26, 46, 0.7);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}
.modal.show { display: flex; }

.modal-box {
    background: var(--white);
    border-radius: 24px;
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.3s ease;
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-2);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-title {
    font-weight: 800;
    font-size: 1.2em;
    display: flex;
    align-items: center;
    gap: 10px;
}
.modal-close {
    width: 36px;
    height: 36px;
    background: var(--gray-1);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-4);
    font-size: 1.2em;
    transition: all 0.15s;
}
.modal-close:hover { background: var(--coral-light); color: var(--coral); }

.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px 24px; display: flex; gap: 12px; }

/* Claim Modal */
.claim-summary {
    background: linear-gradient(135deg, var(--purple-light) 0%, var(--mint-light) 100%);
    padding: 20px;
    border-radius: 16px;
    margin-bottom: 20px;
    text-align: center;
}
.claim-total { font-size: 2.5em; font-weight: 800; color: var(--purple); }
.claim-detail { font-size: 0.9em; color: var(--gray-4); margin-top: 4px; }

.use-credits {
    background: var(--mint-light);
    border: 2px solid var(--mint);
    padding: 14px 16px;
    border-radius: 12px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.use-credits input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--mint);
}
.use-credits-info { flex: 1; }
.use-credits-label { font-weight: 700; color: #059669; }
.use-credits-balance { font-size: 0.85em; color: var(--gray-4); }

.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}
.color-preview {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    border: 3px solid var(--gray-2);
    flex-shrink: 0;
}
.color-picker-wrapper input[type="color"] {
    flex: 1;
    height: 48px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
}

/* Bid Modal */
.bid-info {
    background: var(--gray-1);
    padding: 16px;
    border-radius: 14px;
    margin-bottom: 20px;
}
.bid-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}
.bid-info-row:not(:last-child) { border-bottom: 1px solid var(--gray-2); }
.bid-info-label { color: var(--gray-4); font-weight: 600; }
.bid-info-value { font-weight: 800; }

/* Auth Modal */
.auth-tabs {
    display: flex;
    background: var(--gray-1);
    padding: 4px;
    border-radius: 12px;
    margin-bottom: 20px;
}
.auth-tab {
    flex: 1;
    padding: 10px;
    background: transparent;
    border: none;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.95em;
    color: var(--gray-4);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
}
.auth-tab.active {
    background: var(--white);
    color: var(--purple);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* ===== TOAST ===== */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--white);
    border: 2px solid var(--gray-2);
    padding: 14px 20px;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(26, 26, 46, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    animation: toastIn 0.3s ease;
    max-width: 360px;
}
@keyframes toastIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

.toast.success { border-color: var(--mint); background: var(--mint-light); color: #059669; }
.toast.error { border-color: var(--coral); background: var(--coral-light); color: var(--coral); }
.toast.info { border-color: var(--purple); background: var(--purple-light); color: var(--purple); }

/* ===== DASHBOARD ===== */
.page-dashboard .map-container { display: none; }
.page-dashboard { padding-top: 61px; }

.dashboard {
    padding: 24px 20px 40px;
    max-width: 1200px;
    margin: 0 auto;
}

.dashboard-header { margin-bottom: 32px; }
.dashboard-title { font-size: 1.8em; font-weight: 800; margin-bottom: 8px; }
.dashboard-subtitle { color: var(--gray-4); }

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}
.stat-card {
    background: var(--white);
    border: 2px solid var(--gray-2);
    border-radius: 16px;
    padding: 20px;
    text-align: center;
}
.stat-card-value { font-size: 2em; font-weight: 800; color: var(--purple); }
.stat-card-value.mint { color: var(--mint); }
.stat-card-label {
    font-size: 0.85em;
    color: var(--gray-3);
    font-weight: 600;
    text-transform: uppercase;
    margin-top: 4px;
}

.dashboard-section {
    background: var(--white);
    border: 2px solid var(--gray-2);
    border-radius: 20px;
    margin-bottom: 24px;
    overflow: hidden;
}
.section-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-2);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.section-title {
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 8px;
}
.section-badge {
    background: var(--coral);
    color: white;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: 700;
}
.section-body { padding: 20px; }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray-3);
}
.empty-state-emoji { font-size: 3em; margin-bottom: 12px; }

/* Bid Cards */
.bid-card {
    background: var(--gray-1);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.bid-card:last-child { margin-bottom: 0; }
.bid-card-info { flex: 1; min-width: 150px; }
.bid-card-location { font-weight: 700; margin-bottom: 4px; }
.bid-card-meta { font-size: 0.85em; color: var(--gray-3); }
.bid-card-amount { font-size: 1.3em; font-weight: 800; color: var(--mint); }
.bid-card-actions { display: flex; gap: 8px; }

/* Square Cards */
.squares-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
}
.square-card {
    background: var(--gray-1);
    border-radius: 14px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}
.square-card:hover {
    border-color: var(--purple);
    transform: translateY(-2px);
}
.square-card-color {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    margin: 0 auto 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.square-card-coords { font-weight: 700; font-size: 0.85em; margin-bottom: 4px; }
.square-card-date { font-size: 0.75em; color: var(--gray-3); }

/* ===== ALERTS ===== */
.alert {
    padding: 14px 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-weight: 600;
}
.alert-success { background: var(--mint-light); color: #059669; border: 1px solid var(--mint); }
.alert-warning { background: var(--yellow-light); color: #B8860B; border: 1px solid var(--yellow); }
.alert-error { background: var(--coral-light); color: var(--coral); border: 1px solid var(--coral); }

/* ===== SUCCESS PAGE ===== */
.success-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    text-align: center;
}
.success-box {
    background: var(--white);
    border-radius: 24px;
    padding: 48px;
    max-width: 480px;
    box-shadow: 0 20px 60px rgba(26, 26, 46, 0.1);
}
.success-emoji { font-size: 4em; margin-bottom: 16px; }
.success-title { font-size: 1.8em; font-weight: 800; margin-bottom: 12px; }
.success-text { color: var(--gray-4); margin-bottom: 24px; line-height: 1.7; }

/* Confetti */
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    top: -10px;
    animation: confetti-fall 3s ease-out forwards;
    z-index: 1000;
    pointer-events: none;
}
@keyframes confetti-fall {
    to { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* ===== MAPLIBRE ===== */
.maplibregl-ctrl-attrib {
    font-size: 10px !important;
    background: rgba(255,255,255,0.8) !important;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .header { padding: 10px 16px; }
    .header-center { display: none; }
    .logo-icon { width: 32px; height: 32px; font-size: 9px; }
    .logo-text { font-size: 1.1em; }
    
    .map-container { top: 53px; }
    
    .panel {
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        border-radius: 20px 20px 0 0;
        max-height: 70vh;
        overflow-y: auto;
    }
    
    .zoom-hint { bottom: 80px; font-size: 0.85em; padding: 10px 20px; }
    
    .dashboard { padding: 20px 16px 30px; }
    .dashboard-title { font-size: 1.5em; }
    .dashboard-stats { grid-template-columns: repeat(2, 1fr); }
    .stat-card { padding: 16px; }
    .stat-card-value { font-size: 1.5em; }
    
    .squares-grid { grid-template-columns: repeat(2, 1fr); }
    
    .user-name { display: none; }
    .user-balance span { display: none; }
    
    .toast-container { left: 16px; right: 16px; top: 70px; }
    .toast { max-width: 100%; }
}