/* Lottery page styles — standalone download */
/* Based on tokenpage.css — shared infrastructure kept, lottery-specific sections added */

/* Ensure [hidden] always wins over display rules */
[hidden] { display: none !important; }

.lottery-page {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #1a1a2e;
    line-height: 1.6;
    max-width: 720px;
    margin: 0 auto;
}

/* Header: logo + title + wallet */
.lp-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e0e0e0;
}

.lp-logo {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #6c5ce7;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    flex-shrink: 0;
}

.lp-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    flex: 1;
}

/* Section */
.lp-section {
    margin-bottom: 1.5rem;
}

.lp-section-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.75rem 0;
    color: #444;
}

/* Row: label + value */
.lp-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
}

.lp-row:last-child {
    border-bottom: none;
}

.lp-label {
    font-size: 0.875rem;
    color: #666;
    flex-shrink: 0;
    margin-right: 1rem;
}

.lp-value {
    font-size: 0.875rem;
    font-weight: 500;
    text-align: right;
    word-break: break-all;
}

/* ---- Wallet connection (shared with tokenpage) ---- */

.lp-connect-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.375rem;
    background: #6c5ce7;
    color: #fff;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}

.lp-connect-btn:hover {
    background: #5a4bd1;
}

.lp-connect-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.lp-wallet-wrapper {
    margin-left: auto;
    position: relative;
    flex-shrink: 0;
}

.lp-dropdown-addr {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #f0f0f0;
}

/* Address display (same as tokenpage) */
.addr-display {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.addr-link {
    color: #6c5ce7;
    text-decoration: none;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.8125rem;
}

.addr-link:hover {
    text-decoration: underline;
}

.addr-copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 2px;
    cursor: pointer;
    color: #666;
    border-radius: 0.25rem;
    transition: color 0.15s, background 0.15s;
}

.addr-copy-btn:hover {
    color: #6c5ce7;
    background: #f0f0f0;
}

/* Dropdown menu */
.lp-wallet-dropdown {
    position: absolute;
    top: calc(100% + 0.375rem);
    right: 0;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    min-width: 160px;
    z-index: 100;
    padding: 0.25rem 0;
}

.lp-dropdown-item {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: none;
    background: none;
    text-align: left;
    font-size: 0.8125rem;
    color: #1a1a2e;
    cursor: pointer;
}

.lp-dropdown-item:hover {
    background: #f8f8f8;
}

.lp-dropdown-danger {
    color: #c0392b;
}

.lp-dropdown-danger:hover {
    background: #fdf0ef;
}

/* ---- Input & button base ---- */

.lp-input {
    flex: 1;
    box-sizing: border-box;
    padding: 0.5rem 0.75rem;
    border: 1px solid #e0e0e0;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    color: #1a1a2e;
    background: #fff;
    outline: none;
    transition: border-color 0.15s;
}

.lp-input:focus {
    border-color: #6c5ce7;
}

.lp-input::placeholder {
    color: #aaa;
}

/* Hide number spinner */
.lp-input::-webkit-inner-spin-button,
.lp-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.lp-input[type=number] {
    -moz-appearance: textfield;
}

.lp-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.375rem;
    background: #6c5ce7;
    color: #fff;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.lp-btn:hover {
    background: #5a4bd1;
}

.lp-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---- TX result messages ---- */

.lp-tx-msg {
    font-size: 0.8125rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    margin-top: 0.75rem;
}

.lp-tx-success {
    background: #eafaf1;
    color: #27ae60;
    border: 1px solid #d5f5e3;
}

.lp-tx-error {
    background: #fdf0ef;
    color: #c0392b;
    border: 1px solid #fadbd8;
}

/* ---- Progress bar ---- */

.lp-progress-wrap {
    background: #f0f0f0;
    border-radius: 0.5rem;
    height: 1.25rem;
    overflow: hidden;
    margin: 0.75rem 0;
}

.lp-progress-bar {
    height: 100%;
    background: #6c5ce7;
    border-radius: 0.5rem;
    transition: width 0.3s ease;
    min-width: 0;
}

.lp-progress-text {
    text-align: center;
    font-size: 0.8125rem;
    color: #666;
    margin-top: 0.25rem;
}

/* ---- Buy ticket section ---- */

.lp-buy-section {
    text-align: center;
    padding: 1rem 0;
}

.lp-buy-btn {
    width: 100%;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    background: #6c5ce7;
    color: #fff;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background 0.15s;
}

.lp-buy-btn:hover {
    background: #5a4bd1;
}

.lp-buy-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---- Direct send (send BNB directly to contract) ---- */

.lp-direct-send {
    margin-top: 0.75rem;
    text-align: center;
}

