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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f5f7fa;
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid #e1e5eb;
    margin-bottom: 30px;
}

header h1 {
    font-size: 24px;
    color: #1a1a2e;
}

.wallet-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.network-badge {
    background: #e8f4fd;
    color: #0066cc;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
}

.chain-id-badge {
    background: #fff3e0;
    color: #e65100;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-family: monospace;
}

.account-badge {
    background: #f0f0f0;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-family: monospace;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary {
    background: #5865f2;
    color: white;
}

.btn-primary:hover {
    background: #4752c4;
}

.btn-secondary {
    background: #e3e5e8;
    color: #333;
}

.btn-secondary:hover {
    background: #d4d7dc;
}

.btn-success {
    background: #3ba55c;
    color: white;
}

.btn-success:hover {
    background: #2d8049;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

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

/* Cards */
.card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: #1a1a2e;
}

.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-header-row .card-title {
    margin-bottom: 0;
}

.card-actions {
    display: flex;
    gap: 8px;
}

/* Form Elements */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: #555;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: #5865f2;
}

textarea.form-control {
    resize: vertical;
    min-height: 120px;
    font-family: monospace;
    font-size: 12px;
}

.input-group {
    display: flex;
    gap: 10px;
}

.input-group .form-control {
    flex: 1;
}

/* Message */
.message {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: none;
}

.message.info {
    background: #e8f4fd;
    color: #0066cc;
}

.message.success {
    background: #e8f8ed;
    color: #2d8049;
}

.message.error {
    background: #fde8e8;
    color: #cc0000;
}

/* Contract Section */
#contract-section {
    display: none;
}

/* ABI Input Modal */
.abi-input-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #eee;
}

.abi-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.abi-tab {
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 13px;
}

.abi-tab.active {
    background: #5865f2;
    color: white;
    border-color: #5865f2;
}

.abi-content {
    display: none;
}

.abi-content.active {
    display: block;
}

/* Functions List */
.functions-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.function-card {
    border: 1px solid #e1e5eb;
    border-radius: 10px;
    overflow: hidden;
}

.function-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: #f9fafb;
    cursor: pointer;
}

.function-name {
    font-weight: 600;
    font-size: 14px;
    color: #1a1a2e;
}

.function-badge {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.function-badge.read {
    background: #e8f4fd;
    color: #0066cc;
}

.function-badge.write {
    background: #fff3e0;
    color: #e65100;
}

.function-body {
    padding: 16px;
    display: none;
    border-top: 1px solid #e1e5eb;
}

.function-body.expanded {
    display: block;
}

.param-input {
    margin-bottom: 12px;
}

.param-label {
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
}

.param-type {
    color: #888;
    font-family: monospace;
}

.function-result {
    margin-top: 12px;
    padding: 12px;
    background: #f5f7fa;
    border-radius: 6px;
    font-family: monospace;
    font-size: 13px;
    word-break: break-all;
    white-space: pre-wrap;
}

.function-result.error {
    background: #fde8e8;
    color: #cc0000;
}

.function-result.success {
    background: #e8f8ed;
    color: #2d8049;
}

/* Loading */
.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #5865f2;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* File Upload */
.file-upload {
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s;
}

.file-upload:hover {
    border-color: #5865f2;
}

.file-upload input {
    display: none;
}

/* Contract Tabs */
.contract-tabs-wrapper {
    margin-bottom: 20px;
}

.contract-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    background: white;
    padding: 12px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.contract-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px solid #e1e5eb;
    border-radius: 8px;
    background: #f9fafb;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    max-width: 200px;
}

.contract-tab:hover {
    border-color: #5865f2;
}

.contract-tab.active {
    background: #5865f2;
    color: white;
    border-color: #5865f2;
}

.contract-tab-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.contract-tab-address {
    font-size: 11px;
    opacity: 0.7;
    font-family: monospace;
}

.contract-tab-close {
    margin-left: 4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.1);
    color: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
}

.contract-tab.active .contract-tab-close {
    background: rgba(255,255,255,0.2);
}

.contract-tab-close:hover {
    background: rgba(0,0,0,0.2);
}

.contract-tab.active .contract-tab-close:hover {
    background: rgba(255,255,255,0.3);
}

/* Contract Header */
.contract-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.contract-header .card-title {
    margin-bottom: 0;
}

.contract-header-actions {
    display: flex;
    gap: 8px;
}

.contract-address-display {
    font-family: monospace;
    font-size: 12px;
    color: #666;
    margin-bottom: 16px;
    padding: 8px 12px;
    background: #f5f7fa;
    border-radius: 6px;
    word-break: break-all;
}

/* Responsive */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 15px;
    }

    .wallet-info {
        flex-wrap: wrap;
        justify-content: center;
    }

    .input-group {
        flex-direction: column;
    }

    .contract-tab {
        max-width: 100%;
        flex: 1;
    }
}