.lp-direct-label {
    font-size: 0.75rem;
    color: #888;
    margin-bottom: 0.25rem;
}

.lp-direct-addr {
    display: block;
    font-size: 0.75rem;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    color: #6c5ce7;
    word-break: break-all;
    cursor: pointer;
    transition: color 0.15s;
}

.lp-direct-addr:hover {
    color: #1a1a2e;
}

/* ---- Connect prompt ---- */

.lp-connect-prompt {
    text-align: center;
    padding: 2rem;
    color: #888;
}

.lp-connect-prompt .lp-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

/* ---- Claim section ---- */

.lp-claim-section {
    background: #eafaf1;
    border: 1px solid #d5f5e3;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
    text-align: center;
}

.lp-claim-label {
    font-size: 0.8125rem;
    color: #666;
    margin-bottom: 0.25rem;
}

.lp-claim-amount {
    font-size: 1.25rem;
    font-weight: 700;
    color: #27ae60;
    margin-bottom: 0.5rem;
}

.lp-claim-zero {
    color: #888;
}

.lp-claim-haircut {
    color: #e67e22;
}

.lp-haircut-note {
    display: block;
    font-size: 0.8125rem;
    color: #c0392b;
    font-weight: 500;
}

.lp-btn-claim {
    padding: 0.5rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    background: #27ae60;
    color: #fff;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
}

.lp-btn-claim:hover {
    background: #219a52;
}

.lp-btn-claim:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---- Ticket list ---- */

.lp-ticket-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.8125rem;
}

.lp-ticket-row:last-child {
    border-bottom: none;
}

.lp-ticket-id {
    font-weight: 600;
    min-width: 5rem;
}

.lp-ticket-round {
    color: #666;
    min-width: 4rem;
}

.lp-ticket-date {
    color: #888;
    flex: 1;
}

.lp-ticket-status {
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    border-radius: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.lp-status-active {
    background: #eafaf1;
    color: #27ae60;
}

.lp-status-winner {
    background: #fef9e7;
    color: #f39c12;
}

.lp-status-refunded {
    background: #f0f0f0;
    color: #888;
}

.lp-ticket-refunded {
    opacity: 0.6;
}

.lp-ticket-winner {
    background: #fffbf0;
}

.lp-refund-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    color: #c0392b;
    background: none;
    border: 1px solid #fadbd8;
    border-radius: 0.25rem;
    cursor: pointer;
}

.lp-refund-btn:hover {
    background: #fdf0ef;
}

.lp-refund-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.lp-empty {
    text-align: center;
    color: #888;
    padding: 1rem;
    font-size: 0.875rem;
}

/* ---- Round history table ---- */

.lp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.lp-table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    background: #f8f8f8;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-size: 0.6875rem;
    border-bottom: 1px solid #e0e0e0;
}

.lp-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #f0f0f0;
}

.lp-table tr:last-child td {
    border-bottom: none;
}

/* ---- Round participants navigation ---- */

.lp-participants-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.lp-participants-header .lp-section-title {
    margin: 0;
}

.lp-participants-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.lp-nav-btn {
    padding: 0.25rem 0.5rem;
    border: 1px solid #e0e0e0;
    border-radius: 0.25rem;
    background: #f8f8f8;
    color: #444;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.15s;
}

.lp-nav-btn:hover {
    background: #e0e0e0;
}

.lp-nav-latest {
    font-size: 0.6875rem;
    margin-left: 0.25rem;
}

.lp-nav-label {
    font-size: 0.75rem;
    color: #888;
}

.lp-nav-input {
    width: 3.5rem;
    box-sizing: border-box;
    padding: 0.25rem 0.375rem;
    border: 1px solid #e0e0e0;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    text-align: center;
    color: #1a1a2e;
    background: #fff;
    outline: none;
}

.lp-nav-input:focus {
    border-color: #6c5ce7;
}

/* Hide spinner on nav input */
.lp-nav-input::-webkit-inner-spin-button,
.lp-nav-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.lp-nav-input[type=number] {
    -moz-appearance: textfield;
}

.lp-empty-cell {
    text-align: center;
    color: #888;
    padding: 1rem;
}

.lp-mono {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.8125rem;
}

/* ---- Totals strip ---- */

.lp-totals {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    padding: 0.75rem;
    background: #f8f8f8;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.lp-total-label {
    font-size: 0.6875rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.lp-total-value {
    font-size: 0.875rem;
    font-weight: 600;
    color: #1a1a2e;
}

/* ---- Refund terms ---- */

.lp-refund-terms {
    font-size: 0.8125rem;
    color: #888;
    padding: 0.5rem 0.75rem;
    background: #fef9e7;
    border: 1px solid #f5c67a;
    border-radius: 0.375rem;
    margin: 0.75rem 0;
}

/* ---- Contract address section ---- */

.lp-contract-addr {
    font-size: 0.8125rem;
    color: #888;
    margin-top: 0.75rem;
    text-align: center;
}

/* ---- Admin panel ---- */

.lp-admin-panel {
    border: 2px solid #c0392b;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-top: 1.5rem;
}

.lp-admin-title {
    font-size: 1rem;
    font-weight: 700;
    color: #c0392b;
    margin: 0 0 1rem 0;
}

.lp-admin-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: #f8f8f8;
    border-radius: 0.375rem;
    font-size: 0.8125rem;
}

.lp-admin-stat-label {
    color: #888;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.lp-admin-stat-value {
    font-weight: 600;
    color: #1a1a2e;
}

.lp-admin-section {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #f0f0f0;
}

.lp-admin-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.lp-admin-section-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #444;
    margin: 0 0 0.5rem 0;
}

.lp-admin-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

.lp-admin-row > * {
    min-width: 0;
}

.lp-admin-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.375rem;
    background: #6c5ce7;
    color: #fff;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.lp-admin-btn:hover {
    background: #5a4bd1;
}

.lp-admin-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.lp-btn-danger {
    background: #c0392b;
}

.lp-btn-danger:hover {
    background: #a93226;
}

.lp-admin-result {
    font-size: 0.8125rem;
    padding: 0.5rem 0.75rem;
    background: #f8f8f8;
    border-radius: 0.375rem;
    margin-top: 0.5rem;
}

.lp-danger-zone {
    border-top: 1px solid #fadbd8;
    margin-top: 1rem;
    padding-top: 1rem;
}

.lp-danger-label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: #c0392b;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.5rem;
}

/* ---- Mobile ---- */
@media (max-width: 480px) {
    .lottery-page {
        padding: 0 0.5rem;
    }

    .lp-header {
        gap: 0.5rem;
    }

    .lp-logo {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }

    .lp-title {
        font-size: 1.25rem;
    }

    .lp-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.125rem;
    }

    .lp-value {
        text-align: left;
    }

    .lp-connect-btn {
        padding: 0.375rem 0.75rem;
        font-size: 0.75rem;
    }

    .addr-link {
        font-size: 0.75rem;
    }

    .lp-totals {
        grid-template-columns: 1fr;
    }

    .lp-admin-stats {
        grid-template-columns: 1fr;
    }

    .lp-admin-row {
        flex-direction: column;
        align-items: stretch;
    }

    .lp-admin-row .lp-input,
    .lp-admin-row .lp-admin-btn {
        width: 100%;
    }

    .lp-participants-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .lp-participants-nav {
        width: 100%;
        flex-wrap: wrap;
    }

    .lp-nav-latest {
        margin-left: 0;
    }

    .lp-participants-table thead {
        display: none;
    }

    .lp-participants-table,
    .lp-participants-table tbody,
    .lp-participants-table tr {
        display: block;
        width: 100%;
    }

    .lp-participants-table tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 0.75rem 1rem;
        padding: 0.875rem;
        margin-bottom: 0.75rem;
        border: 1px solid #f0f0f0;
        border-radius: 0.5rem;
        background: #fff;
    }

    .lp-participants-table tr:last-child {
        margin-bottom: 0;
    }

    .lp-participants-table td {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
        min-width: 0;
        padding: 0;
        border-bottom: none;
    }

    .lp-participants-table td::before {
        font-size: 0.6875rem;
        font-weight: 600;
        color: #888;
        text-transform: uppercase;
        letter-spacing: 0.03em;
    }

    .lp-participants-table td:nth-child(1) {
        grid-column: 1;
    }

    .lp-participants-table td:nth-child(1)::before {
        content: 'Ticket';
    }

    .lp-participants-table td:nth-child(2) {
        grid-column: 1 / -1;
    }

    .lp-participants-table td:nth-child(2)::before {
        content: 'Address';
    }

    .lp-participants-table td:nth-child(3) {
        grid-column: 1 / -1;
    }

    .lp-participants-table td:nth-child(3)::before {
        content: 'Time';
    }

    .lp-participants-table td:nth-child(4) {
        grid-column: 2;
        align-items: flex-end;
        text-align: right;
    }

    .lp-participants-table td:nth-child(4)::before {
        content: 'Status';
    }

    .lp-participants-table .lp-empty-cell {
        grid-column: 1 / -1;
        align-items: center;
        text-align: center;
        padding: 0.25rem 0;
    }

    .lp-participants-table .lp-empty-cell::before {
        content: none;
    }

    .lp-ticket-row {
        flex-wrap: wrap;
    }
}
